During adding and removing kernels on my multi-boot PC, I ran into “Device or resource busy” error. The problem was in used device-mapper as leftover that was shown on dmsetup list. After removing device definitions (clearing list), I was able to recreate boot grub2 options.
Before anything else, please be careful and read manuals. Resetting device-mapper driver to remove osprober-linux-sda15 was successful in my case without any data loss so use with care!
OK, my PC with UEFI has two Fedora boot options (Fedora 27 and Fedora 28) and Windows 10. After adding kernel in Fedora 27, rebooting to Fedora 28 and generating new boot options with grub2-mkconfig, the following error was displayed for sda15.
# grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg Generating grub configuration file ... Found linux image: /boot/vmlinuz-4.16.3-301.fc28.x86_64 Found initrd image: /boot/initramfs-4.16.3-301.fc28.x86_64.img Found linux image: /boot/vmlinuz-0-rescue-a7b31c458cf84e03b15ccfb4c6aa7c32 Found initrd image: /boot/initramfs-0-rescue-a7b31c458cf84e03b15ccfb4c6aa7c32.img device-mapper: remove ioctl on osprober-linux-sda15 failed: Device or resource busy Command failed Found Windows Boot Manager on /dev/sda2@/EFI/Microsoft/Boot/bootmgfw.efi done
I was convinced that /dev/sda15 was not used as it’s shown with df command:
# df -hT Filesystem Type Size Used Avail Use% Mounted on devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs tmpfs 3.9G 1.9M 3.9G 1% /run tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup /dev/sda8 ext4 28G 7.6G 19G 30% / /dev/sda6 ext4 1.9G 126M 1.6G 8% /boot /dev/sda10 ext4 3.7G 67M 3.4G 2% /tmp /dev/sda7 ext4 148G 28G 113G 20% /home /dev/sda9 ext4 28G 2.0G 25G 8% /var /dev/sda5 vfat 488M 18M 470M 4% /boot/efi tmpfs tmpfs 795M 16K 795M 1% /run/user/42 tmpfs tmpfs 795M 24K 795M 1% /run/user/1000
The problem was with osprober-linux-sda15 device as the reason why /dev/sda15 was marked busy. lsblk command displays it nicely:
# lsblk -p NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT /dev/sda 8:0 0 465.8G 0 disk ├─/dev/sda1 8:1 0 499M 0 part ├─/dev/sda2 8:2 0 100M 0 part ├─/dev/sda3 8:3 0 16M 0 part ├─/dev/sda4 8:4 0 214.2G 0 part ├─/dev/sda5 8:5 0 488M 0 part /boot/efi ├─/dev/sda6 8:6 0 1.9G 0 part /boot ├─/dev/sda7 8:7 0 150.9G 0 part /home ├─/dev/sda8 8:8 0 28G 0 part / ├─/dev/sda9 8:9 0 28G 0 part /var ├─/dev/sda10 8:10 0 3.7G 0 part /tmp ├─/dev/sda11 8:11 0 3.7G 0 part [SWAP] ├─/dev/sda12 8:12 0 476M 0 part ├─/dev/sda13 8:13 0 1.9G 0 part ├─/dev/sda14 8:14 0 1.9G 0 part └─/dev/sda15 8:15 0 30.2G 0 part └─/dev/mapper/osprober-linux-sda15 253:0 0 30.2G 1 dm
Now we are close to the solution. dmsetup manages logical devices that use the device-mapper driver and with “ls” option it will list all device names in use.
# dmsetup ls osprober-linux-sda15 (253:0)
Finally, removing osprober-linux-sda15 device was solution for my problem. I assume that it was somehow leftover after trying to downgrade Fedora 27 kernel version and recreating new boot options with grub2 on Fedora 28. With removing osprober device from dmsetup list, I was able to mount /dev/sda15 and grub2-mkconfing was not showing any error.
# dmsetup remove_all
Hope this tips will help you to resolve similar problems.
2 thoughts on “Device or resource busy”
Not sure if this is a life saving, but definitely a sleep saving advice! Thank you!
For me it was life saving :-)