Gparted and loop devices

Questions about applications and software
Forum rules
Before you post please read how to get help
Post Reply
sanmig
Level 4
Level 4
Posts: 237
Joined: Tue Dec 04, 2018 8:27 am

Gparted and loop devices

Post by sanmig »

AndyMH wrote:
Fri Sep 25, 2020 7:18 pm
It can handle loop devices, wouldn't expect it to work with nbd.
Although I’ve read all the (good) help, where is it hidden?
I had to use Disks to clean up behind Gparted’s glitch.
AFAIK Gparted can only handle physical devices, not pseudo-devices?
(n00b here, reads a lot, understands little :( )
ajgringo619
Level 8
Level 8
Posts: 2225
Joined: Thu Mar 01, 2018 8:36 pm
Location: San Diego, California, USA

Re: Gparted and loop devices

Post by ajgringo619 »

What are you trying to accomplish?
Mint 20.1 XFCE [kernel 5.4.0-64-generic]
Ryzen 7 2700X 3.7 GHz w/16GB RAM
GTX 1070 w/8GB RAM [460.32.03]
Image
User avatar
AndyMH
Level 15
Level 15
Posts: 5509
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: Gparted and loop devices

Post by AndyMH »

The quickest and easiest way to create a loop device is use disks on a new unformatted drive (or to test on an existing drive wipe the partition table, dd if=/dev/zero of=/dev/sdX bs=1M count=1). Most newbies don't realise that to put a partition table on the drive you have to use the hamburger menu. Just one reason I don't like disks.

Gparted makes it more difficult, you have to do it intentionally. From the device menu > create partition table and select loop. You will be able to create a single partition. If you right click on the partition and select information you will see that the partition starts at zero = no partition table.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
sanmig
Level 4
Level 4
Posts: 237
Joined: Tue Dec 04, 2018 8:27 am

Re: Gparted and loop devices

Post by sanmig »

ajgringo619 wrote:
Sat Sep 26, 2020 7:57 pm
What are you trying to accomplish?
Long story …
I was interested if Gparted’s Device/Attempt Data Rescue… could read data from one of my semi-damaged USB sticks.
It found 2 (of 3 FAT32) partitions and was able to read from, mounted as read only in /tmp, great!
The last line in it's “View” window says: “All mounted views will be unmounted when you close this dialog.”, OK, closed the window and Gparted.
Curious, I checked /mnt (Nemo, update may fail sometimes …) and found both partitions still there, could play mp3 from USB!
Of course, left pane of Nemo didn’t know about, as /tmp mounts are not shown there.
In Gparted the unmount wasn’t available because it thinks the partitions are not mounted.
(I was afraid to try double mount to unmount?)

So I tried Disks - and saw Gparted has, unbeknown to the user, mounted the files systems via /dev/loop0 and /dev/loop1, still mounted at /tmp/gparted-roview… , the USB partitions /dev/sde1+2 were not mounted.
I unplugged the USB stick, music still playing in Media Player, even next title, until “An error occurred - The movie couldn’t be read”.
But both loop devices were still there in Disks and mounted (plug USB in again to resume playing).
So Gparted could handle loop devices?

I searched Gparted’s doc and the Net but couldn’t find anything about GUI handling of loop devices.
It seems only using terminal one can open such a loop device: gparted /dev/loop0. In case of using “Unmount” Gparted clears GUI and loop device -
But the content still remains in Nemo’s view of the /tmp/gparted-roview-… (likley a Nemo - issue? Opening the folder as root it doesn’t have content …).
Conclusion: Use Disks to fully GUI - handle loop devices (create, attach, format, detach, …).

What a bumpy ride, thanks for reading!

Now back to your question: “What are you trying to accomplish?”

=> I wanted to Gparted-copy a partition [Gparted works on file level, only the used data part is copied] and paste it onto a loop device-file with smaller, but appropriate size for the data: Gparted should resize the partition automatically.
Disks can’t do that “copy”, and in Gparted I can’t use the GUI to access loop devices :evil:

AndyMH wrote:
Sun Sep 27, 2020 5:23 am
... create a loop device is use disks on a new unformatted drive ...
Nope, what Gparted calls “loop” is a partition on a (HW) drive without partition table.
I don’t know why they call it loop, but that’s not a loop device = a file (.img or .ISO) accessible as a block device.
In Disks click at the top - left hand side disk-icon (how I love that intuitive, modern design …) to create or attach a loop file. An attached loop file will be shown as loop device and handled like a physical device. Default is attaching read only, but see bottom left to uncheck the read only … nice interface, isn't it?
Post Reply

Return to “Software & Applications”