A Bash Script to Create a Bootable USB ISO Linux
Another Day! A new tutorial to help my fellow guys: Are you struggling to learn how to Create a Bootable USB Linux, Let’s have A Bash Script method for you in this tutorial.
Check out Our Best VPS Hosting for scaling your cloud-based applications and processes.
Boot ISO File
Boot iso is very a strong Bash script that easily and securely creates a bootable USB device from one ISO file. This will help you create a bootable USB from an ISO using a single command from the terminal. It is a carefully tailored script which ensures organized and validated execution using shellcheck.
It has to run with root authority, and if it requires external programs that are not available on your system, it will ask you to install them and exit. Bootiso checks that the selected ISO has the correct mime type, otherwise it will exit. To prevent system damage, the script makes sure that the selected device is connected only via USB.
Before you format and partition your USB, Bootiso asks you to accept execution of the actions to prevent any data loss. Importantly, it manages any failure from an internal command and appropriately exits. In addition, it performs a cleanup of any temporary files upon exit by employing the trap utility.
Create a Bootable USB Linux
An easy way to install Bootiso from source code is to clone the git repository and execute permissions as shown below:
git clone https://github.com/jsamr/bootiso.git cd bootiso/ chmod +x bootiso
Next, we are going to move the script to a bin path (for example ~/bin/ or /usr/local/bin/) to run it like any other Linux command on your system.
mv bootiso ~/bin/
After it’s installed, the syntax for running Bootiso is to provide the ISO as the first argument.
In order to create a bootable USB device from the ISO file, first you have to list every available USB drive attached to your system using the –I flag as follows:
Listing USB drives available in your system: NAME HOTPLUG SIZE STATE TYPE sdb 1 14.9G running disk
Next, if you want to make the device /dev/sdb into a bootable device, just provide the ISO as the first argument. Keep in mind that if there is only one USB device attached to the system (as in the case above), the script should automatically select it, otherwise, it is going to ask you to select from an auto-generated list of all attached USB drives.
sudo bootiso ~/Templates/eXternOS.iso
You could also use the –a flag to enable autoselecting of USB drives in conjunction with the –y (disables prompting user before formatting USB drive) option as shown.
sudo bootiso -a -y ~/Templates/eXternOS.iso
If you have a few USB devices connected to the system, you could use the –d flag to explicitly specify the USB device you’d like to make bootable from the command line, as shown:
sudo bootiso -d /dev/sdb ~/Templates/eXternOS.iso
By default, Bootiso uses mount + rsync. To employ the dd command instead, add the –dd flag as shown.
sudo bootiso --dd -d ~/Templates/eXternOS.iso
In addition, for non-hybrid ISOs, you can install a bootloader with syslinux using the -b option, as follows. This option, however, does not support the dd command.
sudo bootiso -b /ptah/to/non-hybrid/file.iso
sudo bootiso -bd /usb/device /ptah/to/non-hybrid/file.iso
For more information on other Bootiso capabilities and options, see the help message.
Bootiso Github repository: https://github.com/jsamr/bootiso
That’s it! Bootiso is a powerful Bash script to help you easily and securely create a bootable USB device from one ISO file with a single command on the terminal. Use the comment form below to share your thoughts about it or ask questions.
Also, here are a few hand-picked guides that must read next:
Do let us know if you want to add any specific Linux or Windows hosting topics into this tutorial series.