Question about fix-usb.sh

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
User avatar
fredx181
Posts: 3059
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 373 times
Been thanked: 1301 times
Contact:

Question about fix-usb.sh

Post by fredx181 »

Successfully used the script fix-usb.sh as included in Fatdog (and kindly recommended to me once by @jamesbond ) for when used dd to write ISO to USB, to be able to use all space (besides the space that the ISO takes).
So no complaint, but I just like to understand why the the created partitions after running fix-usb.sh won't show in gparted (only iso9660 showing).

2024-10-08_19-49-53.png
2024-10-08_19-49-53.png (48.29 KiB) Viewed 380 times

Output of fdisk -l /dev/sda does show the new partitions made:

Code: Select all

fdisk -l /dev/sda
Disk /dev/sda: 3.77 GiB, 4047503360 bytes, 7905280 sectors
Disk model: Cruzer Contour  
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7e7e4ea7

Device     Boot   Start     End Sectors  Size Id Type
/dev/sda1  *          0 2899263 2899264  1.4G  0 Empty
/dev/sda2           528   25103   24576   12M ef EFI (FAT-12/16/32)
/dev/sda3       2912256 7905279 4993024  2.4G 83 Linux
jamesbond
Posts: 716
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 124 times
Been thanked: 402 times

Re: Question about fix-usb.sh

Post by jamesbond »

@fredx181, that's because there are two different disklabels (=partition tables) on the disk: the ISO9660 disk label, and the (crippled) msdos disklabel. That's just the nature of isohybrid ISO images.

gparted is confused by this, so it decides to pick one of them: and this is almost always the ISO 9660 disklabel, which has no partitions in it.

In fact, it's really hard to convince the gparted to be able to re-partition the flash drive again, to the point that you have to wipe-out the disk this way, as documented here, but I copied the relevant command below:

dd if=/dev/zero of=/dev/«Flash drive device name» bs=1M count=1

User avatar
fredx181
Posts: 3059
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 373 times
Been thanked: 1301 times
Contact:

Re: Question about fix-usb.sh

Post by fredx181 »

@jamesbond
Tried wiping out first , and created new partition table, ran dd ... to write the iso again, ran fix-usb and gparted is still stubborn :? , showing only the iso 9660 partition.
Well.. nevermind, thanks anyway, I got the extra partition and that's the important thing.

jamesbond
Posts: 716
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 124 times
Been thanked: 402 times

Re: Question about fix-usb.sh

Post by jamesbond »

fredx181 wrote: Sun Oct 13, 2024 11:24 am

@jamesbond
Tried wiping out first , and created new partition table, ran dd ... to write the iso again, ran fix-usb and gparted is still stubborn :? , showing only the iso 9660 partition.

No, no, sorry for the misunderstanding. Let me try again.

What I mean is, if you dd-ed an isohybrid (any isohydrid, not only Fatdogs), you will always end up in the situation where gparted will be confused and refuse to work. There is __no__ way you can make gparted work, and still have the OS usable. If you want to keep the OS, then you'll just have to accept that gparted will no longer work on the flash drive.

You can use fdisk or sfdisk to manage the partition tables, but not gparted (or parted, for that matter). fix-usb.sh works using sfdisk, that's why it works.

-------

Now, lets say after a while, you want to re-purpose the flash drive and wipe everything on it (e.g. remove the OS completely and re-partition). You still __cannot__ use gparted for this purpose. If I recall correctly, even if you create a new disklabel with gparted, it will still not be recognised. It will continue to see the ISO 9660 filesystem. Weird, isn't it?

The only way to clear the flash drive and allow gparted to work again, is to use the "dd" command in my previous post. This removes / clears everything, make the flash drive looks blank to gparted, and then you can re-partition it again.

I hope I make it clearer now.

User avatar
fredx181
Posts: 3059
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 373 times
Been thanked: 1301 times
Contact:

Re: Question about fix-usb.sh

Post by fredx181 »

@jamesbond

...
There is __no__ way you can make gparted work, and still have the OS usable. If you want to keep the OS, then you'll just have to accept that gparted will no longer work on the flash drive.
...

Ah, ok, thanks, indeed I misunderstood earlier, clear now that it cannot be fixed for gparted.

User avatar
rcrsn51
Posts: 1389
Joined: Sun Aug 23, 2020 4:26 pm
Been thanked: 357 times

Re: Question about fix-usb.sh

Post by rcrsn51 »

Can you not repair the drive with Gparted just by creating a new partition table?

jamesbond
Posts: 716
Joined: Tue Aug 11, 2020 3:02 pm
Location: The Pale Blue Dot
Has thanked: 124 times
Been thanked: 402 times

Re: Question about fix-usb.sh

Post by jamesbond »

rcrsn51 wrote: Sun Oct 13, 2024 3:53 pm

Can you not repair the drive with Gparted just by creating a new partition table?

I remembered that this would not work. But that was quite a while ago, using older version of gparted.

I just tested with a modern version of gparted, and you're right @rcrsn51, now apparently gparted is smart enough to clear the ISO 9660 filesystem marker if you tell it to create a new disklabel (=a new partition table). So at least, no need to go with the "dd" method to clear the flash drive.

Post Reply

Return to “FatDog”