Saturday, November 29, 2014

linux - Make a Bootable USB That Saves a Few Files, Overwrites Local Drive, Restores the Few Files

I have a situation similar to Oli's Question.


What I have are small Ubuntu hosts that perform like kiosks and they need a complete rebuild. The technician will attach a USB keyboard and USB stick. They will boot the USB stick, a task they've done before, and then four tasks will happen.



  1. A few files from the local SSD will be saved to the USB. Can this simply be a different partition on the USB, mounted rw?

  2. The local drive will be completely overwritten with a new image.


    dd if=generic-image of=local-SSD bs=1M


  3. Restore the saved files.


  4. Reboot. The BIOS/uEFI boot order lists the local SSD first, so it won't boot from the USB.


The kiosks only have one 32 GB SSD, so my image will be around 32 GB in size. Boot order lists the local SSD first. If these devices are connected to a network, it can be unreliable, so Internet downloads aren't an option.


I can make a bootable USB, but where do I go from there? Modify some GRUB line to run a special script? (This seems simplest, but how?) Modify some systemd service to run once? (How?) Force Anaconda to use a simple ks.cfg that only uses %pre and %post without any %package? (How would I setup Anaconda? I've done kickstart files before, but never with no %package section.)


In the MS-DOS days, I'd have a bootable floppy disk and modify autoexec.bat to do tasks 1, 2, and 3. This can't be that hard with all the Linux tools at my disposal.

No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...