Previously I’ve shown you can use guestfish to unpack a Fedora live CD.
I’m interested in whether we can use the contents of these live CDs to mass-install operating systems using libguestfs.
If you imagine that you go through an “all defaults” install of say Fedora or Ubuntu to a new virtual machine, then when you end up with is an identical disk image containing 1-2 GB of default packages and a lot of empty space. Two people asked to go through the same all-defaults install of the same distro would end up with roughly the same content. The details on the disk would be slightly different because some parts of the disk partitioning and ext3 superblocks change slightly depending on the overall disk size. But really those things can be fixed up afterwards using a little repartitioning, lvresize and resize2fs.
Let’s look inside an Ubuntu live CD:
$ guestfish --ro -a ubuntu-9.10-desktop-amd64.iso Welcome to guestfish, the libguestfs filesystem interactive shell for editing virtual machine filesystems. Type: 'help' for help with commands 'quit' to quit the shell ><fs> run ><fs> list-devices /dev/sda ><fs> file /dev/sda ISO 9660 CD-ROM filesystem data 'Ubuntu 9.10 amd64 ><fs> mkmountpoint /t1 ><fs> mount /dev/sda /t1 ><fs> ll /t1/casper total 691049 dr-xr-xr-x 2 root root 2048 Oct 27 14:31 . dr-xr-xr-x 10 root root 2048 Oct 27 14:31 .. -r--r--r-- 2 root root 37288 Oct 27 14:19 filesystem.manifest -r--r--r-- 2 root root 35354 Oct 27 14:16 filesystem.manifest-desktop -r--r--r-- 2 root root 697778176 Oct 27 14:25 filesystem.squashfs -r--r--r-- 2 root root 5836401 Oct 27 14:20 initrd.lz -r--r--r-- 2 root root 3941696 Oct 16 12:12 vmlinuz ><fs> mkmountpoint /t2 ><fs> mount-loop /t1/casper/filesystem.squashfs /t2 ><fs> cat /t2/etc/debian_version squeeze/sid
The file /casper/filesystem.squashfs
seems to be a complete Ubuntu installation, and if I’m understanding this correctly the Ubuntu installer will copy this to the newly created filesystem directly. That will be the new Ubuntu installation, plus or minus some config file changes and some extra packages downloaded afterwards from the net.
Here’s the same examination of the Fedora 12 Live CD:
$ guestfish --ro -a Fedora-12-x86_64-Live.iso Welcome to guestfish, the libguestfs filesystem interactive shell for editing virtual machine filesystems. Type: 'help' for help with commands 'quit' to quit the shell ><fs> run ><fs> list-devices /dev/sda ><fs> file /dev/sda ISO 9660 CD-ROM filesystem data 'Fedora-12-x86_64-Live ><fs> mkmountpoint /t1 ><fs> mount /dev/sda /t1 ><fs> ls /t1 EFI GPL LiveOS isolinux ><fs> ll /t1/LiveOS total 655291 dr-xr-xr-x 2 root root 2048 Nov 9 14:45 . dr-xr-xr-x 5 root root 2048 Nov 9 14:44 .. -r-xr-xr-x 1 root root 23040 Nov 9 14:44 livecd-iso-to-disk -r-xr-xr-x 1 root root 8192 Nov 9 14:45 osmin.img -r-xr-xr-x 1 root root 670982144 Nov 9 14:48 squashfs.img ><fs> mkmountpoint /t2 ><fs> mount-loop /t1/LiveOS/squashfs.img /t2 ><fs> ls /t2 LiveOS ><fs> ls /t2/LiveOS/ ext3fs.img ><fs> mkmountpoint /t3 ><fs> mount-loop /t2/LiveOS/ext3fs.img /t3 ><fs> cat /t3/etc/redhat-release Fedora release 12 (Constantine)
Again I hope I assume correctly that the installer copies ext3fs.img
to the hard disk when installing Fedora 12.
So my vague plan, assuming anything I’ve written above is correct, is to take these pre-made filesystem images and allow people to quickly install specific operating system images from a simple tool:
$ virt-press Fedora-12 F12
which would stamp out a Fedora 12 VM in a few seconds and register it with libvirt as “F12”.
I’m not sure this is possible yet …
Pingback: Prebuilt distributions part 1 « Richard WM Jones
Pingback: GLLUG talk on libguestfs (18th March 2010) « Richard WM Jones
Pingback: Tip: Use guestfish to look inside an Arch Linux ISO « Richard WM Jones