Cloning the sample image

The way to go would be like this:
  • Create the root & swap partitions
    lvcreate -L 12G -n arc02_root vg_root
    lvcreate -L 4G -n arc02_swap vg_root
    mkswap /dev/vg_root/lrms02_swap -L SWAP-hdb1
  • from xen11:
    cat /scratch/sample_root.img | ssh xen14 'cat > /dev/vg_root/lrms01_root_REPLACE_THIS_DEVICE'
  • Create the xen config file
    cp /etc/xen/sample /etc/xen/arc02
  • Mount the new image
    kpartx -a /dev/vg_root/arc02_root
    mount /dev/mapper/arc02_root1 /mnt
  • run ./finalize_xen_guest.sh HOSTNAME MAC
  • Umount the image
    cd /
    umount /mnt
    kpartx -d /dev/vg_root/arc02_root

NOTE-NOTE-NOTE: Avoid using the dash (-) in the name of the images, because it triggers a bug (added by FG, 20100825)

Creation of a Xen Sample image

We begin from a working virtual machine already shut down, that we cloned somewhere with dd like this:
lvcreate -L 12G -n sample_root vg_root
dd if=/dev/vg_root/ui64_root of=/dev/vg_root/sample_root

Then, we need to create a /etc/xen/sample file with this content:

name = "@@SIMPLENAME@@"

vcpus = 2
memory = 4096
disk = ['phy:/dev/vg_root/@@SIMPLENAME@@_root,xvda,w',
        'phy:/dev/vg_root/@@SIMPLENAME@@_swap,xvdb,w']
vif = ['mac=@@MAC@@,bridge=xenbr0']

bootloader = "/usr/bin/pygrub"
on_reboot = 'restart'
on_crash = 'destroy'

Afterward we need to mount the sample image from the xen host, but we need to map it first (it's a partitioned block device):

kpartx -a /dev/vg_root/sample_root
mount /dev/mapper/sample_root1 /mnt/

To find the files to change, running a grep test54 /mnt/etc/* -R will help, but see below. Then go file by file and change to fit this variables (examples, they need to match the finalize_xen script):

  • @@NAME@@
  • @@IP_LAST@@ (last two digits of the IP, to be able to match 148.187 and 10.10 interfaces with the same field)

You may want also to do some tweaking to the ifcfg-eth*:

  • Delete the line HWADDR if you are setting up static IP addresses (so that you don't need a Mac adddress specified, it works with any)

And this is the list of the files that were changed

/mnt/etc/dhclient-eth0.conf
/mnt/etc/hosts
/mnt/etc/sysconfig/network
/mnt/etc/sysconfig/networking/profiles/default/ifcfg-eth0
/mnt/etc/sysconfig/networking/profiles/default/ifcfg-eth1
/mnt/etc/sysconfig/networking/profiles/default/network

Furthermore, you want to delete the local host ssh keys that are generated the first time sshd starts, to be unique in the next boot. rm /mnt/etc/ssh/ssh_host_*

At the end we need to umount the sample image and unmap it:

cd /
umount /mnt
kpartx -d /dev/vg_root/sample_root

-- PabloFernandez - 2010-02-18


This topic: LCGTier2 > WebHome > HardwareInformation > XenSampleImageReplication
Topic revision: r18 - 2011-09-01 - PabloFernandez
 
This site is powered by the TWiki collaboration platform Powered by Perl This site is powered by the TWiki collaboration platformCopyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback