LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (http://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   Getting the file associated with a loop device (http://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/getting-the-file-associated-with-a-loop-device-914635/)

telexl 11-21-2011 02:26 AM

Getting the file associated with a loop device
 
I use a lot of loop filesystems (/dev/loopN) with embedded devices, and something that's always bothered me is this: once a loop file has been mounted with a loop device, how do I get the name of the original file?

I tried this:
Code:

losetup -a
... but on my system, it outputs a truncated path:
Code:

/dev/loop0: [0802]:19358161 (/home/lex/Projects/Backup/media/card/*)
I don't know what the '*' is doing there.

I found the answer when looking in /sys:
Code:

cat /sys/devices/virtual/block/loop0/loop/backing_file
/home/lex/Projects/Backup/media/card/loop-images/home.ext2

Sorted!


All times are GMT -5. The time now is 03:14 AM.