Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to create a Linux Live USB drive from an isohybrid (.iso) image.

To accomplish this task, I have taken these steps in the past:

  1. Securely wipe the flash drive using the command:

    sudo dd bs=4M if=/dev/zero of=/dev/sdx

  2. Create an msdos partition table on the flash drive with gparted

  3. Create a new partition (/dev/sdx1) that is the entire size of the flash drive with a fat32 filesystem (for cross-platform compatibility) aligned to cylinder with gparted

  4. Set the bootable flag on the newly created partition (/dev/sdx1) using gparted

  5. Check the filesystem on the newly created partition (/dev/sdx1) to make sure all of the disk formatting operations were carried out properly using gparted

  6. Write the .iso image to the flash drive using the command:

    sudo dd bs=4M if=<distro>.iso of=/dev/sdx

However, after completing the last step, when I inspect the disk again with gparted, it reports that all of the space on the flash drive is unallocated and that there is no partition table on the disk. I suspect that this may have something to do with the Master Boot Record (MBR) being overwritten or corrupted when I write the .iso to the flash drive using the dd command.

When I mount the flash drive all of the files that were contained within the .iso appear to be properly extracted from the .iso, and I am sometimes able to boot the live USB. However, I have had various reliability issues using this method during boot up and also when trying to install a distro on a hard drive using the live USB. Like I mentioned before, I suspect that this may have something to do with the partition table being corrupted and the fat32 filesystem not being properly detected after the .iso is written to the flash drive, which may be leading to some reading and writing issues with the disk when booting and installing.

Is there a way to prevent these reliability issues from occurring and the partition table from being corrupted, while still using only gparted and dd?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Once you run dd bs=4M if=something.iso of=/dev/sdx, everything you created with gparted (i.e. the partition table) is overwritten by the dd.

The fact that gparted shows the disk is unallocated and has no partition table is normal. At least, that's what gparted shows for all Debian USB sticks I've created so far.

A better way to test whether the dd succeeded is to try to mount the first partition on the disk and see if the contents look sane (= look similar to what's in the iso).

mkdir a b
mount /dev/sdx1 a
mount file.iso b
# see if the a and b directories seem to contain the same files

Also, you might want to use cp something.iso /dev/sdx instead of dd. It's easier to type and just (if not even more) effective.

EDIT: I see that you did mount the disk and saw that the files were there. The reliability issues you're having might be the result of a bad USB stick. Try another and see if the problems persist.

Further information about ISOs and filesystems.

An .iso is a disc image. It's that long string of ones and zeros you get if you read a CD/DVD/etc from start to end.

cat /dev/cdrom > myfile.iso

If you write an .iso directly to an USB stick, the stick is treated just like a CD/DVD by the operating system.

Now, let's see what happens if you partition the USB stick, create a filesystem on a partition and copy the .iso there as a normal file.

mount /dev/sdx1 folder
cp file.iso folder/

We'll read the contents of the USB stick

cat /dev/sdx > mysecondfile

Now:

  • myfile.iso is the image of a disc containing the installer's files, bootloader, etc
  • mysecondfile is the image of a disc containing a single file, myfile.iso.

And this is why you should write the iso to the stick directly instead of storing it as a file.

share|improve this answer
    
Okay, I actually thought that, that might be normal. I have actually tried multiple flash drives and the reliability issues seem to occassionaly occur on both. However, they are both somewhat old flash drives, so I suppose that it is possible that they are damaged. Thank you for the help! The only question I have is whether using cp extracts the files from .iso like using dd does. –  Kevin Gurney Aug 24 '13 at 19:34
    
Neither cp nor dd "extract" the files from the .iso. An iso is not an archive; it's a disc image. It's the long string of ones and zeroes you'd get if you read a DVD from start to end. cp and dd just write this to the disk, and the operating system or bios read it just like they would read a DVD. –  user49740 Aug 24 '13 at 19:38
    
Okay, that makes sense. However, could you clarify why when you use dd or cp the files are presented separately on the flash drive, as opposed to if you simply moved the .iso onto the flash drive using a GUI file manager? –  Kevin Gurney Aug 24 '13 at 19:39
    
I'll explain that in an edit to the answer in a few minutes. –  user49740 Aug 24 '13 at 19:40
    
Okay, thanks again for all of your help! –  Kevin Gurney Aug 24 '13 at 19:41
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.