About loop devices used on core


I want to make a virtual disk via usb-otg, When i mount to loop device ,loop1-8 are busy and /dev/loop0 is mounted on /type squashfs. So I use /dev/loop9 and it works as a u-disk, but i’m not sure if loop9 can be used. Any suggestions about it? Thanks!


snap packages are gpg signed squashfs files that get loop mounted automatically to get access to their content (the the case of ubuntu core this means your rootfs (the core snap) and even your kernel are snap packages and use up loop devices)…

the more snap packages you have installed, the more loop devices you will have in use so picking loop9 in any hardcoded way will not work (as soon as you have more snaps installed loop9 will be taken)

i’d recommend taking a look at the udisks2 snap, it offers a udisks2 interface you can use from your snap that gives you access to all the udisk tools and dbus to mount something.

for a loop device i’d just use something like:

udisksctl loop-setup -r -f my-otg-served-image.img

and let udisks2 do all the loop device work for me …