문제

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.

도움이 되었습니까?

해결책

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?

다른 팁

This could also be done by adding

GRUB_DEFAULT=saved

to your grub.cfg . Then you can create 2 different GRUB entries to the bootloader (eg. "RedHat" and "RedHat RO". The set the default entry like this in your terminal

grub-set-default "RedHat"

To run the other grub entry only for the next reboot issue in your terminal

grub-reboot "RedHat RO"

This works essentially, by adding a flag in the grub configuration (grubenv) and removing it after reboot. So basically your /boot/ partition has to be writeable. You can also remount the boot partition writeable if necessary. In any case you need the /boot/ directory on a separate partition.

Another alternative would be to put the boot partition on a USB stick and boot the "RedHat RO" from there every time you need it.

Otherwise: As sarnold already said: The changes you do in the GRUB command line or GRUB editing are only temporary.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top