6

I'm trying to come up with a bash-scriptable method of replacing the root filesystem on a running PC. The system uses a MBR partitioned disk with an ext4 rootfs and a swap partition, unfortunately it doesn't use LVM / BTRFS or anything useful like that. It's running a minimal Debian distro using grub / kernel & initrd / systemd.

There is no physical access to the PC in question - it is running some kiosk software, with which a proprietary tool can be used to push a tarball containing binaries and an update shell script to the PC. My plan is to use this update system to try to replace the rootfs.

My ideas basically boil down to the following:

  • Replace the initrd with a custom version which does not switch_root to the real rootfs but instead replaces it (probably using dd to write a new image), then reboot to the new system

  • (Somehow!) switch_root from the live system to some sort of temporary filesystem, then do the above dd & reboot

  • As above, but pivot_root the init process to a new, temporary fs and do the above, or something like it...

I'm not familiar with pivot_root and switch_root functionality and am currently having a play - i'm sure this has been done before, but I've searched and not found a solution!

5

See this Stack Exchange answer. The accepted answer points to this link, which explains how to use pivot_root to create a temporary in-memory root filesystem, which enables you to change, resize, replace or in any other way mess with your root filesystem without reboot.

1
  • Perfect, that's exactly what I am after. Thanks! – hygri May 22 '15 at 12:22

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.