Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
    
busybox losetup without additional parameters lists them for me. –  frostschutz Nov 15 '13 at 16:55
add comment

1 Answer 1

up vote 3 down vote accepted

From http://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
/volumes/jfs.dsk

...


Substitite busybox losetup for losetup above.

share|improve this answer
1  
and see grep -oE 'loop[0-9]+$' /proc/partitions for the list of loop devices in use (that's what losetup -a does). –  Stéphane Chazelas 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 –  Tobias Kienzler Nov 18 '13 at 7:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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