StatelessLinux/CreateImageWithXen

From FedoraProject

Jump to: navigation, search

Stateless Linux - Creating An Image Using Xen

See Stateless Linux HOWTO

Before you begin, you'll need to be running a xen hypervisor and kernel and have xend running. See FedoraXenQuickstartFC5 for more details.

Running xenguest-install.py, you get asked a number of questions:


All these options can be specified on the command line, so e.g. using paravirt:

$> xenguest-install.py -n Terminal -f terminal-pv.img -s 4 -r 512
-p -l http://172.31.0.4/rawhide-latest/x86_64

It should also be possible to install using fully-virt, with e.g.

$> xenguest-install.py -n Terminal -f terminal-fv.img -s 4 -r 512
-v -c ./boot.iso

Notes:

Copying The Root Filesystem Image

Now you'll want to extract the ext3 root filesystem image from the disk image.

First, associate the disk image with a loopback device:

$> losetup ./terminal-pv.img /dev/loop0

Now, using the kpartx utility from the device-mapper-multipath package, create devices which map to each of the partitions on the disk image:

$> kpartx -av /dev/loop0
add map loop0p1 : 0 208782 linear /dev/loop0 63
add map loop0p2 : 0 8177085 linear /dev/loop0 208845

This causes the /dev/mapper/loop0p1 and /dev/mapper/loop0p2 devices to be created, mapping to the partitions on the disk image.

Assuming you created the root filesystem in an LVM volume, you'll now need to activate the volume group stored on the second partition on the disk image.

$> vgscan
Reading all physical volumes.  This may take a while...
Found volume group "TerminalVG" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2
$> vgchange -ay TerminalVG

You can now copy the root filesystem image to a file:

$> dd if=/dev/TerminalVG/LogVol00 of=./terminal-rootfs.img


Optionally, you can use this little utility to make a sparse copy (i.e. a copy which takes up less space) of the image:

$> e2cp ./terminal-rootfs.img ./terminal-rootfs-sparse.img

Finally, clean up after yourself:

$> vgchange -an TerminalVG
$> kpartx -d /dev/loop0
$> losetup -d /dev/loop0