Skip to content

Instantly share code, notes, and snippets.

@daltonnyx
Last active July 1, 2017 04:05
Show Gist options
  • Save daltonnyx/4ecaefdf5503dc827954c6933179e9a7 to your computer and use it in GitHub Desktop.
Save daltonnyx/4ecaefdf5503dc827954c6933179e9a7 to your computer and use it in GitHub Desktop.

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.

Format USB with: mkdosfs -F 32 -I /dev/sdc1

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.

Second method

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment