One time boot into Read Only?

neuroelectronic picture neuroelectronic · Nov 3, 2011 · Viewed 8.4k times · Source

I'm trying to boot into read only mode to test some software. I don't want to remount a drive after booting as that would not meet the requirements to test the software which checks the file system at boot.

Is there a way to do this without editing grub.conf? Preferably adding something via the grub UI when interrupting boot?

If I do edit the grub.conf to boot in read only, how am I supposed to edit it back?


I understand that the kernel mounts root as RO but it's remounted as RW later in the boot process.

Answer

sarnold picture sarnold · Nov 3, 2011

When grub is running, you typically have some ability to edit the kernel command line before grub loads the kernel and continues booting. Perhaps your distribution has hidden the grub interface at boot -- holding down the left shift may bring it up and let you edit the kernel command line.

The Linux kernel Documentation/kernel-parameters.txt documents the ro kernel command parameter to mount your root filesystem read-only. If you add-in init=/bin/sh, then you'll be in charge of mounting whatever filesystems you want. You may need to mount /proc before mount(8) will show any mounted filesystems: mount -t proc none /proc.

Just be sure to give the -o ro or -o rw option to mount(8) as your mount each filesystem as you desire.

But I have to think there are better ways of testing software. What are you really trying to do?