I needed to create an automated Btrfs guest for a test. A trivial virt-install
based automated script couldn’t complete the guest install (on a Fedora Rawhide host) — it hung perpetually once it tries to retrieve .treeinfo, vmlinuz, initrd.img. On my cursory investigation with guestfish
, I couldn’t pin-point the root cause. Filed a bug here
[Edit, 31JAN2014: The above is fixed by adding –console=pty to virt-install
command-line; refer the above bug for discussion.]
In case someone wants to reproduce with versions I noted in the above bug:
$ wget http://kashyapc.fedorapeople.org/virt/create-guest-qcow2-btrfs.bash $ chmod +x create-guest-qcow2-btrfs.bash $ ./create-guest-qcow2-btrfs.bash fed-btrfs2 f20
Oz
So, I resorted to Oz – a utility to create automated installs of various Linux distributions. I previously wrote about it here
Below I describe a way to use it to create a minimal, automated Btrfs Fedora 20 guest template.
Install it:
$ yum install oz -y
A minimal Kickstart file with Btrfs partitioning:
$ cat Fedora20-btrfs.auto install text keyboard us lang en_US.UTF-8 network --device eth0 --bootproto dhcp rootpw fedora firewall --enabled ssh selinux --enforcing timezone --utc America/New_York bootloader --location=mbr --append="console=tty0 console=ttyS0,115200" zerombr clearpart --all --drives=vda autopart --type=btrfs reboot %packages @core %end
A TDL (Template Description Language) file that Oz needs as input:
$ cat f20.tdl <template> <name>f20btrfs</name> <os> <name>Fedora</name> <version>20</version> <arch>x86_64</arch> <install type='url'> <url>http://dl.fedoraproject.org/pub/fedora/linux/releases/20/Fedora/x86_64/os/</url> </install> <rootpw>fedora</rootpw> </os> <description>Fedora 20</description> </template>
Invoke oz-install
(supply the Kickstart & TDL files, turn on debugging to level 4 — all details):
$ oz-install -a Fedora20-btrfs.auto -d 4 f20.tdl [. . .] INFO:oz.Guest.FedoraGuest:Cleaning up after install Libvirt XML was written to f20btrfsJan_29_2014-11:38:44
Define the above Libvirt guest XML, start it over a serial console:
$ virsh define f20btrfsJan_29_2014-11:38:44 Domain f20btrfs defined from f20btrfsJan_29_2014-11:38:44 $ virsh start f20btrfs --console [. . .] Connected to domain f20btrfs Escape character is ^] Fedora release 20 (Heisenbug) Kernel 3.11.10-301.fc20.x86_64 on an x86_64 (ttyS0) localhost login:
It’s automated, fine, but still slightly more tedious (TDL file looks redundant at this point) to create custom guest image templates.