2

I want to modify the root device node as a part of a script in initramfs. I don't want to execute switch_root myself (unless I have to). I would like to add in a script which can change the root device if certain conditions are met.

I tried various options like reading/setting $root variable, but that didn't work.

The background problem is that I am trying to encrypt the root device only if certain conditions are met. In such a case, I am copying the data from old root device into new encrypted device and want to switch the root to new encrypted /dev/mapper/secret device instead of preconfigured /dev/sda2.

Vivek
  • 89
  • 1
  • 4

1 Answers1

2

Based on my research, it seems that the root parameter given to kernel can't be changed via initramfs script.

See https://unix.stackexchange.com/questions/65589/kernel-grub-how-override-root-parameter-inside-initrd-script

@enzo2 provided the answer that the only way to achieve this by rewriting the grub config file (/boot/grub/menu.lst in my case) and issue a reboot so that kernel can be loaded with a different root device.

Community
  • 1
  • 1
Vivek
  • 89
  • 1
  • 4