dd command for creating bootable .iso does not boot

21,000

Solution 1

Cloning the iso file to a USB pendrive

Using dd like you describe is cloning, which is a simple an reliable method that works with all current Ubuntu family iso files in order to create USB boot drives, and 64-bit systems work in both BIOS and UEFI mode.

You need elevated permissions, which you do by running with sudo. I think the following command would do what you want

sudo dd if=~/Desktop/xubuntu16.04 of=/dev/sdx bs=4096

where x is the device letter of the target drive. It is extremely important the get the correct letter for the target drive, otherwise you might overwrite a drive, where you store the family pictures and some other very important files. dd is a very powerful but also very dangerous tool, because it does what you tell it to do without questions, and a minor typing error is enough to destroy your family pictures.

There should be no partition number, so /dev/sdx (not /dev/sdx1) because you want to clone from the iso file to the whole drive and point to the drive's head end, (not to a partition). In my experience it is fast in many computers to write with the block size 4096 bytes.

Safer cloning tools

I would recommend that you use a tool that helps you identify and select the target drive and with a final checkpoint where you can make sure, that you will write to the correct drive.

  • 'mkusb' is such a tool that works in all current Ubuntu versions. It wraps a safety belt around dd. See this link

    help.ubuntu.com/community/mkusb

  • The Ubuntu 'Startup Disk Creator' in Ubuntu 16.04 LTS and newer versions is also a reliable cloning tool to create USB boot drives with Ubuntu. (Earlier versions of the Ubuntu 'Startup Disk Creator' are buggy.)

  • Another alternative is 'Disks' alias gnome-disks.

Solution 2

So ISO images might work and some might not. An Optical disk and a USB drive have different booting characteristics. The don't boot the same and have the bootloaders in the same location.

Rufus and other ISO writers are aware of this and compensate. As you can see from your test cases, just writing the exact byte by byte to the media won't always work, because the low-level raw writing is not making the needed adjustments, which isn't the same on both an Optical drive and as in this case, a USB drive.

Share:
21,000

Related videos on Youtube

tulleydr
Author by

tulleydr

Updated on September 18, 2022

Comments

  • tulleydr
    tulleydr almost 2 years

    I am new to Linux. I'm not sure what I'm doing wrong, but when I use the dd command to try and make a bootable/installable USB drive it will not boot from any computer. If I take the same .iso file and use rufus, on windows, it will boot on any computer. All of the computers but one have BIOS and the other has UEFI. Also I am not doing a dual boot on any of them. I have tried the following 8 different ways to accomplish this with dd

    • dd if=~/Desktop/xubuntu16.04 of=/dev/sdb

    • dd if=~/Desktop/xubuntu16.04 of=/dev/sdb1

    • dd if=~/Desktop/xubuntu16.04 of=/dev/sdb bs=4M

    • dd if=~/Desktop/xubuntu16.04 of=/dev/sdb1 bs=4M

    • dd if=/dev/cdrom of=/dev/sdb

    • dd if=/dev/cdrom of=/dev/sdb1

    • dd if=/dev/cdrom of=/dev/sdb bs=4M

    • dd if=/dev/cdrom of=/dev/sdb1 bs=4m

    • Organic Marble
      Organic Marble over 7 years
      What kind of file is /Desktop/xubuntu16.04 ?
    • Panther
      Panther over 7 years
      Did you check the sum of the iso ? What error message do you get when you boot ?
    • Elder Geek
      Elder Geek over 7 years
      All currently supported .ISO files can be successfully copied to live bootable media via dd your problem is likely a corrupted ISO file. Please see this
    • tulleydr
      tulleydr over 7 years
      It is an .iso file I got from xubuntu.org/getxubuntu/#lts. I downloaded the torrent file using transmission in Xubuntu. @OrganicMarble
    • tulleydr
      tulleydr over 7 years
      I don't know what check the sum of the iso means, but will do some research on it and try that. The other systems just state that there is no bootable media. @bodhi.zazen
    • tulleydr
      tulleydr over 7 years
      Here is the output of the checksum. From my research, it looks as if it passed. dustin@dustin:~/Downloads$ md5sum xubuntu-16.04.2-desktop-i386.iso 8fa567c74340743727f7d5d51f8e49bd xubuntu-16.04.2-desktop-i386.iso dustin@dustin:~/Downloads$ @bodhi.zazen
    • gone
      gone almost 5 years
      unmount your USB drive first, then use dd.
  • tulleydr
    tulleydr over 7 years
    I used your command of sudo dd if=~/Desktop/xubuntu16.04 of=/dev/sdx bs=4096 and used sdx not sdx1 to create the bootable USB media. I don't know if it was the sudo or the bs=4096, but whichever one it was, it worked great. Thank You!!! @sudodus
  • sudodus
    sudodus over 7 years
    You are welcome @tulleydr. I'm glad that it works for you :-) I think sudo was the crucial thing, that made it work.
  • sdjuan
    sdjuan over 5 years
    @tulleydr @ sudodus I had a similar issue but was already using sudo so I did a little research on the sector size and it turns out the 4096 can be quite important: "partition tables (both MBR and GPT) use physical sector size to compute their addresses. Therefore, changing the physical sector size invalidates partition tables. " quoted from [link] (klennet.com/notes/2018-04-14-usb-and-sector-size.aspx) So a wrong sector size will cause boot fail...
  • sdjuan
    sdjuan over 5 years
    and if you want to know the correct block size fdisk -l imagefilename will show you that
  • sudodus
    sudodus over 5 years
    @sdjuan, The block size bs used with dd commands is affecting the chunks of data managed by dd, but there is at least one software layer between it and the physical sector size of the drive (shown by fdisk and parted). So bs of dd has an influence on the write speed, but not on the physical sector size on the drive (the result will be the same, if I understand things correctly). -- But cloning from a drive with 512 byte physical sectors to a drive with 4096 byte physical sectors is a bad idea. The result might work, but not in an optimal way.
  • sdjuan
    sdjuan over 5 years
    I certainly noticed the write speed. 4096 bs took 15 mins for 10G image vs 50 minutes for 512 bs on my system