Softaculous


Topic : ioctl: LOOP_SET_FD: Device or resource busy


Posted By: aldemaroc on May 13, 2021, 3:21 pm
Hello!

We set up a brand new server using Ubuntu 20.04 LTS to a client, and when he is reinstalling a new KVM VPS there is an error:

Code
[Command] cd /home/kvm; /sbin/kpartx -l v1001-dmbw3tvsq6qhqkjx-bic3zzwwwyjxa823.raw
[Retval] 1
[Output]: Hide [Error]: Hide
Array
(
    [0] => ioctl: LOOP_SET_FD: Device or resource busy
    [1] => can't set up loop
)
Array
(
)


We checked and all loop devices are free:

Code
root@ubuntu-new:/home/kvm# losetup -f
/dev/loop0


Code
root@ubuntu-new:/home/kvm# lsblk
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  1.8T  0 disk
├─sda1  8:1    0    1M  0 part
├─sda2  8:2    0    1G  0 part /boot
├─sda3  8:3    0  50G  0 part /
└─sda4  8:4    0  1.8T  0 part /home


Have anyone experieced anything close to that and solved?

Posted By: aldemaroc on May 13, 2021, 6:56 pm | Post: 1
I think we found the issue.

We reinstalled the server and could reproduce it one more time.

Looks like virtualizor is sometimes not remove all loop devices correctly.

We found that somehow /dev/mapper/loop0p1 was still present where it should not be:

Code

root@ubuntu-new:~# lsblk
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda      8:0    0  1.8T  0 disk
├─sda1  8:1    0    1M  0 part
├─sda2  8:2    0    1G  0 part /boot
├─sda3  8:3    0  50G  0 part /
└─sda4  8:4    0  1.8T  0 part /home

root@ubuntu-new:~# ls /dev/mapper/
control  loop0p1


Removing /dev/mapper/loop0p1 using "dmsetup remove /dev/mapper/loop0p1" allowed us to reinstall the VPSs as we pleased, but we are afraid it can happen again in the future as looks like this is caused by some kind of bug.

Posted By: jevingala on May 14, 2021, 6:06 am | Post: 2
Hi,


If it happens again , then you can open a ticket so that we can check that vps logs and try to replicate the issue :

https://softaculous.deskuss.com/open.php?topicId=2

-----------------------
Regards,
Virtualizor Team.
http://virtualizor.com/

Posted By: aldemaroc on May 22, 2021, 12:07 pm | Post: 3
I think I found the issue

When building the VPS if something goes wrong when mounting the loop device virtualizor will never free up the loop again:

Code
[Command] /bin/mount /dev/mapper/loop0p1 /home/v1002/0 2>&1
[Retval] 32
[Output]: Hide
Array
(
    [0] => mount: /home/v1002/0: can't read superblock on /dev/mapper/loop0p1.
)


After that Virtualizor will just exit, and leave the loop there, stuck.

Next time you try to reinstall the VPS:

Code
[Command] cd /vz/kvm; /sbin/kpartx -l v102-d1pwqtx0zxwezgpv-3o93zbcvlvcndt3v.raw
[Retval] 1
[Output]: Show [Error]: Hide
Array
(
    [0] => ioctl: LOOP_SET_FD: Device or resource busy
    [1] => can't set up loop
)


As there is no hook for when the server is installed/reinstalled we can't add our custom routine that will clean up stuck loops, and had to make a cron script that will look for stuck loops and delete them.

Posted By: jevingala on May 22, 2021, 12:24 pm | Post: 4
Hi,

Was v1002 a fresh vps created using our OS template previously ?

Or was it a vps created using ISO ?
Or there was some other vps created using ISO with LVM based storage in it ?

We are executing kpartx -d to remove the loop device.
But it fails then other vps may get affected.

-----------------------
Regards,
Virtualizor Team.
http://virtualizor.com/

Posted By: aldemaroc on May 22, 2021, 5:36 pm | Post: 5
Quote From : jevingala May 22, 2021, 12:24 pm
Hi,

Was v1002 a fresh vps created using our OS template previously ?

Or was it a vps created using ISO ?
Or there was some other vps created using ISO with LVM based storage in it ?

We are executing kpartx -d to remove the loop device.
But it fails then other vps may get affected.


Hello! It is your ubuntu 18 template. We are using Ubuntu 20 as the host OS.

We will reinstall this node and open a support ticket so you guys can check further.

Powered By AEF 1.0.8 © 2007-2008 Electron Inc.