WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-users

Re: [Xen-users] How do I create an initrd for a vm that is using lvm ?

To: xen-users@xxxxxxxxxxxxxxxxxxx
Subject: Re: [Xen-users] How do I create an initrd for a vm that is using lvm ?
From: JoeSC100 <jarmstrong@xxxxxxxxxxxx>
Date: Fri, 12 Jun 2009 15:58:30 -0700 (PDT)
Delivery-date: Fri, 12 Jun 2009 15:59:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <23986257.post@xxxxxxxxxxxxxxx>
List-help: <mailto:xen-users-request@lists.xensource.com?subject=help>
List-id: Xen user discussion <xen-users.lists.xensource.com>
List-post: <mailto:xen-users@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-users>, <mailto:xen-users-request@lists.xensource.com?subject=unsubscribe>
References: <23986257.post@xxxxxxxxxxxxxxx>
Sender: xen-users-bounces@xxxxxxxxxxxxxxxxxxx

I hope this comes in handy for someone else.

Joe

Solution for CentOs 5.3:

The idea here was to clone a VM and change the VM's LVM group so that each
VM has its own group.  I wanted each VM to have its own LVM group just to
avoid my own stupid mistakes such as fsck'ing a VM's root partition but
doing
it on the wrong VM (especially bad if the VM is running)! 
        - this is possible if all VM's have the same LVM group name (VG00)
as doing a "vgchange -ay VG00" would get 
          whatever VM image happened to be dkpart'd at the time.
        - by having each VM with an LVM group containing its VMname, eg.
VG_VM10 is VM10's volume group, the
          chances of error is reduced somewhat
Just one more level of protection...

Instead of re-creating the initrd I unpacked the cloned initrd modified the
"init" script and then re-packed it.  Other changes were needed in the root
filesystem & grub/menu.lst to match this change as outlined below.

This clones a VM image dd'd onto an iSCSI volume, changing the LVM group
from VG_VM09 to VG_VM10:

# create the clone
dd if=/dev/iscsi/6002219000bde59b0000000049cafede/part9
of=/dev/iscsi/6002219000bde59b0000000049cafede/part10 bs=1024K

# mount the VM's /boot to get at grub/menu.lst and initrd
losetup -o $((512*63)) /dev/loop1
/dev/iscsi/6002219000bde59b0000000049cafede/part10
        - the (512 * 63) are the (units * start) from fdisk -lu
mount -t ext3 /dev/loop1 /mnt

# unpack the initrd, modify it, pack it again
cd /mnt
mkdir tmp
cd tmp
cat ../initrd-2.6.18-128.el5xen.img | gunzip | cpio --extract
vi "init" 
        - search for VG_VM09 and change it to VG_VM10
mv ../initrd-2.6.18-128.el5xen.img ../initrd-2.6.18-128.el5xen.img.orig
find . | cpio --quiet -c -o | gzip > ../initrd-2.6.18-128.el5xen.img
cd ..
rm -rf tmp

# Update menu.lst to point to the new root path 
cd grub
edit menu.lst
        - change root path using new VG_VM10 path

# cleanup access to /boot
cd
umount /mnt
losetup -d /dev/loop1

# Create access to the root filesystem of the newly cloned VM
kpartx -av /dev/iscsi/6002219000bde59b0000000049cafede/part10

# Change the volume group name
vgrename VG_VM09 VG_VM10
vgchange -ay VG_VM10
mount /dev/VG_VM10/root /mnt

cd /mnt
vi etc/fstab
        - change path to swap & root to be VG_VM10
vi etc/blkid/blkid.tab
        - change paths to use VG_VM10
        - not sure if this is really necessary to do as it is created by
          blkid but I am not sure when
vi etc/sysconfig/network
        - change nodename
vi etc/sysconfig/network-scripts/ifcfg-eth0
        - update MAC
        - update IP (if needed)
vi etc/hosts
        - update nodename

rm etc/lvm/archive/*
        - just for cleanlyness

# Clean up access to VM's root
cd
umount /mnt
vgchange -an VG_VM10
kpartx -dv /dev/iscsi/6002219000bde59b0000000049cafede/part10

cp /etc/xen/vm09 /etc/xen/vm10
        - edit vm10 config to change the name, uuid, vif/mac and disk

xm create vm10
-- 
View this message in context: 
http://www.nabble.com/How-do-I-create-an-initrd-for-a-vm-that-is-using-lvm---tp23986257p24007251.html
Sent from the Xen - User mailing list archive at Nabble.com.


_______________________________________________
Xen-users mailing list
Xen-users@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-users

<Prev in Thread] Current Thread [Next in Thread>