Transitioning from LVM storage to file-based storage in Xen
I have tended to setup Xen systems with LVM storage due to the performance increases I’ve observed compared to file-based storage. Recently I’ve decided to largely transition to file-based storage primarily for the increase in manageability that file-based virtual machine images provides. Files are much easier to manipulate for backups, migrating to other systems, and similar tasks. While I will still use LVM in certain situations I think the file-based images is a better choice until one runs into performance bottlenecks. Even at that point there may be other alternatives available.
In an effort to create a Xen setup that is relatively consistent between para-virtualized systems and hardware-virtualized systems I’ve decided that the image files should be disk images rather than partition images. While there are techniques for mounting disk images I think I prefer to use the Xen system with its block commands: xm block-list, xm block-attach, xm block-detach.
Creating a file-based disk image might go something like this on the Dom0:
dd if=/dev/zero of=/mnt/xen-disk-images/system.img bs=1K count=10M- This creates a 10GiB file.
xm block-attach 0 tap:aio:/mnt/xen-disk-images/system.img xvda w- This attaches the file as disk xvda in a writable state to Dom0.
cfdisk /dev/xvda- You can use your partitioning tool of choice to partition the drive. For this example I’ll assume a single partition is created: xvda1.
mkfs.ext3 /dev/xvda1- This partition can then be formatted with whatever file-system is appropriate.
mount /dev/xvda1 /mnt/system-xvda1- This partition can then be mounted to install or copy files.
umount /dev/xvda1- The system should be unmounted when done.
xm block-list 0- This command must be run to get the device id of the block device.
xm block-detach 0 DevID- DevID must be replaced with the device id from the block-list command.




Recent comments
20 hours 7 min ago
20 hours 8 min ago
1 week 5 days ago
11 weeks 5 days ago
12 weeks 3 days ago
17 weeks 5 days ago
17 weeks 5 days ago
17 weeks 5 days ago
18 weeks 3 days ago
18 weeks 3 days ago