After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 749500 - GParted Live .iso not bootable on UEFI if dd'd to USB drive
GParted Live .iso not bootable on UEFI if dd'd to USB drive
Status: RESOLVED FIXED
Product: gparted
Classification: Other
Component: livecd
0.22.0
Other Linux
: Normal major
: ---
Assigned To: gparted maintainers alias
gparted maintainers alias
Depends on:
Blocks:
 
 
Reported: 2015-05-17 16:22 UTC by Kubuist
Modified: 2015-05-26 16:41 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kubuist 2015-05-17 16:22:27 UTC
I have been trying to create a new Gparted-live thumb drive.

Using 

sudo dd if=/location-of-iso of=/dev/sdX bs=4M; sync

I create a bootable usb drive, that does function, providing Gparted-live.

However, there are a couple of issues:

    1. My computer does not recognize any UEFI boot up function on the usb drive.
    2. When the program is booted Gparted announces an error on the thumb drive "Invalid partition table - recursive partition on /dev/sdX" and a choice to Cancel or Ignore. Ignore allows the program to be used, ignore shuts down the program (gparted).
    3. Further investigation shows that - "partition table overlaps the last partition by 33 blocks! You will need to delete this partition or resize it in another utility."
    4. Any attempts to correct these errors results in a non-booting thumb drive.
    5. The only way to get things working again is to repartition and reinstall the .iso but this re-creates the error state.

After spending some time trying to sort out the drive, its partition and its formatting, I tried an alternative.

I installed Gparted-live using Method B for Linux. (http://gparted.org/liveusb.php) with gparted-live-0.22.0-1-amd64.zip.
This produced a thumb drive with no partition table or formatting errors, which also was recognized by my PC as having UEFI properties.

I suspect that the interaction of dd and the .iso produces an error or errors in certain circumstances.

The thumb drive is 4Gb, has an Msdos partition table, one FAT32 partition with 1Mb unused space at the beginning. 
I was using gparted-live-0.22.0-1-amd64.iso with dd, on a recent install of Kubuntu 15.04 Vervet.
MyPC is 64bit with UEFI. I do not have Windows installed.
Comment 1 Kubuist 2015-05-18 05:21:52 UTC
Quote: 
"Ignore allows the program to be used, ignore shuts down the program (gparted)."
should have read:
"Ignore allows the program to be used, Cancel shuts down the program (gparted)."
Comment 2 Kubuist 2015-05-18 11:13:41 UTC
With:
sudo parted /dev/sdd print

I get:
libparted bug found
Invalid partition table - recursive partition on /dev/sdd.



Performing:
sudo fdisk -lu /dev/sdd

I get:
Disk /dev/sdd: 3.9 GiB, 4127194624 bytes, 8060927 sectors
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: 0x656f8811

Device     Boot Start    End Sectors  Size Id Type
/dev/sdd1  *        0 464895  464896  227M 17 Hidden HPFS/NTFS


After extensive Googling I found this comment explains the above:
The first partition starts at sector 0, so it includes the MBR and the partition table that contains itself.  This makes it look like an extended partition recursively containing itself.
-----------------------------------------------
Should something be done to make the dd copy skip a few sectors to allow space for the msdos partition table? Is that even possible?

This still doesn't address the fact that the computer cannot see the file on the usb drive has UEFI capabilities.

Is the file type reported by fdisk relevant?

I am very much out of my depth here but I will continue tread water in the hope that a rescue is possible.
Comment 3 Kubuist 2015-05-19 04:48:18 UTC
I checked out a bootable thumb drive made by using dd with a different iso.
It is recognized as UEFI capable by my PC and displays no errors.

Performing on it:
sudo fdisk -lu /dev/sdd

I get:
Disk /dev/sdd: 7.5 GiB, 8053063680 bytes, 15728640 sectors
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: 0x000ea6ea                                                                            
                                                                                                       
Device     Boot Start      End  Sectors  Size Id Type                                                  
/dev/sdd1  *       63 15727634 15727572  7.5G  c W95 FAT32 (LBA)

The important things to note here are that it starts at sector 63, its Id is c of Type W95 FAT32 (LBA)

The problem with the Gparted live is that it starts at sector 0, its Id has somehow become 17 of Type Hidden HPFS/NTFS ???

Both thumb drives started out clean, with a dos partition table and one fat32 partition.

I am still out of my depth but willing to work with anyone over this bug to the iso file: gparted-live-0.22.0-1-amd64.iso

Incidentally someone on the Gparted Forum has stated that gparted-live-0.21.0-1-amd64.iso is displaying similar behaviour.
Comment 4 Steven Shiau 2015-05-20 00:03:28 UTC
Kubuist,
As I mentioned here:
http://gparted-forum.surf4.info/viewtopic.php?pid=33235#p33235
Please allow me to re-use that here:
There is no "dd" method mentioned on http://gparted.org/liveusb.php
Actually "dd" is not a good way to make bootable USB flash drive, because it will overwrite everything on the USB flash drive, and it has compatibility issue. Say if you have a 4 GB drive, using dd to write gparted-live iso to that drive, then you won't make use all of the 4 GB space. The rest is not seen. Not to mention what you have report, it's not working for UEFI machine.
Therefore, I do not think it's a bug for GParted live. It's the the restriction for dd.

Steven.
Comment 5 Kubuist 2015-05-20 10:18:26 UTC
I think this needs to be looked into a little closer, as your comments are not strictly accurate, Steven, as a result I suggest that status being 'resolved' is also inaccurate
Comment 6 Kubuist 2015-05-20 10:19:44 UTC
I think this needs to be looked into a little closer, as your comments are not strictly accurate, Steven, as a result I suggest that status being 'resolved' is also inaccurate
Comment 7 Steven Shiau 2015-05-21 00:26:50 UTC
Kubuist,
Yes, maybe I was wrong. If you find and live CD iso you can use dd to make it boot on a uEFI machine, please let me know. I am eager to know how it works.
Please feel free to reopen this if you think it's necessary.
Thank you very much.

Regards,
Steven.
Comment 8 Kubuist 2015-05-21 05:27:22 UTC
Okay, I must go to work now, but later I will walk you through making a working bootable thumb drive using dd. I assure you I have been using this method for years with no problems. I am not alone in having success with it. I am sure there are others who would expect this method to work.
Comment 9 Kubuist 2015-05-21 05:53:14 UTC
I might be some time if I have to download old versions of GHParted live to find a properly working one.
It must have worked at some stage - Method D says so
I wonder when that part of the Web page was written? It might be a clue.
Comment 10 Kubuist 2015-05-21 10:23:33 UTC
I have re-read your comment. Are you suggesting that Gparted live cannot or has never been able to boot on an UEFI machine?
I am not a computer coding expert so it is difficult for me to understand how all this works.
Let me outline what I understand and what I would expect.
If you download the operating system Kubuntu as an .iso in the amd64 version you will have a file that can be used to create a bootable thumb drive containing a Live version of Kubuntu and also an installer, if you want install Kubuntu onto your computer. The thumb drive can be set up using the dd program. When it is set up, on examining the thumb drive in a file manager, you can see the files of the Kubuntu installation on that usb drive. If you look at the usb drive in a partition editor you will see a bootable fat32 partition containing data. At start up this drive can be booted as dos or UEFI.
Using Method D I would expect to get a similar thumb drive containing Gparted-Live. Unfortunately, the thumb drive is only bootable to dos, displays errors in a partition editor and does not seem to have any regular partitioning system.
Perhaps this has always been the case? 

I am not a coder so my suggestions are likely to be off target. The zip file does produce an UEFI enabled usb drive, which performs as expected. For some reason the iso does not.
Comment 11 Kubuist 2015-05-21 10:40:44 UTC
On further testing the .iso, by copying to CD using K3B, this DOES produce a properly functioning UEFI enabled item.
Comment 12 Kubuist 2015-05-21 11:21:24 UTC
I tried another viable method to create the thumb drive:
sudo cp ~/gparted-live-0.22.0-1-amd64.iso /dev/sdX

but it also resulted in the same problems.
Comment 13 Kubuist 2015-05-21 11:24:27 UTC
The essential program Gparted-Live does not appear to be the problem.
Also, I find it hard to believe that both cp and dd have the same bug that prevents them from functioning correctly with the Gparted-live isohybrid, but allows them to behave correctly with all other isohybrids.

I have Googled isohybrid, syslinux-utils and now have a rudimentary understanding of what is involved, but I don't know how they are applied to the Gparted-live iso and wonder if it is here that the problems begin.

Maybe someone with a knowledge of the setting up of an isohybrid could give us some pointers?
Or maybe we could muddle through it in the dark.
It seems a shame to have such a useful utility not readily available to its audience.
UEFI and 64bit is becoming standard and there is going to be an ever increasing number of those wanting to access this resource.

Some will very likely try, as I did, via the Method D. Then will they give it up as a bad job since it didn't work right?
Comment 14 Kubuist 2015-05-21 11:25:05 UTC
Perhaps I could download an iso off the CD I created and apply isohybrid to it and create a working iso? Is this how it is done?
Comment 15 Curtis Gedak 2015-05-21 14:57:05 UTC
Thank you Kubuist for your interest in improving GParted Live.

The GParted Live image is based on Debian Live.  The isohybrid feature is part of Debian Live as mentioned in the online documentation.

   GNU/Linux Method D: Manual - Overwite section.
   http://gparted.org/liveusb.php#linux-method-d

The documentation on the Debian Live page indicates that the isohybrid boots under BIOS.  There is no mention of UEFI.

   Debian - How do I write a CD image to a USB flash drive?
   https://www.debian.org/CD/faq/#write-usb

Perhaps you could follow up with upstream Debian regarding this issue?
Comment 16 Kubuist 2015-05-21 17:02:38 UTC
What jumps out at me, though I neither know nor understand the hows and wheres, is that my operating system (Ubuntu) is based upon Debian. It offers an AMD64 iso that is bootable in both BIOS and UEFI modes. Using it to create a bootable thumb drive is quick and straight forward. As Gparted-live is also based on Debian I would imagine that it too should be able to boot in both modes. 
I will see what I can find out. Unfortunately I'm not a coder or programmer or writer of softwares so I might be a while explaining myself and getting results but I will give it a go. Anything useful I discover I will post either back here or in the Gparted Forum.
Oh and thanks for the acknowledgement - Gparted has been useful to me for some time - if I can put something back in it would be a pleasure.

In the meantime - would it be a good idea on GNU/Linux Method D to put a line saying that:
This Method is not working as we would like at the moment... but we are working on it. In the meantime GNU/Linux Method B: Manual will give the result you seek.
Comment 17 Patrick Verner 2015-05-21 19:53:17 UTC
@Steven

Use isohybrid from syslinux-6.03. I'm guessing you are using this command:

isohybrid gparted_bla_bla.iso

You should be using:

isohybrid --uefi gparted_bla_bla.iso

I'm not sure how this started or when, but it seems most of the distributions now claim turning your USB flash drive into a read-only CDR is a good idea. I recently had some requests for this and figured it out. I thought it would be complicated, but in the end it was just a flag added to isohybrid.

I have found that Unetbootin is the best way to install a distribution on a USB drive. We use the syslinux config the way Unetbootin alters it by default. The USB drives I sell are simply created with Unetbootin. I've sold 100's in the last year and I have never had one returned because it wouldn't boot.

I've downloaded a bunch of different debian distributions from Ubuntu to Mint. They all show this weird behavior in GParted like the poster described when you use dd. The development version of Parted Magic I posted today doesn't show these errors in GParted and boots from legacy or EFI. I'm not sure what debian is doing, but they might be using an older version of isohybrid.

Hope this helps...
Comment 18 Steven Shiau 2015-05-22 14:51:46 UTC
@Patrick, 
Wow, thanks for clarifying that. Now I understand that. I will create another version of GParted live based on your info.
Appreciate.

@Kubuist,
Yes, it's my fault. I am sorry. I did not know isohybrid has this option. I will create another GParted live with this option.
However, as Patrick mentioned, it's better to use some other tool than dd, like unetbootin or tuxboot.
Actually for uEFI machine, as what you have done, is just to unzip the gparted-live zip file on your flash drive. That's all. 
Of course we should have a universal iso file which works for any method.
Thanks for your bug report.

Steven.
Comment 19 Kubuist 2015-05-22 20:40:03 UTC
you are very welcome Steven
there are several other options to isohybrid that can tweak how it configures the final hybrid iso
I'd be pleased to post the results I get when the updated iso is published.
Comment 20 Curtis Gedak 2015-05-23 15:33:41 UTC
Updating bug title from:

   making a dd of the .iso corrupts usb drive

to:

   GParted Live .iso not bootable on UEFI if dd'd to USB drive
Comment 21 Kubuist 2015-05-24 09:04:46 UTC
@ Steven
quote from:

http://d-i.debian.org/manual/en.i386/ch04s03.html
-------------------------------------------------------------------------------
4.3.1. Preparing a USB stick using a hybrid CD or DVD image
	Important
The image must be written to the whole-disk device and not a partition, e.g. /dev/sdb and not /dev/sdb1. Do not use tools like unetbootin which alter the image.
-------------------------------------------------------------------------------

Please note that Debian do not recommend unetbootin and similar for setting up a live version. Also my experience corroborates this view and is the reason I use cp and dd. I know I am not alone in using this method, which is in essence the making of a bit by bit copy.
Comment 22 Steven Shiau 2015-05-24 13:18:08 UTC
@Kubuist,
Here you are:
http://sourceforge.net/projects/gparted/files/gparted-live-testing/0.22.0-2/gparted-live-0.22.0-2-amd64.iso
Please give it a try and let us know the results.
As for the Debian doc you gave, I do not think it covers the uEFI machine. As I mentioned, if what you want is for the uEFI machine, either unzip the gparted-live zip file to the USB flash drive,  or mount the iso file and copy all the files to the flash drive. That's all. For uEFI booting, it's so easy. The complicated thing is for legacy BIOS about make it bootable.
 Besides, I still do _NOT_ think the brutally way like "dd" or "cp debian.iso /dev/sdX" is a good method. It overwrites all the existing data on the flash drive. A good method we should have is is to keep the existing data on the flash drive, and it is also bootable.
Thanks.

Steven.
Comment 23 Curtis Gedak 2015-05-24 15:57:38 UTC
Thank you Steven for the new GParted Live image.  I will test it on my computers to ensure that the old methods of BIOS boot still work.

@Kubuist,

Would you be able to test this latest image for UEFI boot?


@Patrick,

Thanks for the tip on the --uefi option for the isohybrid command.  :-)
Comment 24 Curtis Gedak 2015-05-24 19:50:29 UTC
@Steven,

I tested the gparted-live-0.22.0-2-i586.iso image on my suite of test computers and virtual machines.  In all cases the image booted properly.

From my perpective, this image is ready for promotion to the stable release directions.  When promoted, I will make the appropriate announcement on our news page.

@Kubuist,

When you have a chance, would you be able to test the "dd" method for BIOS/UEFI boot?
Comment 25 Kubuist 2015-05-25 22:56:51 UTC
I'm downloading it right now - I'll report back shortly with results.
Comment 26 Kubuist 2015-05-26 00:06:02 UTC
I zeroed a 4MB thumb drive, then used gparted to set up an msdos partition table and to create one fat32 partition the full size of the drive. I set the boot and lba flags.

I made sure the thumb drive was unmounted and ran the following command in the terminal:

sudo dd if=/path/to/gparted-live-0.22.0-2-amd64.iso of=/dev/sdX bs=4M; sync

which gave:
241172480 bytes (241 MB) copied, 32.0677 s, 7.5 MB/s


In gparted the following showed:

partition----file system--label---------size------used---unused--flags
unallocated--unallocated--------------224.31MiB-----------------------
/dev/sdd2----fat16--------GParted-EFI---4.08MiB---3.99Mi--92KiB--esp
unallocated--unallocated----------------3.62GiB-----------------------

(I think the efi partition could do with being a little larger, or does isohybrid chose the size itself and just gives the bare minimum?)

I restarted my PC, going into the UEFI startup menu and saw the thumb drive showing up as both UEFI and legacy, which earlier versions were not doing. I clicked for a UEFI start and congratulations, GpartedLive booted into the correct mode, also there were no complaints about recursive partition tables.
It looks like you've killed that bug. Many thanks to all who contributed, Steven, Curtis, Patrick. I'll mark the bug as resolved, fixed.
Comment 27 Steven Shiau 2015-05-26 10:52:31 UTC
@Kubuist,
Thank you very much. I have moved this version to stable release.

@Curtis,
Please announce it. Thanks!

Steven.
Comment 28 mikeq 2015-05-26 13:42:55 UTC
I tested the new test GParted testing iso and it works great.

I did this slightly differently than kubuist in preparing the flash drive.

First, we both reported the error obtained with the previous version of GParted.  I also got that error upon running fdisk on the GParted flash drive:

sudo fdisk -lu
Error: Invalid partition table - recursive partition on /dev/sdb.

I took that same flash drive and simply zero-ed it out with dd:

sudo dd if=/dev/zero of=/dev/sdb bs=16M
dd: error writing ‘/dev/sdb’: No space left on device
485+0 records in
484+0 records out
8127512576 bytes (8.1 GB) copied, 1239.65 s, 6.6 MB/s

Then without creating any partition table (i.e., no partitioning, no formatting--just the "raw" cleared-out flash drive), I ran this dd:

sudo dd if=gparted-live-0.22.0-2-amd64.iso of=/dev/sdb bs=16M
14+1 records in
14+1 records out
241172480 bytes (241 MB) copied, 39.713 s, 6.1 MB/s

Re-booting the PC with this live GParted flash drive, entering my UEFI firmware setup (ASUS H-97 Plus motherboard), the flash drive showed up both ways, as a UEFI bootable choice and as a BIOS=legacy-CSM choice:

UEFI: (FAT) KingstonDataTraveler 2.0 (7751 MB)
and as
KingstonDataTraveler 2.0 (7751 MB)

I booted to the UEFI entry. And it booted perfectly, fast, it did its configuring, and opened with the GParted screen with no error messages.

Perfect.  Thanks for the great work.
Comment 29 Curtis Gedak 2015-05-26 16:41:30 UTC
Thank you Kubuist and MikeQ for testing and confirming that this latest image boots correctly on UEFI computers.

@Steven,
Thanks again for creating this latest image and promoting it to the stable branch.  I have announced this new release.

Curtis