PDA

View Full Version : [SOLVED] dd'ing the Ubuntu .iso image creates two partitions on USB startup disk



pveurshout
December 31st, 2014, 01:17 PM
I downloaded the Ubuntu 14.04.1 .iso image and used dd to 'burn' it to a USB flash drive (which I'll refer to as sdX).


dd if=/path/to/ubuntu-14.04.1-desktop-amd64.iso of=/dev/sdX

Afterwards, I noticed that this had created two partitions on the flash drive: sdX1 and sdX2. sdX1 is mountable and contains the files that the iso image contains. I wanted to know what sdX2 was for, and found a possible explanation for this in the Community Help Wiki:


2. There may be a bug during the formatting which will cause two partitions to appear when booting from the USB flash drive. Try selecting each of them and one should work. If not, restart the computer and try booting from the USB flash drive again.

But this didn't sound like a satisfactory answer (after all, I didn't use the Startup Disk Creator, so a bug there wouldn't cause this for me), so I dug a little deeper. I noticed that sdX1 was exactly the same size as the original .iso image and sdX2 was a few MB in size. So I computed a checksum of /dev/sdX and verified it against the .iso image. Unsurprisingly, these did not match because the flash drive is much larger than the 981.0 MB Ubuntu image, so the checksum of the former is calculated over a lot of zeroes in addition to the dd'd (:)) image. What did struck me as a surprise, however, was that the sha256-checksums of the .iso image and the contents of /dev/sdX1 matched exactly. But...the .iso image did not just create sdX1, it also created sdX2 as well as a partition table for the device sdX which holds the information of the existence of sdX1 and sdX2.

I've been trying to figure out what is going on, but the following still confuses me greatly: how can dd'ing an image (to sdX, not sdX1!) have created a partition table on sdX with two partitions in it, where one of the partitions contained by it (sdX1) is an exact copy of the original image? In other words: if the information contained in the .iso image makes up the contents of sdX1, where did the information for sdX2 and a partition table for sdX come from in the first place?

I'd be very happy if someone could shed some light on this. After all, it's never a bad thing to start the new year as a slightly more knowledgeable person! :-D

oldfred
December 31st, 2014, 05:58 PM
When you use dd to copy the ISO image it is copying a DVD which does not have partitions like a standard drive.

Do the partitions look like normal partitions?

I have seem where very strange partition appear. I believe the random data that DVD has written into the first sector is close enough that then partition tools try to read that data as partitions.

The info on partition table is just a few entries in the MBR.
Info on MBR
http://www.dewassoc.com/kbase/hard_drives/master_boot_record.htm

sudodus
December 31st, 2014, 06:35 PM
Does your USB drive boot properly? There is an iso9660 file system, which is read-only. Don't worry about the other things, as long as it works.

But you should worry about using dd, nicknamed 'disk destroyer', because there are no safely checks. I made mkusb to wrap security around dd. See this link https://help.ubuntu.com/community/mkusb

Ko_Char
December 31st, 2014, 08:18 PM
I think you answer is here.

http://lists.gnu.org/archive/html/coreutils/2014-10/msg00012.html

pveurshout
January 18th, 2015, 07:34 PM
I think you answer is here.

http://lists.gnu.org/archive/html/coreutils/2014-10/msg00012.html

Thanks, this clears it up! I'll mark the thread as solved.


Does your USB drive boot properly? There is an iso9660 file system, which is read-only. Don't worry about the other things, as long as it works.

But you should worry about using dd, nicknamed 'disk destroyer', because there are no safely checks. I made mkusb to wrap security around dd. See this link https://help.ubuntu.com/community/mkusb

Yeah, the install worked just fine :) I was just afraid that if something had gone wrong while creating the disk, it might've corrupted something that wouldn't have turned up until later (i.e., after a seemingly successful install). (And, also, I was curious ;).)


When you use dd to copy the ISO image it is copying a DVD which does not have partitions like a standard drive.

Do the partitions look like normal partitions?

I have seem where very strange partition appear. I believe the random data that DVD has written into the first sector is close enough that then partition tools try to read that data as partitions.

The info on partition table is just a few entries in the MBR.
Info on MBR
http://www.dewassoc.com/kbase/hard_drives/master_boot_record.htm

Great and comprehensive read, thanks for the tip!