I have couple of servers running off of an usb stick each. Servers are basically hypervizors.
What I was thinking of doing is distributing binary updates in form of downloading system image and unpacking it directly onto live usb disk device, followed by a reboot. This technique would boil down to dd if=newimage.img of=/dev/sda && reboot
.
However, I have tried this, and it doesn't quite work as expected. Newly imaged disk is unable to boot.
As it's possible to run series of commands on each host and have them updated that way most of the time, this is not something critical to me. But, I'd like to learn if there's a way to unpack disk image on top of live running system, and have it boot properly into new environment, whichever it is. For example, I might decide to replace those linuxes by completely different OS some day, who knows :)
Ideas, suggestions?
(Assuming that the answer to my previous question is a "yes"). Possibly the host is writing to (its idea of the correct filesystem layout on) the USB device while or after
dd
is running. You could try aremount -o ro,remount
on the filesystems of the running host before doing thedd
, but you might then preventdd
itself from working when it tries to write to /dev/sda. You might also want a quick and 'brutal' reboot (echo b > /proc/sysrq-trigger
) so that the OS does not try to write anything during shutdown.Clobering the file system of the currently running system sounds like a bad idea. You might get it to work by remounting the root filesystem read-only, then doing the
dd
command, then reseting the system (Note: don't use the reboot script because you don't want to do the shutdown stuff if you have clobbered the root file system, you just want to restart the system onto it.)