osdir.com
mailing list archive F.A.Q. -since 2001!



Subject: Xen + LVM + OS image - msg#00257

List: linux.redhat.fedora.xen

Mail Archive Navigation:
by Date: Prev Next Date Index by Thread: Prev Next Thread Index

Hello all,

I have a setup that I have been testing to create a FC6 guest image on a
lvm logical volume (lv) and then use that to deploy new a new guest. I
wanted to get feedback about anything that I might have overlooked.

In a nutshell, each xen guest install has it's own lv for a root partition
and swap partition provided by the host. The guest installs are not using
lvm, they use the whole 'disk' as they see it, which is of course managed
by the host lvm.

To deploy a new FC6 guest, lvcreate new swap and data partitions and dd
the image lv to the new guest partition.

Then a copy of the /etc/xen/image is made, the mac address, uuid and name
are updated. Furthermore, in the new guest os the mac address and
networking settings must be updated.

An external USB2.0 drive that is managed by lvm is used for backups. Use
pvcreate and vgcreate to create a backup volume group (first time only)
and create logical volumes, shutdown the guests and dd the guest lv to
the backup volume group. Then use vgchange and vgexport to remove the
backup volume (pvscan and vgimport are used to re-attach the volume in the
future).

The following is a edited version of my more detailed notes.

I would really like to hear any suggestions or any major problems with
this,

Thanks!
Gordon Turner.



1. Host setup
-------------
- Install FC6 and xen on the host, using LVM and leaving space for the
guest logical volumes.
- Create logical volumes for xen hosts and create swap space:
lvcreate -L 1G -n ImageSwap00 VolGroup00
lvcreate -L 3G -n ImageData00 VolGroup00


2. Create image domain
----------------------
- Run installer:
[root@xen ~]# /usr/sbin/xenguest-install
What is the name of your virtual machine? image
How much RAM should be allocated (in megabytes)? 256
What would you like to use as the disk (path)? /dev/VolGroup00/ImageData00
Would you like to enable graphics support? (yes or no) no
What is the install location? http://192.168.1.199/fc6/

- During the guest install, remove default lvm partitioning and create
one filesystem that completely fills the available 'drive'. Ignore the
swap warning, it will be added later.

- After the first boot of the guest image, update fstab in the image to
include the swap space:
vi /etc/fstab
/dev/xvdb swap swap defaults 0 0

- Then halt the guest os:
halt

- In the host xen system, edit the /etc/xen/image file to shrink the
ram(optional) and add the swap:
vi /etc/xen/image
...
memory = "64"
disk = [ 'phy:/dev/VolGroup00/ImageData00,xvda,w', 'phy:/dev/VolGroup00/ImageSwap00,xvdb,w' ]

- Create the swap space:
mkswap /dev/VolGroup00/ImageSwap00

- Boot and test guest image, halt when done.


3. Create a new guest from image
--------------------------------
- Create lvm partitions:
lvcreate -L 1G -n ExampleSwap00 VolGroup00
lvcreate -L 3G -n ExampleData00 VolGroup00

- Map the ImageData00 partition:
kpartx -av /dev/VolGroup00/ImageData00

- Use dd to copy to the new partition:
dd if=/dev/mapper/ImageData00p1 of=/dev/VolGroup00/ExampleData00

- Create swap space:
mkswap /dev/VolGroup00/ExampleSwap00

- Unmap the ImageData00 partition:
kpartx -dv /dev/VolGroup00/ImageData00

- Mount the new data partition:
mount /dev/VolGroup00/ExampleData00 /mnt/Data

- In new host, edit the following files and change 'image' to new name:
vi /mnt/Data/etc/hosts
vi /mnt/Data/etc/sysconfig/network

- Also on new host, set the correct ip address and MAC address:
vi /mnt/Data/etc/sysconfig/network-scripts/ifcfg-eth0

- Unmount the new data partition:
umount /mnt/Data

- Copy the 'image' xen configuration file and edit it:
cp /etc/xen/image /etc/xen/example
vi /etc/xen/example


4. Create new Backup Volume Group
---------------------------------
- One time deal:
pvcreate /dev/sda
vgcreate VolBackup00 /dev/sda
vgchange -a n VolBackup00
vgexport VolBackup00


5. Backup Logical Volume
------------------------
- Plugin USB2.0 drive, wait for initialization(check dmesg) and import the
Volume Group:
pvscan
vgimport VolBackup00

- To create and backup to new logical volume:
lvcreate -L3G -n YYYYMMDD_NAME VolBackup00
dd if=/dev/VolGroup00/ImageData00 of=/dev/VolBackup00/YYYYMMDD_NAME

- To export the Volume Group and disconnect the drive:
vgchange -a n VolBackup00
vgexport VolBackup00


6. Notes and questions
----------------------
- My understanding is that using dd to copy lv around is safe as long as
the physical extents are the same, ie lvcreate should create volumes of
exactly the same size.

- Not sure the exact process of increasing a guest lv from the host, but
it should be possible.

- When a new copy of an image is copied, the ssh keys should be recreated
so that they are unique. Haven't looked at how to do that yet.



Thread at a glance:

Previous Message by Date:

Running Windows Vista RC1 in Xen on FC6

Hello All,I am trying to get Windows Vista RC1 to run in Xen.  I had it working fine when I first tried it.  I installed an update to Xen when it came out an now my virt-manager says:Unable to open a connection to the Xen hypervisor/daemon. Verify that: - A Xen host kernel was booted - The Xen service has been startedOf course I verified those and I have Intel VT turned on in the BIOS.What is funny is that I can see Dom0 running in virt-manager behind the error.  As soon as I close the error, virt-manager closes. I can provide any additional info as needed.  Any ideas?Following similar threads, I ran 'virsh list' and it shows Dom0 running fine.  'xm top' shows it running fine as well.Looking at /root/.virt-manager/virt- manager.log, I see this error:Unable to open connection to hypervisor URI 'xen': socket.gaierror (-3, 'Temporary failure in name resolution')I did rename my system after creating it...  What's the fix? Thanks in advance!Ian-- Ian Patton

Next Message by Date:

Windows Vista RC1 on Xen 3.0.3 FC6

Hello,I now have Windows Vista RC1 attempting to boot using the following hvm file:# Automatically generated xen config filename = "WindowsVistaRC1"builder = "hvm"memory = "784" disk = [ 'phy:/dev/hdc1,hda,w', 'file:/tmp/WINDOWS_VISTA.iso,hdc:cdrom,r' ]vif = [ 'type=ioemu, mac=00:16:3e:0f:a7:08, bridge=xenbr0', ]uuid = "7232d84d-f579-a4f1-d190-b31ebb66faf9"device_model = "/usr/lib/xen/bin/qemu-dm" kernel = "/usr/lib/xen/boot/hvmloader"vnc=1vncunused=1#sdl=1apic=1acpi=1pae=1boot="d"vcpus=1serial = "pty" # enable serial consoleon_reboot   = 'restart' on_crash    = 'destroy'I can see it boot from the DVD image and start to load the installer.  It gets to the point where the black screen progress bar is at 100% and then I see the DomU processor drop to 0% and it does nothing. xend.log shows nothing usefulthe qemu-dm.*.log shows:domid: 28qemu: the number of cpus is 1shared page at pfn:30fff, mfn: 3a0afbuffered io page at pfn:30ffd, mfn: 3a0b1char device redirected to /dev/pts/1 False I/O request ... in-service already: 0, pvalid: 0, port: 0, data: 0, count: 0, size: 0and the xend-debug.log shows this:Nothing to flush.Nothing to flush. File "/usr/lib/python2.4/site-packages/xen/xend/server/SrvDomainDir.py", line 77, in op_create     dominfo = self.xd.domain_create(config)  File "/usr/lib/python2.4/site-packages/xen/xend/XendDomain.py", line 228, in domain_create    dominfo = XendDomainInfo.create(config)  File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 195, in create     vm.initDomain()  File "/usr/lib/python2.4/site-packages/xen/xend/XendDomainInfo.py", line 1335, in initDomain    balloon.free(memory + shadow)  File "/usr/lib/python2.4/site-packages/xen/xend/balloon.py", line 166, in free     raise VmError(VmError: I need 1070492 KiB, but dom0_min_mem is 262144 and shrinking to 262144 KiB would leave only 773804 KiB free.I have tried chaning the APIC, ACPI and PAE settings to every possible combo and it only made it worse. I did create a partition for this install...  Actually I gave it it's own whole disk drive.  The partition is /dev/hdc1 but it is not formatted.  I assumed Windows would format it as needed.  Does anyone know if it should be formatted as ext3 for it to work? -- Ian Patton

Previous Message by Thread:

Running Windows Vista RC1 in Xen on FC6

Hello All,I am trying to get Windows Vista RC1 to run in Xen.  I had it working fine when I first tried it.  I installed an update to Xen when it came out an now my virt-manager says:Unable to open a connection to the Xen hypervisor/daemon. Verify that: - A Xen host kernel was booted - The Xen service has been startedOf course I verified those and I have Intel VT turned on in the BIOS.What is funny is that I can see Dom0 running in virt-manager behind the error.  As soon as I close the error, virt-manager closes. I can provide any additional info as needed.  Any ideas?Following similar threads, I ran 'virsh list' and it shows Dom0 running fine.  'xm top' shows it running fine as well.Looking at /root/.virt-manager/virt- manager.log, I see this error:Unable to open connection to hypervisor URI 'xen': socket.gaierror (-3, 'Temporary failure in name resolution')I did rename my system after creating it...  What's the fix? Thanks in advance!Ian-- Ian Patton

Next Message by Thread:

Re: Xen + LVM + OS image

On Wed, 22 Nov 2006 17:05:32 -0500 (EST) turner@xxxxxxx wrote: TN> - When a new copy of an image is copied, the ssh keys should be recreated TN> so that they are unique. Haven't looked at how to do that yet. Just delete them, and sshd will recreate them the next time it starts..
blog comments powered by Disqus

Home | News | Sitemap | FAQ | advertise | OSDir is an Inevitable website. GBiz is too!