How to create a Bootable USB stick, with free space, from an ISO image

  • Posted on: 3 April 2019
  • By: Michael

So you too don't like burning a new DVD each time you have a new ISO image to play with? This guide should help you create a bootable USB flash drive from the linux terminal without using any third-party applications. Rinse and repeat as needed and you won't have stacks of shiny plastic masquerading as coasters sitting all over the house.

All of this can be achieved using the 'dd' command, which I specifically did not use. Why? Couple reasons:

  • * These steps are fairly dangerous to begin with but 'dd' is even more dangerous as it's command options are not only cryptic but highly similar.
  • * These steps leave you with 'free space' on the USB stick. Do copy your .bashrc and any other files that make your life easier to the USB stick so you have them immediately after the USB boots.

WARNING!: If you don't know what you're doing, or you make a typo, you can easily FUBAR your computer.

DISCLAIMER!: While the author has successfully followed the steps given, the author, and Internet Design Alliance, are not liable, directly or indirectly, for any damages, losses, or impairments you receive related to the completeness, accuracy, or timeliness of any information contained on this site.

Now that the legal crap is over with, if you get stumped or have a situation this doesn't cover add a comment or send me an email through the contact form above. I tried to cover everything I hit along the way, but I'm sure there are other speed bumps out there...

Best,

Michael

Commands

Most of the steps are fairly self evident. References at the end can give you greater details for related items. If you encounter errors see Problem Children. If that that doesn't help, use your search-fu and add what worked for you in a comment so I can give you link joy.

Conventions and Definitions

This is all command line. I usually have at least two shells open at a time, one for root and one for user commands.

  • * For sections labeled {root} perform those actions as root or use sudo. [1]
  • * For sections labeled {user} perform those actions as yourself.

[1] For those distributions that kill off access to root, you can use 'sudo -i' to open a root prompt.

You should be able to copy Instructions to a text document and then find & replace all the 'Items named below' with your values (ymmv).

Items named below What it is
/media/iso-mx-18.1/ Place you're mounting the ISO image (read only)
/home/michael/Downloads/transmission/MX-18.1_x64.iso The ISO image file
/media/michael/CENTON_USB Place auto mount has mounted the USB stick
/dev/sdb1 Device name your system has given to the filesystem on your USB stick. Note the "1"!
/media/michael/CENTON_USB/boot/isolinux Where the isolinux directory has been placed by the ISO builder


Instructions

Shove the USB stick into your computer and let it auto mount. If it won't auto mount then follow the commands in the Reference link. Back up any files you have on it. Then we need to verify that your USB stick is formated as FAT 32. Most are, surprisingly the one I grabbed out of the bin was ext2.

{user}
lsblk

Find where your USB "filesystem" is mounted to determine what the device name is.

NAME                           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sdb                              8:16   1    15G  0 disk
--sdb1                           8:17   1    15G  0 part  /media/michael/CENTON_USB

The SIZE should tell you which one is your USB and TYPE labeled 'part' should tell you which is the filesystem on the USB.

{user}
findmnt /dev/sdb1

Does "FSTYPE' show up as "vfat"? If not then do section "USB not already FAT 32?" before proceeding.

{root}
mkdir /media/iso-mx-18.1/
mount -t iso9660 -o loop /home/michael/Downloads/transmission/MX-18.1_x64.iso /media/iso-mx-18.1/

{user}
cp -a /media/iso-mx-18.1/. /media/michael/CENTON_USB

Coping files can take some time, more coffee anyone?

{root}
syslinux -s /dev/sdb1

{user}
cd /media/michael/CENTON_USB

Now find if you have both the isolinux and syslinux directories. Most of the time it's like the first entry, but it depends on the ISO builder and mine happened to be like the second one:

  • /media/michael/CENTON_USB/isolinux
  • /media/michael/CENTON_USB/syslinux

  • /media/michael/CENTON_USB/boot/isolinux
  • /media/michael/CENTON_USB/boot/syslinux

If you have both, you should be good to go and can finish with:

  • * Open up a file manager and copy your .bashrc and all your other 'nice to have' files to the USB.
  • * Check your desktop for the USB drive icon. Right click on it and select Unmount and/or Safely Remove as available.
  • * As needed change the boot order in BIOS to allow booting from a USB drive.
  • * Boot from USB...

Don't have a syslinux directory? Or the USB stick didn't boot?

You'll need to copy the isolinux directory to syslinux and rename the .cfg and .bin files, which truthfully is easiest to do in a file manager, but here's the commands.

{user}
mkdir -p /media/michael/CENTON_USB/boot/isolinux
cp -a /media/michael/CENTON_USB/boot/isolinux. /media/michael/CENTON_USB/boot/syslinux
cd /media/michael/CENTON_USB/boot/isolinux
mv isolinux.cfg syslinux.cfg
mv isolinux.bin syslinux.bin

Okay, now try the finishing steps...

Problem Children

USB not already FAT 32?

This will most likely change your USB auto mounting point, so make sure to take note of that.

{root}
umount /dev/sdb1

Did you get the message?
umount: /media/michael/CENTON_USB: device is busy.

Change the directory of each shell session (and file manager) that is sitting on the path /media/michael/CENTON_USB to something else. Going up one level by 'cd ..' to get to /media/michael is usually the easiest. Then repeat the umount command. Once umount completes (e.g. gives no message at all) do the next command.

{root}
mkdosfs -F 32 -I /dev/sdb1

  • * Check your desktop for the USB drive icon. Right click on it and select Unmount and/or Safely Remove as available.
  • * Remove the USB stick from the computer
  • * Wait a bit (Get more coffee, go to the bathroom, whatever...)
  • * Stick the USB stick back into your computer and let it auto mount again.

{user}
lsblk

Check if "sdb1" has changed and note the NEW auto mount point. In my case /media/michael/CENTON_USB became /media/michael/8714-CEEC . Redo your find & replace and go back to where you where in the main Instructions.

Missing Software (command not found)?

This is for Debian derivatives, you'll need to track down your own otherwise.

{root}
apt-get install syslinux mtools
apt-get install dosfstools

References

How to mount/access a usb flash drive from the terminal?

https://askubuntu.com/a/37775

Creating a bootable Ubuntu USB flash drive from terminal

https://askubuntu.com/a/376430

How To Find The Mounted Filesystem Type In Linux

https://www.ostechnix.com/how-to-find-the-mounted-filesystem-type-in-linux/

How to format a usb drive with FAT32 file system on Linux

https://www.garron.me/en/go2linux/format-usb-drive-fat32-file-system-ubuntu-linux.html

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
You know what to do... An image you see? there is one finger less than two hands of items to find. (We sincerely apologize for using image CAPTCHA, hint go low, and bots suck...)
Image CAPTCHA
Enter the characters shown in the image.