Git Product home page Git Product logo

bootiso's Introduction

License: MIT Version Codacy grade
GitHub open bugs GitHub closed bugs GitHub enhancement issues GitHub enhancement issues

Create a USB bootable device from an ISO image easily and securely.

Don't want to messup the system with dd command? Create a bootable USB from an ISO in one line [see it in action].

Works seamlessly with hybrid and non-hybrid ISOs (SYSLINUX or UEFI compliant) such as any linux ISO, Windows ISO or rescue live-cds like UltimateBootCD. You don't have to tweak anything: bootiso inspects the ISO file and chooses the best method to make your USB bootable.

Synopsis

bootiso [<options>...] <file.iso>
bootiso <action> [<options>...] <file.iso>
bootiso <action> [<options>...]

The default action [install-auto] as per first synopsis is to install an ISO file to a USB device in automatic mode. In such mode, bootiso will analyze the ISO file and select the best course of actions to maximize the odds your USB stick be proven bootable (see automatic mode behavior).
Other <options> and <actions> are listed in this bellow section.

Examples

To have a quick feedback, [probe] around to check bootiso capabilities with given ISO file and list USB drives candidates [watch video]:

bootiso -p myfile.iso

With the default action [install-auto] [read its detailed behavior here], give 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 with -d flag. Command fails and exit if the provided device is not USB, such as sata [watch video]:

bootiso -d sde myfile.iso

Avoid being promtped before writting to USB drive and autoselect device when there is exactly one [watch video]:

bootiso -ay myfile.iso

List available USB drives and exit:

bootiso -l

[inspect] the given ISO file and exit:

bootiso -i myfile.iso

Quick-[format] the USB drive to NTFS and label it 'SAMUEL_SONY':

bootiso -f -t ntfs -L 'SAMUEL_SONY'

Go to the flags section to see the full list of actions and options.

Quick install

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

Optionally, move the script to a bin path

mv bootiso <bin-path>

Where bin-path is any folder in the $PATH environment, preferably for superuser utilities such as /usr/local/sbin/.

Make sure to follow our distro-dependent tweaks to have bootiso settled.

Help the community

If you like bootiso, feel free to help the community find it by staring the project and upvoting those SE posts:

Probing

--probe (shorten -p) gives you details about ISO boot capabilities and list available USB drives.

Using --assume-yes + --autoselect

--assume-yes (shorten -y) bypass prompting the user for overwritting USB device, and --autoselect (shorten -a) allow automatic selection of USB device when exactly one device is connected in combination with --assume-yes.

No-USB device failure

In the bellow example, the selected device with --device (shorten -d) flag is not connected through USB and bootiso fails.

Note that short POSIX flags can be stacked as of v2.4.0, like so: bootiso -Jaybd /dev/sde

Actions

Action
(POSIX short) 

Action
(GNU, long)
                                               
Description Requires root
[install-auto]: Default action. Install ISO file in automatic mode. yes
-h --help [help]: Display a help message and exit. no
-v --version [version]: Display version and exit. no
-l --list-usb-drives [list-usb-drives]: List available USB drives. no
-i --inspect [inspect]: Inspect ISO file boot capabilities and how bootiso can handle it, and check against a hash file if exists, then exit. yes
-p --probe [probe]: Equivalent to [inspect] followed by [list-usb-drives] actions. yes
-f --format [format]: Format USB drive. yes
--dd [install-dd]: Overrides "automatic" mode and install ISO in image-copy mode with dd utility. It is recommended to run [inspect] action first. yes
--mrsync [install-mount-rsync]: Overrides "automatic" mode and install ISO in mount-rsync mode with rsync utility. It is recommended to run [inspect] action first. yes
Option
(POSIX short) 

Option
(GNU, long)
                                               
Description Applicable actions
                                                    
-d <device> --device <device> Select <device> block file as USB device. If <device> is not connected through a USB bus, bootiso will fail and exit. Device block files are usually situated in /dev/sXX or /dev/hXX. You will be prompted to select a device if you don't use this option. You can omit `/dev/` prefix. [install-*],
[format]
-y --assume-yes bootiso won't prompt the user for confirmation before erasing and partitioning USB device. Use at your own risks. [install-*],
[format]
-a --autoselect Enable autoselecting USB devices in combination with -y option. Autoselect will automatically select a USB drive device if there is exactly one connected to the system. Enabled by default when neither -d nor --no-usb-check options are given. [install-*],
[format]
-J --no-eject Do not eject device after unmounting. [install-*]
-H --no-hash-check Do not search for hash files and check ISO integrity. [install-*],
[inspect],
[probe]
-M --no-mime-check bootiso won't assert that selected ISO file has the right mime-type. [install-*]
-t <type> --type <type> Format to <type> instead of default FAT32 (vfat). Supported types: vfat exfat ntfs ext2 ext3 ext4 f2fs. [install-mount-rsync],
[format]
-L <label> --label <label> Set partition label as <label> instead of inferring. bootiso will cut labels which are too long regarding the selected filesystem limitations. [install-mount-rsync],
[format]
-- POSIX end of options. [install-*],
[inspect],
[probe]
--no-usb-check bootiso won't assert that selected device is connected through USB bus. Use at your own risks. [install-*],
[format]
--no-size-check Prevent script from asserting that the device size is larger then the image. [install-*]
--no-wimsplit Prevent splitting sources/install.wim file in Windows ISOs. [install-*]
--hash-file <file> Specify file containing the ISO hash. Other files will not be checked. [install-*],
[inspect],
[probe]
--force-hash-check Fail and exit when no valid hash is found. [install-*]
--local-bootloader Prevent download of remote bootloader and force local (SYSLINUX) during installation. [install-mount-rsync],
[install-auto]
--remote-bootloader <version> Force download of remote bootloader at version <version>. Version must follow the pattern MAJOR.MINOR. Examples: 4.10, 6.04. [install-mount-rsync],
[install-auto]
-b --bootloader Removed in v3.0.0. SYSLINUX installation is now automated.

bootiso inspects ISO file to find the best strategy resulting in a booting USB stick
bootiso check the ISO file hash sum against a hash file if one found. Supported hash algorithms are md5, sha1, sha256 and sha512. ✔ bootiso asserts that selected ISO has the correct mime-type and exit if it doesn't (with file utility).
bootiso asserts that selected device is connected through USB preventing system damages and exit if it doesn't (with udevadm utility).
bootiso asserts that selected item is not a partition and exit if it doesn't (with lsblk).
bootiso asserts that selected image is not larger than selected device.
bootiso prompts the user for confirmation before erasing and paritioning USB device.
bootiso will handle any failure from a command properly and exit.
bootiso will call a cleanup routine on exit with trap.
bootiso is being carefully linted and validated with shellcheck (see code quality status from codacy) and formatted with shfmt.

This script will also check for dependencies and prompt user for installation (works with apt-get, yum, dnf, pacman, zypper, emerge).

With default [install-auto] action, bootiso will inspect the ISO file and choose the best strategy to end up with a bootable USB stick.
99% of the time, you shouldn't enforce any strategy and let bootiso choose.

The main decision is to pick up image-copy or mount+rsync modes. In image-copy dd mode (enforcable with [install-dd] action, --dd flag), bootiso uses dd utility to make a raw copy of the ISO. This is perfectly appropriate when the ISO file is aimed both at disk drives and CDs. Those ISO are called hybrids.

In mount+rsync mode (enforcable with [install-mount-rsync] action, --mrsync flag), bootiso creates one partition with MBR table in the USB drive and copy files from mounted ISO. It will also install SYSLINUX bootlaoder if configuration files are found, which will allow legacy BIOS boot. When local version doesn't match ISO version, it will attempt to download the closest version available in kernel.org if --local-bootloader flag is not set.

Environment variables and distro-specific tweaks

Variables

  • SYSLINUX_LIB_ROOT: set syslinux assets root, where mbr will be searched.
  • On Fedora, set SYSLINUX_LIB_ROOT env to /usr/share/syslinux

Credits

This script was made after this askubuntu post answer from Avinash Raj to automate the described steps in a robust, secured way (see the security section for more details).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.