Debian – XEN: Error: Device 769 (vbd) could not be connected. Failed to find an unused loop device

debianloopbackxen

I'm trying to start a new DomU machine (Lenny) on an Ubuntu Dom0.

However, I'm getting the following error when executing the xm-create command:

# xm create vm3.rootspirit.com.cfg
Using config file "./vm3.rootspirit.com.cfg".
Error: Device 769 (vbd) could not be connected. Failed to find an unused loop device

After some Googling I learned it was due to limit of loopback devices in /dev

# ls -ls /dev/ | grep loop
0 brw-rw---- 1 root   disk      7,   0 2009-07-17 04:01 loop0
0 brw-rw---- 1 root   disk      7,   1 2009-07-22 12:49 loop1
0 brw-rw---- 1 root   disk      7,   2 2009-07-22 12:49 loop2
0 brw-rw---- 1 root   disk      7,   3 2009-07-22 12:49 loop3
0 brw-rw---- 1 root   disk      7,   4 2009-07-22 12:49 loop4
0 brw-rw---- 1 root   disk      7,   5 2009-07-22 12:49 loop5
0 brw-rw---- 1 root   disk      7,   6 2009-07-22 12:49 loop6
0 brw-rw---- 1 root   disk      7,   7 2009-07-22 12:49 loop7

I currently have 3 DomUs running:

# xm list
Name                                        ID   Mem VCPUs      State   Time(s)
Domain-0                                     0  5352     2     r----- 945295.5
vm0.rootspirit.com                         130  1024     1     -b---- 653791.0
vm1.rootspirit.com                         106  1024     2     -b----  48359.3
vm2.rootspirit.com                         128   512     2     -b----  18150.9

I have added the max_loop option to the loop module

# cat /etc/modules | grep loop
loop max_loop=64 

But I am unable to reload the module

# modprobe -r loop
FATAL: Module loop is in use.

I am unable destroy all the DomUs and/or to reboot the Dom0 at this time.
Any other way to reload/force the use of extra loop devices?

Thanks,
Yeri

Best Answer

Yeri (and for future reference),

I would suggest changing each of your DomU's disks to be 'tap:aio' instead of 'file' resources. Both of the options are essentially the same, with the exception that tap:aio won't use up a loopback device on the Dom0.

For example, in the Xen configuration files for your DomU's, use:

disk = [ 'tap:aio:/domu/guest1.img,sda1,w' ]

instead of:

disk = [ 'file:/domu/guest1.img,sda1,w' ]

Resources:

http://www.centos.org/docs/5/html/5.2/Virtualization/sect-Virtualization-Troubleshooting-Loop_device_errors.html

http://doc.opensuse.org/products/draft/SLES/SLES-xen_draft/cha.xen.vbd.html