Why does 'dd' not work for creating bootable USB?

37

18

Recently I wanted to create a bootable USB of Linux mint. I found that there was a lot of conflicting advice/experience about whether the 'dd' command could be used to create a bootable USB. I decided to download an ISO and try. While dd definitely put the image on the USB stick it was not bootable. So my question is what is the magic ingredient that will make this work or why has this approach persisted if it does not work?

This is the command I used,

dd if=/mint/iso/image of=/dev/sdb1 oflag=direct 

jdowner

Posted 2012-04-01T12:33:37.797

Reputation: 485

You may have a system-on-a-stick that shall be used in an EFI boot system -- but your machine is configured to use "classical" boot. So seen with a Linux Mint USB stick. – David Tonhofer – 2016-08-08T16:12:24.830

Here is a simple/genius workaround for recalcitrant iso images (based on Ubuntu Live ISO): 1) Format stick so that there is a filesystem on (say) "/dev/sdX1" , 2) Mount stick as "/mnt/usb" for example, 3) Install grub2 on stick: grub2-install --boot-directory /mnt/usb/boot/ /dev/sdX, 4) Copy previously downloaded ISO image (for example "foolinux.iso") to stick: cp foolinux.iso /mnt/usb/ 5) Create "/mnt/usb/boot/grub2/grub.cfg" file that boots linux from the ISO image present on the stick (cont) – David Tonhofer – 2016-08-08T18:40:33.460

(cont from previous, using "¶" to indicate line breaks) set timeout=10 ¶ set default=0 ¶ menuentry "Run Ubuntu Live ISO" { ¶ loopback loop /foolinux.iso ¶ linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=/foolinux.iso splash -- ¶ initrd (loop)/casper/initrd.lz ¶ } ... and that should work (tested on boot-repair-disk-64bit.iso, picked up from this page

– David Tonhofer – 2016-08-08T18:42:38.877

@sawdust while you are stating that the answers posted are a "no go", this article (http://community.linuxmint.com/tutorial/view/744) indicates that this is the correct procedure.

– Dave G – 2012-04-02T02:03:30.500

1@DaveG - Interesting, apparently 'dd' is a usable command iff the source file is a "Hybrid ISO image". But it is not a generic procedure for every iso. Perhaps that distinction is the reason for the conflicting advice jdowner encountered. – sawdust – 2012-04-02T05:26:44.060

@sawdust thanks for the additional clarification on that. – Dave G – 2012-04-02T07:47:06.910

Answers

33

You are writing the image to the partition 1 of /dev/sdb

Change this to the following command:

dd if=/mint/iso/image of=/dev/sdb oflag=direct

this information was acquired from here

Dave G

Posted 2012-04-01T12:33:37.797

Reputation: 448

2I'm doing: sudo dd if=./debian-8.4.0-powerpc-DVD-1.iso of=/dev/rdisk3 bs=1m and its not bootable, any ideas? – Yusufk – 2016-06-11T16:22:02.980

I'd rdisk3 a partition or a raw disk? You are attempting to write the image to a specific partition – Dave G – 2016-06-11T16:46:49.537

1i'm doing /dev/sdb and it's still not bootable – holms – 2018-03-17T22:45:09.247

rdisk3 is the 3rd disk on a mac afaik. I have the same issue as Yusufk. Need to check if its related to UEFI. – gavit – 2018-05-05T16:23:06.000

11

You copied the image to the first partition. Try copying to /dev/sdb rather than /dev/sdb1.

The actual mechanism varies a bit depending on the type of image you're using, but for simple DOS/MBR images you need to get a correct partition table (with the bootable partition marked as being bootable, and the MBR - the part of the initial 512 bytes that isn't the partition table - containing initial boot code.

Kristof Provost

Posted 2012-04-01T12:33:37.797

Reputation: 618

I would note that rather than trying to copy the whole ISO again to another partition, simply setting the boot flag on the partition you originally copied the image too may suffice (as hinted at in this answer) – GrayedFox – 2018-11-19T19:11:53.507

2

From my experience with another Linux distro, all you should have to do is change the syslinux boot loader file and modify it to boot the USB. There's more detailed information about this at the syslinux wiki.

See also this Google search.

Jacob J Daniels

Posted 2012-04-01T12:33:37.797

Reputation: 21

1

You may need to have a BPB written into your bootloader. See Dex's post from Fri Apr 24, 2009 9:06 am at http://f.osdev.org/viewtopic.php?f=1&t=19681

The gist is that "if [your usb firmware] users floppy emulation and you do not have a BPB, it will NOT boot"

Armed with that advice, I was able to resolve this issue. I use linux, so my dd command was:

sudo dd bs=512 count=2880 if=IMG.bin of=/dev/sdb

You'll want to replace sdb with your usb device. You can find it by running

ls -l /dev/ | grep sd

before and after inserting your usb while linux is running. If you get e.g. sdb1 and sdb, chose the non-indexed option.

define

Posted 2012-04-01T12:33:37.797

Reputation: 11

0

I've also encountered this issue a few times.

What I found that works for me most of the time is to zero-fill the drive first.

  1. Change X to your drive letter or number, to find it:

    • Mac: diskutil list
    • Linux: lsblk
  2. Zero-fill the drive

    • Mac: dd if=/dev/zero of=/dev/rdiskX bs=4m
    • Linux: dd if=/dev/zero of=/dev/sdX bs=4M
  3. dd your image again

(4meg block sizes seem to be the quickest for me)

Andre Helberg

Posted 2012-04-01T12:33:37.797

Reputation: 101

0

Have you made sure that your motherboard is set to boot from the USB device before it tries booting from your HDD? I would guess that may be your only issue - there's not much to using dd as you can see.

Eli Sand

Posted 2012-04-01T12:33:37.797

Reputation: 174

1This was an issue that I had thought about, especially because I was working on an old computer. So when it did not work on my target machine, I set the boot order on my wifes laptop (shh, don't tell her) and it did not boot from that either. – None – 2012-04-01T15:07:57.957