You don't need to run this as a command during boot, you can achieve read-only mounting via the file /etc/fstab
. /etc/fstab
contains all filesystems that should be mounted upon boot and that's exactly what you want. It's also possible to add the mount
options (for example, ro
for read-only) to an /etc/fstab
entry.
The additional line you need to add to the file (for example, via sudo nano /etc/fstab
) looks like this:
/dev/sda2 /media/Windows ntfs ro 0 2
If you're interested in a cleaner way of creating that line, you'll need the UUID of your partition - The /dev/sdx allocation may change if you're adding different disks or even USB media (most likely it does not, nonetheless you're safer with using the UUID). To display the partition's UUID, run sudo blkid /dev/sda2
and change the line you have to match this syntax:
UUID=<UUID for /dev/sda2> /media/Windows ntfs ro 0 2
After saving the file, run sudo mount -a
to make sure your partition is mounted properly (unmount the partition before to make sure it really works).