title: Modify/Set root device in initramfs script
body: <p>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.</p>
  
  <p>I tried various options like reading/setting $root variable, but that didn't work.</p>
  
  <p>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.</p>