2

When the Linux kernel starts up, it uses initrd as the root / filesystem, then replaces that with a filesystem partition in fstab.

Based on a test in an early init script, I want to replace that root / filesystem with another filesystem partition. How to do that?

  • Are you asking to create a dual boot? – ryekayo Aug 18 '14 at 17:24
  • @ryekayo no, not dual boot. Dual boot is a modification of boot loader. I'm not modifying the boot loader. – Sepero Aug 18 '14 at 17:30
  • Do you mean that you want to go initrd → root #1 → root #2? This isn't possible. But you can modify the content of the initrd and go initrd → root #2. (Are you sure it's an initrd and not an initramfs? Most distributions have switched to initramfs, even though the image file may still be called initrd; the principle is the same but the mechanics are a little different.) What tests do you need to make to determine the location of the root filesystem? – Gilles Aug 18 '14 at 21:36
  • Here's an alternative in case you can't do it inside initrd: list all your possible roots as separate boot options in grub.conf, then in an init script use grub-reboot n to choose one of them if the desired root isn't currently mounted. superuser.com/a/290458/264506 has some details. – Mark Plotnick Aug 19 '14 at 0:16
  • Thanks for the suggestion Mark. Unfortunately the machine is Arm architecture and doesn't use grub. – Sepero Aug 24 '14 at 15:35
0

I know this is an old thread, but still came up in Google.

if you stumble on this, look at pivot_root https://linux.die.net/man/8/pivot_root

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.