busybox (at least version 1.7, which I'm bound to use) to not provide the losetup -a switch to obtain a list of currently used loop devices plus the associated filename. Is there any way to obtain such a list with busybox?

  • busybox losetup without additional parameters lists them for me. Nov 15 '13 at 16:55

From https://stackoverflow.com/questions/10832350/howto-find-the-file-for-a-loopmounted-device:

From losetup(8) man page

If only the loopdev argument is given, the status of the corresponding loop device is shown.

So you only need to use

$ losetup /dev/loop1
/dev/loop1: [0802]:4751362 (/volumes/jfs.dsk)

If you have a recent kernel (2.6.37 or above), you can also get the target file in /sys/block/loopX/loop/backing_file.

$ cat /sys/block/loop1/loop/backing_file


Substitite busybox losetup for losetup above.

  • 1
    and see grep -oE 'loop[0-9]+$' /proc/partitions for the list of loop devices in use (that's what losetup -a does). Nov 15 '13 at 17:28
  • I feel kind of stupid for not having tried this... Also thanks @StephaneChazelas, I didn't know /proc/partitions Nov 18 '13 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.