3

When I create a 400MB file called /tmp/foo, then call losetup -f /tmp/foo, this creates a loop device /dev/loop15. If I then partition the loopdevice and format it to contain ext4,ntfs, and fat32 filesystems respectively, then run lsblk, I get the following:

loop15        7:15   0 390,6M  0 loop 
├─loop15p1  259:8    0   100M  0 part 
├─loop15p2  259:9    0   200M  0 part 
└─loop15p3  259:10   0    83M  0 part 

under /etc/dev there is then loop15, loop15p1, loop15p2, and loop15p3.

but after calling losetup -d /dev/loop15 to unbind the loop device, then recall losetup -f /tmp/foo to rebind it, then when running gparted or KDE disk manager, both show me that there are 3 partitions on the device, but all of them unformatted. If I run lsblk -f or ls /dev/loop* I see /dev/loop15, but the partitions are gone.

Is there a way to make the filesystems persistent across un-/binds? How do I restore the blockdevice nodes to the partitions (loop15p1,loop15p2,loop15p3...)?

1 Answer 1

4

You need to run losetup with -P/--partscan to tell kernel to scan for partitions on the device, it's not enabled by default for loop devices so the partition device nodes are not created without this option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .