499

Is there any way to create a bootable Ubuntu USB flash drive from the terminal without using any third-party applications like YUMI, Unetbootin, Startup Disk Creator, etc.

I tried to create a bootable Ubuntu flash drive with dd method,

sudo umount /dev/sdb
sudo dd if=/path/to/ubuntu.iso of=/dev/sdb bs=1M

It creates files on the USB disk, but when I try to boot the USB disk it shows an Operating System Not Found error.

2
  • debian 11 here, this link helped : workaround.org/article/… : bottom line is : install genisoimage, use geeltorito to generate an img from the iso, and then (my part) use cp to copy the img to the USB to create a bootable USB stick.
    – RichieHH
    May 4, 2021 at 16:26
  • this is a very useful question. I liked it. Aug 22, 2021 at 22:42

8 Answers 8

655

You can use dd.

sudo umount /dev/sd<?><?>  

where <?><?> is a letter followed by a number, look it up by running lsblk.

It will look something like

sdb      8:16   1  14.9G  0 disk 
├─sdb1   8:17   1   1.6G  0 part /media/username/usb volume name
└─sdb2   8:18   1   2.4M  0 part 

I would dismount sdb1.

Then, next (this is a destructive command and wipes the entire USB drive with the contents of the iso, so be careful):

sudo dd bs=4M if=path/to/input.iso of=/dev/sd<?> conv=fdatasync  status=progress

where input.iso is the input file, and /dev/sd<?> is the USB device you're writing to (run lsblk to see all drives to find out what <?> is for your USB).

This method is fast and has never failed me.


EDIT: for those on a Mac ending up here, use lowercase for bs=4m:

sudo dd if=inputfile.img of=/dev/disk<?> bs=4m && sync

EDIT: If USB drive does not boot (this happened to me), it is because the target is a particular partition on the drive instead of the drive. So the target needs to be /dev/sdc and not /dev/sdc <?> For me it was /dev/sdb.

Reference: https://superuser.com/a/407327 and https://askubuntu.com/a/579615/669976

5
  • what will be the resulting format of the pendrive? I used the command showed above for Mac, and the resulting pendrive format was isofs. And that format wasn't readable by Mac OS X but it was readable by linux mint. Is there an argumento of dd to define the resulting format like fat32? Jun 10, 2020 at 15:23
  • Can you see the contents of the usb drive after this operation ?
    – ychaouche
    Mar 4, 2021 at 13:57
  • @ychaouche yes you will be able to see the content of the usb drive after. Apr 24, 2021 at 20:53
  • dd: invalid number: '4m' -> replace by 4M Dec 21, 2021 at 14:16
  • "lsblk" is not installed on my MAC, "df -h" works. Dec 24, 2021 at 11:34
130

You're almost there with dd, but you're missing a step.

sudo umount /dev/sdX
sudo dd if=/path/to/ubuntu.iso of=/dev/sdX bs=4M && sync

where sdX is your usb device (this can be verified with lsblk).

The sync bit is important as dd can return before the write operation finishes.

0
105

Creating a bootable Ubuntu USB flash drive from terminal

  • Place the ubuntu.iso file in any hard disk partition.

  • Then mount the ubuntu.iso file with the below commands in terminal:

    sudo mkdir /media/iso/
    sudo mount -o loop /path/to/ubuntu.iso /media/iso
    
  • Insert your USB flash drive. My drive is /dev/sdd. Here's a screenshot:

GParted screenshot

  • Your drive may be automatically mounted inside /media/. Let's assume that it was mounted in /media/xxx/.

  • Copy all files from /media/iso/ to your mounted USB flash drive by running the below command (make sure to include the dot):

    cp -a /media/iso/. /media/xxx/
    
  • Next, you need the ldlinux.sys file in your USB flash drive to make the USB bootable. My USB partition is /dev/sdd1; enter lsblk to see what's yours. Run the below commands:

    sudo apt-get install syslinux mtools
    sudo syslinux -s /dev/sdd1
    
  • Navigate to the /media/xxx mount folder and rename the isolinux directory to syslinux. Then go into the renamed folder and rename the file isolinux.cfg to syslinux.cfg.

  • Reboot your PC and change the boot order in BIOS to allow booting from a USB drive. Now your Ubuntu USB flash drive will boot and you can install it.

This method will work for any Linux distribution, not only Ubuntu. You don't need to install any third party software to make a Linux USB flash drive.

2
  • 2
    this is producing errors about not being able to create symlinks due to the destination being fat and the source apparently being some fs that supports symlinks
    – Michael
    Jun 22, 2020 at 21:14
  • Is there a source for this explanation?
    – erikbstack
    Sep 7, 2022 at 11:48
44

You have two choices.

If you desire a graphical interface, use usb-creator (it is in the ubuntu repos)

enter image description here

If you want a command line tool, use dd

#Replace X accordingly in both commands

sudo umount /dev/sdX
sudo dd if=/path/to/ubuntu.iso of=/dev/sdbX bs=1M

Just be sure /dev/sdX is the flash drive you wish to use (it will destroy the data on the flash drive).

See https://help.ubuntu.com/community/Installation/FromUSBStick for additional information.

0
36

First, unmount the USB device and then use lsblk to verify the device.

Sometimes (usually older iso files) dd is not sufficient and the pendrive will not boot. In this case, you may need to install syslinux:

sudo apt-get install syslinux

and then run the following commands:

sudo mkfs -t vfat -I /dev/sdX

You want to run that last command to /dev/sdX and not /dev/sdX1.

Then, proceed with the following commands:

isohybrid /path/to/file.iso --entry 4 --type 0x1c
dd if='/path/to/file.iso' of=/dev/sdX bs=8M

or, to see progress of image write:

pv -tpreb /path/to/file.iso | dd of=/dev/sdX bs=8M

or instead of dd, you can use cat instead:

sudo -s
cat /path/to/file.iso > /dev/sdX

Rememeber to issue sync command to flush write cache

sync

web.archive.org/web/20140327085331/https://tails.boum.org/doc/first_steps/installation/manual/linux/index.en.html

0
26

If by "third-party" you mean "GUI", I suggest a lightweight script named bootiso after Avinash Raj answer, because dd does not always work. The big plus is it's very secure (performs many security checks not to mess up with the system), easy to install and portable.

Also, bootiso will inspect the ISO file to choose from two modes: "image-copy" (dd) when the ISO file is hybrid (implies: USB boot friendly). And "mount-rsync" mode when ISO file is non-hybrid, in which case a SYSLINUX bootloader will be automatically installed if supported [more details about install modes].

How to use it

First option, just provide the ISO as first argument and you'll be prompted to select a drive amongst a list extracted from lsblk:

bootiso myfile.iso

Or provide explicitly the USB device:

bootiso -d /dev/sde myfile.iso

Quick install

curl -L https://git.io/bootiso -O
chmod +x bootiso
sudo apt install wimtools

See it in action

4
  • 1
    This is exactly what I was looking for thank you very much. Oct 30, 2020 at 11:50
  • 1
    thanks for the install instructions.. made my life very easy.
    – supersan
    Mar 7, 2021 at 6:32
  • Oh! My God! How is yours not the accepted answer? This tool tops whatever I have seen before! Thank you Dec 23, 2021 at 18:23
  • This is the best answer. I can't belive this stuff is so hard … Dec 27, 2022 at 18:19
9
$ dd if=ubuntu-14.04.1-desktop-amd64.iso of=/dev/sdX bs=1MB

Don't use the path to bit.

  1. Use the cd command to get to the folder that contains the .iso file
  2. use the command dd if=FILE NAME HERE.iso of=/dev/sdX bs=1MB
  3. Wait until the console output looks something like this:

    1028+1 records in
    1028+1 records out
    1028653056 bytes (1.0 GB) copied, 55.4844 s, 18.5 MB/s
    
  4. Boot from the usb.

Note: Make sure you write to the correct device a usb will not always be mounted at: dev/sdX where X can be any letter.

1
  • 1
    Not sure why everyone leaves off sudo :) And status=progress is always welcome for the impatient Oct 29, 2021 at 2:29
3

Title

How to create a bootable Ubuntu USB flash drive from terminal?

There are built-in text mode tools, that you can run from a text screen or a terminal window. dd or cp or cat can be used, but they are not safe because they do what you tell them to do without any question, and a minor typing error is enough to overwrite a drive with valuable data.

Fortunately there are also safer text mode tools, but you have to install them.

Install mkusb via its PPA: If you run standard Ubuntu live, you need an extra instruction to get the repository Universe. (Kubuntu, Lubuntu ... Xubuntu have the repository Universe activated automatically.)

    sudo add-apt-repository universe  # only for standard Ubuntu

    sudo add-apt-repository ppa:mkusb/ppa  # and press Enter
    sudo apt-get update
    sudo apt-get install dus mkusb-nox usb-pack-efi

Installing this way will add not only dus and mkusb-nox but also some program packages that mkusb depends on. (If you try to install the whole mkusb program package, it also wants to bring some tools that need a graphic environment.)

  • If you want a small tool or if you don't like PPAs or don't want any extra program packages, you can use mkusb-min. This shellscript is very small compared to the other versions, yet it serves the purpose to wrap a safety belt around dd.

      $ wc mkusb-min
       208  736 5435 mkusb-min
    

It should be rather easy to see what the shellscript is doing simply by reading it in a text editor.

Download mkusb-min from its Ubuntu help page. Run it locally or install it into a directory in PATH.

  • xorriso-dd-target is a new tool, intended to be uploaded to a Debian repository. The purpose is to make it very safe to create boot drives (USB pendrives or memory cards). A special feature is the plug-in method to identify the target device. The man page is available here. In January 2020 there is not yet any installer, but you can copy and paste from the links above and install the shellscript and man page manually.

  • Finally I want to mention bootiso which is described by its developer in another answer.

Question

Is there any way to create a bootable Ubuntu USB flash drive from the terminal without using any third-party applications like YUMI, Unetbootin, Startup Disk Creator, etc.

If we must look for text mode tools that are already installed in Ubuntu, I am afraid that there are no safe tools available. So in this case I can only suggest that you use dd or cp or cat according to many of the other answers here. But please check and double-check that you are really pointing to the intended target device before pressing the Enter key.

(By the way, the Ubuntu Startup Disk Creator belongs to Ubuntu (is not third party), but it needs a graphical desktop environment or at least a graphical window manager.)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .