brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: mount -o remount,ro puts a disk read-only without unmounting it

Disk
~/tips/tip-disk-remount-readonly

sudo mount -o remount,ro /mnt/data

Switches a mounted filesystem to read-only in place, so a failing disk stops receiving writes.

When a disk acts up I want it to stop taking writes while I copy the data off.

sudo mount -o remount,ro /mnt/data
sudo mount -o remount,rw /mnt/data

The remount keeps the mount point and applies the new option to the live filesystem. It fails with “mount point is busy” while a process still has a file open for writing. Find that process with lsof /mnt/data first. The kernel does the same on its own when ext4 hits an error with the errors=remount-ro option, which is why a disk can suddenly turn read-only.

Further reading: mount manual page

More Disk tips sudo e2freefrag /dev/sdb1 sudo smartctl -a --json /dev/sda | jq '.smart_status.passed' lsscsi -s udisksctl power-off -b /dev/sdX du -sh — .[!.]* * 2>/dev/null | sort -h All Disk tips (44) All topics

Link