virt-sysprep firstboot
Wanted to play around with firstboot to answer a question in #openstack. Seemed that re-iterating runs of virt-sysprep adds copies of the firstboot scripts. I'm not sure how to delete them bar going in with guestfish.
First, clone an existing image the dumb way. Should probably run virt-sparsify to make it smaller.
sudo virt-clone --original centos7base --name firstboottest --auto-clone
Then added a --firstboot script. These run in the guest, as distinct from --script which runs on the host with host resources to do something to the guest.
vi testfirstboot.sh;
#!/usr/bin/env bash touch /root/testingfirstboot.txt echo "Testing firstboot with virt-sysprep"
Get virt-sysprep to modify the image, adding this firstboot script into the image:
virt-sysprep --firstboot /home/ush/Workspacen/VirtTests/testfirstboot.sh -a firstboottest.img
Examine the contents with guestfish
guestfish --ro -i -a firstboottest.img
><:fs> ls /usr/lib/virt-sysprep/scripts 1409153468-gpsyazqb-testfirstboot-sh
When I re-ran virt-sysprep adding a different firstboot script it was added into the directory. The directory was not cleared out. Similarly, running virt-sysprep with no --firstboot directive left the two files in the image directory:
><fs> ls /usr/lib/virt-sysprep/scripts 1409153468-gpsyazqb-testfirstboot-sh 1409154033-gpsyazqb-2testfirstboot-sh ><fs> quit
[root@rabelais images]# virt-sysprep --firstboot /home/ush/Workspacen/VirtTests/testfirstboot.sh -a firstboottest.img













