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.
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 ?
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:
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
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.