Giter Club home page Giter Club logo

bootiso's Introduction

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

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

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

Synopsis

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

With <options> listed in the bellow section.

Examples

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  

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 such as $HOME/bin.

Help the community

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

See it in action

Using --assume-yes + --autoselect

The selected device is not connected through USB

Options

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

Option
(POSIX short) 

Option
(GNU, long)
                                               
Description
-h --help Display a help message and exit.
-v --version Display version and exit.
-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.
-b --bootloader Install a syslinux bootloader (safe mode) for non-hybrid ISOs. Does not work with --dd option.
-y --assume-yes bootiso won't prompt the user for confirmation before erasing and partitioning USB device. Use at your own risks.
-a --autoselect Enable autoselecting USB devices in conjunction 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.
-J --no-eject Do not eject device after unmounting.
-l --list-usb-drives List available USB drives.
-M --no-mime-check bootiso won't assert that selected ISO file has the right mime-type.
-s --strict-mime-check Disallow loose application/octet-stream mime type in ISO file.
-- POSIX end of options.
--dd Use dd utility instead of mounting + rsync. Does not allow bootloader installation with syslinux.
--no-usb-check bootiso won't assert that selected device is a USB (connected through USB bus). Use at your own risks.

Security checks and robustness

✔ 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 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).

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

What it does

This script walks through the following steps:

  1. Request sudo.
  2. Check dependencies and prompt user to install any missing.
  3. If not given the -M, --no-mime-check option, assert that provided ISO exists and has the expected application/x-iso9660-image mime-type via file utiltiy. If the assertion fails, exit with error status.
  4. If given the -d, --device option, check that the selected device exists and is not a partition. Otherwise, prompt the user to select a device and perform the above-mentioned controls.
  5. If not given the --no-usb-check option, assert that the given device is connected through USB via udevadm utility. If the assertion fails, exit with error status.
  6. If not given the -y, --assume-yes option, prompt the user for confirmation that data might be lost for selected device if he goes to next step.
  7. Unmount the USB if mounted, blank it and delete existing partitions.
  8. Create a FAT32 partition on the USB device.
  9. Create a temporary dir to mount the ISO file and mount it.
  10. Create a temporary dir to mount the USB device and mount it.
  11. Copy files from ISO to USB device.
  12. If option -b, --bootloader is selected, install a bootloader with syslinux in slow mode.
  13. Unmount devices and remove temporary folders.
  14. Eject USB device if -J, --no-eject is not selected

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).

bootiso's People

Contributors

codacy-badger avatar jsamr avatar

Watchers

 avatar  avatar

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.