I''m a complete newbie at Xen, just getting started. I was happy to see that Ubuntu 11.10 includes Xen again, http://zulcss.wordpress.com/2011/09/04/xen-4-1-1-on-ubuntu/ So I installed ubuntu 11.10''s precompiled Xen, and started playing around with it. I''m not even trying to start another VM at the moment, just playing around with mounting block devices, and had trouble with block-attach: $ dd if=/dev/zero of=foo.img bs=1024k seek=64 count=0 0+0 records in 0+0 records out 0 bytes (0 B) copied, 1.6493e-05 s, 0.0 kB/s $ sudo xm block-attach 0 file://home/dank/lvmstuff/foo.img /dev/xvda1 w 0 $ sudo xm block-list 0 Vdev BE handle state evt-ch ring-ref BE-path 51713 0 0 1 -1 -1 /local/domain/0/backend/vbd/0/51713 $ sudo mkfs.ntfs /dev/xvda1 Failed to access ''/dev/xvda1'': No such file or directory The device doesn''t exist; did you specify it correctly? Was I supposed to create /dev/xvda1 myself? I thought Xen did that. Thanks, Dan p.s. The little example script I''m trying to get working is http://kegel.com/linux/xen/demo-xen.sh
On Thu, Nov 17, 2011 at 10:24 PM, Dan Kegel <dank@kegel.com> wrote:> $ sudo xm block-attach 0 file://home/dank/lvmstuff/foo.img /dev/xvda1 w 0 > $ sudo xm block-list 0 > Vdev BE handle state evt-ch ring-ref BE-path > 51713 0 0 1 -1 -1 /local/domain/0/backend/vbd/0/51713 > $ sudo mkfs.ntfs /dev/xvda1 > Failed to access ''/dev/xvda1'': No such file or directory > The device doesn''t exist; did you specify it correctly? > > Was I supposed to create /dev/xvda1 myself? I thought Xen > did that.The workaround/fix is sudo modprobe xen-blkfront Is that traditionally not loaded on dom0? - Dan
For completeness, here''s a script that shows the smallest possible example of using xen and lvm together to create and format a blank virtual disk, and then to tear it all down. It works with ubuntu-11.10. There''s nothing at all special about it, it''s just an first example for newbies trying to work out how volume management works, expressed purely as a shell script that uses xm in dom0. It assumes you''re using a 32 bit kernel. (This is http://kegel.com/linux/xen/demo-lvm-xen.sh.txt ) #!/bin/sh # Script to demonstrate creating and mounting a disk image using LVM and Xen set -x set -e lvm version || sudo apt-get install lvm2 dmsetup mdadm # After installing Xen, reboot and choose the Xen kernel. # Note that you won''t be able to use nvidia graphics cards under Xen, # so you''ll probably need to ssh into the box after booting linux in xen. xm help > /dev/null || sudo apt-get install xen-hypervisor-4.1-i386 xenstore-utils xen-tools xen-utils-4.1 xen-utils-common xenwatch test -b /dev/xvda1 || sudo modprobe xen-blkfront # Create a demo physical volume # Make a sparse image file of size 64MB dd if=/dev/zero of=foo.img bs=1024k seek=64 count=0 # Make a loopback device for it sudo losetup /dev/loop0 foo.img # Register it as a physical volume sudo pvcreate -f -M2 /dev/loop0 # List the known physical volumes sudo pvdisplay # Create a demo volume group and put that physical volume in it sudo vgcreate demo_vg /dev/loop0 # List the known volume groups sudo vgdisplay # Create a logical volume in that volume group sudo lvcreate --name foo_lv --size 50MB demo_vg # List the known logical volumes sudo lvdisplay # Attach it to domain 0 sudo xm block-attach 0 phy:/dev/demo_vg/foo_lv /dev/xvda1 w 0 # Show the newly attached block device sudo xm block-list 0 # Create a filesytem on it sudo mkfs.ntfs /dev/xvda1 # Mount it somewhere sudo mkdir /media/foo sudo mount /dev/xvda1 /media/foo # Show that it''s real df /media/foo # Unmount it sudo umount /media/foo sudo rmdir /media/foo # Detach it sudo xm block-detach 0 /dev/xvda1 -f # Remove the logical volume # BUG?: in Ubuntu 11.10, lvremove complains "semop failed" # See https://bugs.launchpad.net/ubuntu/+source/lvm2/+bug/846061 sudo lvremove -f /dev/demo_vg/foo_lv # Remove the volume group sudo vgremove demo_vg # Remove the physical volume sudo pvremove /dev/loop0 # BUG?: have to sleep here, else losetup -d fails sometimes? sleep 1 # Remove the loopback device sudo losetup -d /dev/loop0 # Remove the image rm foo.img
Possibly Parallel Threads
- Installing domU from ISO image file
- xen cannot find root filesystem
- Disk add fails while domain creation, which uses disk backend- "storage driver domain" with xen-4.3.0 , with errors libxl.c:2125
- Disk add fails while domain creation, which uses disk backend- "storage driver domain" with xen-4.3.0 , with errors libxl.c:2125
- Migration stalls with 2.6.26.5 kernel