How to create a bootable linux USB drive with a single command!

in #linux6 years ago

Copy of Linux-aeon.png

Intro

They said you need clunky GUIs like Unetbootin to create bootable USB install drives.

They lied!

With just one command, you can accomplish this task without issues.
I had more issues with the GUI apps you can find online than doing it in this way.

The command

BEWARE 1: I am not responsible for any damage you may do to your system and devices by improper use of the unix dd utility.
BEWARE 2: the following command will erase any data contained in the target USB device. You don't even have to format it first :)

The magic command is one of the oldest and greatest army knives of every Linux user, Data Duplicator (DD):
sudo dd if=manjaro-kde-17.1.11-stable-x86_64.iso of=/dev/sdb bs=4M status=progress

if = input file = The ISO image of your operating system of choice (In my case, the great Manjaro distro).

of = output file = The device you are going to write the ISO image to. I repeat, the device and not the partition.

  • /dev/sdb = Device
  • /dev/sdb1 = Partition



Hint: to find how your USB stick is called, simply run:

sudo fdisk -l

Disk /dev/sda: 223,6 GiB, 240057409536 bytes, 468862128 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x58e6b2a7

Device     Boot     Start       End   Sectors   Size Id Type
/dev/sda1            2049 450402085 450400037 214,8G 83 Linux
/dev/sda2       450402086 468857024  18454939   8,8G 82 Linux swap / Solaris




Disk /dev/sdb: 14,4 GiB, 15497953280 bytes, 30269440 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000

Device     Boot   Start     End Sectors Size Id Type
/dev/sdb1  *         64 4232079 4232016   2G cd unknown
/dev/sdb2       4232080 4240271    8192   4M ef EFI (FAT-12/16/32)

In my case /dev/sdb is the USB drive.

The output

2168455168 bytes (2,2 GB, 2,0 GiB) copied, 291 s, 7,5 MB/s 
517+1 records in
517+1 records out
2171019264 bytes (2,2 GB, 2,0 GiB) copied, 291,41 s, 7,5 MB/s

When it finishes you may have to unmount and remount the drive to allow the data to be synced.

That's it! your bootable USB drive is ready to use!

Conclusion

DD is a great tool and it is very powerful, so be careful when using it!
It is capable of many, many other tasks like:

  • Cloning partitions.
  • Modifying files.
  • Measure drive performance.
  • Converting a text file to upper or lower case (Yes you got it right :)).
  • And much more!.

More info on its own wikipedia page

Thank you! Stay tuned for more linux tips, tricks and much more!

resh aquasummit.png

Sort:  

Good Post friend. I will try that on my raspberry pi 3.

Posted using Partiko Android