I am developing an embedded Linux system. The system is usually installed by creating a ISO file which is written to a USB stick the board can boot from.

To make the installation possible to do automatically (say, over night) I would like to be able to do the installation on the board while the old system is running.

My installation has two parts: An initrd file which contains busybox and install scripts, and a .tar.gz archive that has the rest of the root file system to install.

  1. The bootloader loads the kernel and points it to the initrd, and boots the kernel.
  2. The initrd install scripts mounts the target drive /dev/sda, formats it, installs the bootloader, and finally copies the root file system from .tar.gz and initrd.

Now I instead want to

  1. Copy install.iso from host computer to target device. (No problem)
  2. Do the installation steps as above.

My problem is that I don't know how I should go about replacing the currently running system with my new one. I assume that the currently mounted root (/) would have to be unmounted and replaced by the initrd. But I can't seem to figure out how!

2 Answers 2


I can think of different ways to do what you want. All of which carry a level of risk and difficulty. The main risk being that if the install goes wrong/breaks you will end up with an unbootable system that needs installing manually.

My main thought (which depends on your boot loader and similar) would be to use exactly the procedure that you have now. Basically copy the new install image onto your USB stick which is permanently left in the machine. Then just reboot and let it boot from that and install normally.

It relies on the following

  1. Hands-off install. I'm assuming that you have that otherwise an overnight reinstall would not be a problem.
  2. Your boot loader being able to choose between USB or local filesystem boot automatically (or via an application level command before rebooting)
  3. At the end you need to configure your boot loader to boot from the local board rather than the USB device or just erase the contents of the USB device/make it unbootable so that the bootloader falls over

An alternative to that would be to have two boot/root partitions on your board and just install into the one that you aren't using and at the end of the reboot force your bootloader to boot into the other. You could use a chroot environment to force your installer to think that it was booting from scratch. That is probably a big change in your environment though and would not be a quick win.

  • This is exactly what I ended up doing. Thanks!
    – kigurai
    Feb 16, 2011 at 12:45

Have you tried mounting initrd and then pivot_root? It seems what you want to do.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .