A bash script to securely create a bootable USB device from one ISO file

Hi folks. I hope this topic won’t be labeled as “self-promotion” but I just wanted to share bootiso, a script I wrote to safely create a bootable USB from an ISO file.

See it in action:

Try it:

curl -L https://git.io/bootiso -O
chmod +x bootiso

Hope you’ll like it!



That is a good script. As long as it is an open source and related to Linux/Unix I will allow it. HTH

Thanks ! Yes released in MIT license :slight_smile:

1 Like

Well written my friend, I was curious about the ‘trap’, I’ve never used that before. Also do you have a sample command line use you can share with us ?

Thanks for the feeback!

trap bash builtin function executes the provided command when current process receives a signal, in that case INT or TERM (EXIT is a regular exit). A very useful pattern to run cleanup code.

Here are some snippets (from github repo):

Provide the ISO as first argument and you’ll be prompted to select from available USB drives amongst a list extracted from lsblk. If there is only one USB device connected, bootiso will automatically select it:

bootiso myfile.iso

Or provide explicitly the USB device. Command fails and exit if the provided device is not USB, such as sata:

bootiso -d /dev/sde myfile.iso

Add a syslinux bootloader for non-hybrid ISOs:

bootiso -bd /dev/sde myfile.iso

Use dd instead of mount + rsync:

bootiso --dd -d /dev/sde myfile.iso  

List available USB drives and exit:

bootiso -l
1 Like

Any plans to create a persistent usb?

Add an option to create a persistent data partition, close to what unetbootin offers

Thanks for responding. Honestly I have seen and written a lot of scripts and I think yours is probably one of the best I’ve ever seen. I like the use of functions etc… My only minor comment is the main() to me should be all the way down at the bottom because it’s really the logic. I can see why you put it above cleanup etc… though. One other thing, I wonder how hard it would be to have a ‘–dry-run’ option that went through many of the motions or something and printed out issues etc. ?

Anyway, great script, I plan to update some of mine now to meet this standard lol

1 Like

Thanks for the kudos :slight_smile: .

Could you submit a feature request for a --dry-run option?

I will probably refactor to meet your suggestion, quite like it. Btw, I use shellcheck to lint my scripts and I highly recommend it.

Thanks for sharing this info @jsamr very helpful!! :slight_smile:

@dlwilson88 You’re welcome!
BTW, version 3 is out with many improvements :slight_smile:

Notably, it now inspects ISO file to check if it’s hybrid. When it’s not, it checks for UEFI and SYSLINUX boot capabilities. After which, it chooses the best install mode (image copy or mount+rsync) and eventually installs SYSLINUX.

So you basically don’t need to care, just run bootiso myfile.iso and it will work, even with rescue CDs like as UltimateBootCD.