Once loaded in read-only?

I am trying to boot into read-only mode to test some software. I do not want to reboot the disk after loading, since this does not meet the requirements for testing software that checks the file system at boot.

Is there a way to do this without editing grub.conf? Is it advisable to add something via the grub interface when loading is interrupted?

If I edit grub.conf to load in read-only mode, how do I edit it?


I understand that the kernel mounts root as RO, but later reboots as RW during the boot process.

+4
source share
2 answers

When grub is running, you usually have the option to edit the kernel command line before grub boots the kernel and continues to boot. Perhaps your distribution has a grub interface hidden at boot time - holding the left shift can lead to its update and allow editing the command line kernel.

The Linux kernel Documentation/kernel-parameters.txt documents the ro kernel command parameter for mounting your read-only root file system. If you added init=/bin/sh , then you will be responsible for installing any file systems you want. You may need to install /proc before mount(8) shows all mounted file systems: mount -t proc none /proc .

Just remember to specify the -o ro or -o rw mount(8) option to mount(8) each file system as you wish.

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

+4
source

You can also do this by adding

 GRUB_DEFAULT=saved 

to your grub.cfg. Then you can create 2 different GRUB entries for the bootloader (for example, "RedHat" and "RedHat RO"). To do this, enter the default entry, as it is in your terminal

 grub-set-default "RedHat" 

To run another grub entry only for the next reboot problem in your terminal

 grub-reboot "RedHat RO" 

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

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

Otherwise: As sarnold already said: Changes made to the GRUB command line or editing GRUB are temporary.

+1
source

Source: https://habr.com/ru/post/1379404/


All Articles