About loop devices used on core

Hello
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!

1 Like

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 …

1 Like

Hi @ogra,
Just curious to know, when ever I installed any snaps either from snap store or from locally it created a new loop device on my system.
Is it something like snaps gets memory in Ram after installation ?

loop devices surely occupy some bytes in ram for i.e. having a one-line entry in /etc/mtab (which is a file living in ram usually).

beyond this snaps will not use any memory until you actually execute the apps shipped with them (indeed if you install snaps with daemons/services in them their services usually start at install time).

1 Like