Scenario / Questions

I’m having trouble figuring out how I would write an ISO disk image to a USB flash memory device from the command line in Ubuntu. I have the Startup Disk Creator utility, but I need to be able to script this job.

I found the usb-creator package, but there doesn’t seem to be any documentation and python -m usbcreator gives usbcreator is a package and cannot be directly executed.

I looked at unetbootin, but it seems like another GUI-only utility.

Is there some obvious solution which I’m overlooking?

Find below all possible solutions or suggestions for the above questions..

Suggestion: 1

I know you can do this in UNetbootin gui.
I haven’t tried it myself, but it looks like you can do it by command-line, as well:

unetbootin method=diskimage isofile=”my.iso” installtype=USB targetdrive=/dev/sdc1

Suggestion: 2

Are you sure if the ISO image will work on a USB device? Some ISOs which will boot if they are on a CD/DVD will not actually boot from a USB device.

Assuming the ISO you want has a bootloader that will work, then it should be as simple as dd if=filename.iso of=/dev/usbdevice but this will replace anything that is currently on the USB disk.

If you wanted to place the ISO onto an existing filesystem on the USB drive and boot it, then setting it up may be a lot more complicated.

Suggestion: 3

From Linux there’s a very easy way to create a bootable memory stick from an ISO image — and this should work for any OS. Assuming the memory stick is /dev/sdb and the image is /home/username/Downloads/system.iso.

Just do this (as root):

dd if=/home/username/Downloads/system.iso of=/dev/sdb

Much easer than unetbootin or any other method I’ve heard of.

Suggestion: 4

I use the following procedure:

1. Reading the block size and the volume size:

[root@testserver ~]# isoinfo -d -i /path_to_iso | grep -i -E 'block size|volume size' 
Logical block size is: 2048
Volume size is: 327867

2. Running dd with the parameters for block size and volume size:

root@testserver ~]# dd if=/path_to_iso of=/dev/your_usb_device bs=block-size-from-above count=volume-size-from-above