How to mount a hard disk as read-only from the terminal
You do not mount /dev/sda
, that refers to the entire disk. You mount /dev/sda1
or whatever partition you want.
Make a mount point, call it anything you like.
sudo mkdir /media/2tb
Mount
sudo mount -o ro /dev/sda1 /media/2tb
When your done, you should unmount the disk
sudo umount /media/2tb
See man mount or https://help.ubuntu.com/community/Fstab
When mounting the filesystem read-only, some trouble may happen. The system may try to write into the device anyway and fail.
For that reason the noload
flag may be used, to notify to the system that the disk is blocked.
The best solution I found was:
sudo mount -o ro,noload /dev/sda1 /media/2tb
The manual of mount(8)
explains this options as follows:
-r
,--read-only
Mount the filesystem read-only. A synonym is
-o ro
.Note that, depending on the filesystem type, state and kernel behavior, the system may still write to the device. For example, Ext3 or ext4 will replay its journal if the filesystem is dirty. To prevent this kind of write access, you may want to mount ext3 or ext4 filesystem with
ro,noload
mount options or set the block device to read-only mode, see commandblockdev(8)
.[…]
norecovery
/noload
Don't load the journal on mounting. Note that if the filesystem was not unmounted cleanly, skipping the journal replay will lead to the filesystem containing inconsistencies that can lead to any number of problems.
For more info see the great explanation in “How to Mount Dirty EXT4 File Systems” on the SANS Digital Forensics and Incident Response Blog.
I am plugging a USB connected drive into Ubuntu 12.04 and the system is mounting it automatically. In Terminal, if I just say mount
it shows me the current info. I want to remount it read-only.
Extrapolated from man mount(8)
:
sudo mount -o remount,ro /dev/sdb4 /media/HP_TOOLS
Seemed to work nicely. Had to do it for each automounted partition.