Enlarge a xen Image (.img) File

1 Comment

This HOWTO will allow you to increase the size of .img files created with dd. Note that this process changes the on-disk image in place and hence it is highly recommended that you back up the image first. Also, make sure the image is not already mounted or backing a live domain or virtual machine! This process is *not* recommended for decreasing the overall size of an image and would likely cause the image itself to be corrupted if attempted.
Replace image_file and size_in_MB appropriately
# dd if=/dev/zero of=image_file bs=1M conv=notrunc count=1 seek=size_in_MB
# losetup /dev/loop0 image_file
# e2fsck -f /dev/loop0
# resize2fs /dev/loop0
# e2fsck -f /dev/loop0
# losetup -d /dev/loop0

Xen on centos 5.5

No Comments

Xen Guest OS boot error looks like:

Mounting root filesystem.
mount: could not find filesystem '/dev/root'
Setting up other filesystems.
Setting up new root fs
setuproot: moving /dev failed: No such file or directory
no fstab.sys, mounting internal defaults
setuproot: error mounting /proc: No such file or directory
setuproot: error mounting /sys: No such file or directory
Switching to new root and running init.
unmounting old /dev
unmounting old /proc
unmounting old /sys
switchroot: mount failed: No such file or directory
Booting has failed.

The most common cause of this problem is a conflict of SCSI modules. In order to resolve this it is necessary to create a new initrd initialization RAM Disk without SCSI modules, and then use this to boot the guest Linux operating system. This can be achieved using the following command:

mkinitrd --omit-scsi-modules --with=xennet --with=xenblk --preload=xenblk initrd-$(uname -r)-no-scsi.img $(uname -r)
move the file to /boot

Once the new initrd image file has been generated simply refer to it in the “ramdisk” line of the Xen configuration file, for example:

kernel = "/boot/vmlinuz-2.6.18-194.3.1.el5xen"
ramdisk = "/boot/initrd-2.6.18-194.3.1.el5xen-no-scsi.img"
memory = 1024
name = "centos5"
vif = [ 'mac=00:16:36:4c:87:c3,bridge=virbr0,script=vif-bridge' ]
disk = ['tap:aio:/xen/centos.img,xvda1,w', 'tap:aio:/xen/centos.swap,xvda2,w']
root = "/dev/xvda1 ro"