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.
You can use
dd
.where
<?><?>
is a letter followed by a number, look it up by runninglsblk
.It will look something like
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):
where
input.iso
is the input file, and/dev/sd<?>
is the USB device you're writing to (runlsblk
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
: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
You're almost there with
dd
, but you're missing a step.where
sdX
is your usb device (this can be verified withlsblk
).The
sync
bit is important asdd
can return before the write operation finishes.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:Insert your USB flash drive. My drive is
/dev/sdd
. Here's a 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):Next, you need the
ldlinux.sys
file in your USB flash drive to make the USB bootable. My USB partition is/dev/sdd1
; enterlsblk
to see what's yours. Run the below commands:Navigate to the
/media/xxx
mount folder and rename theisolinux
directory tosyslinux
. Then go into the renamed folder and rename the fileisolinux.cfg
tosyslinux.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.
You have two choices.
If you desire a graphical interface, use usb-creator (it is in the ubuntu repos)
If you want a command line tool, use dd
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.
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:
and then run the following commands:
You want to run that last command to
/dev/sdX
and not/dev/sdX1
.Then, proceed with the following commands:
or, to see progress of image write:
or instead of
dd
, you can usecat
instead:Rememeber to issue sync command to flush write cache
web.archive.org/web/20140327085331/https://tails.boum.org/doc/first_steps/installation/manual/linux/index.en.html
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
:Or provide explicitly the USB device:
Quick install
See it in action
Don't use the path to bit.
cd
command to get to the folder that contains the .iso filedd if=FILE NAME HERE.iso of=/dev/sdX bs=1MB
Wait until the console output looks something like this:
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.Title
There are built-in text mode tools, that you can run from a text screen or a terminal window.
dd
orcp
orcat
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.
mkusb version 12 alias mkusb-dus works also in text mode (not only in GUI mode).
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.)
Installing this way will add not only mkusb but also some program packages that mkusb depends on.
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
.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
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
orcp
orcat
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.)