{"id":13572,"date":"2019-04-03T10:54:33","date_gmt":"2019-04-03T10:54:33","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=13572"},"modified":"2019-04-03T10:54:33","modified_gmt":"2019-04-03T10:54:33","slug":"a-bash-script-to-create-a-bootable-usb-from-iso-in-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/a-bash-script-to-create-a-bootable-usb-from-iso-in-linux\/","title":{"rendered":"A Bash Script to Create a Bootable USB from ISO in Linux"},"content":{"rendered":"<p><strong>Bootiso<\/strong>\u00a0is a powerful Bash script to easily and securely create a bootable USB device from one ISO file. It helps you create a bootable USB from an ISO with a single command from the terminal. It is a well tailored script that carefully organized and validated using\u00a0<a href=\"https:\/\/www.tecmint.com\/shellcheck-shell-script-code-analyzer-for-linux\/\" target=\"_blank\" rel=\"noopener\">shellcheck<\/a>.<\/p>\n<p>It has to be run with root authority, and if external programs it requires are not available on your system, it will ask you to install them and exits. Bootiso checks that the selected ISO has the correct mime-type, otherwise it exits. To prevent system damages, it ensures that the selected device is connected only via USB.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/extract-files-from-iso-files-linux\/\" target=\"_blank\" rel=\"noopener\">3 Ways to Extract and Copy Files from ISO Image in Linux<\/a><\/p>\n<p>Before formating and partitioning your USB device, it prompts you to accept execution of the actions to prevent any data loss. Importantly, it manages any failure from an internal command appropriately exits. In addition, it performs a cleanup of any temporary files on exit by employing the trap utility.<\/p>\n<h3>Install Bootiso Script in Linux<\/h3>\n<p>The easy way to install\u00a0<strong>bootiso<\/strong>\u00a0from sources is to clone the git repository and set execute permission as shown.<\/p>\n<pre>$ git clone https:\/\/github.com\/jsamr\/bootiso.git\r\n$ cd bootiso\/\r\n$ chmod +x bootiso\r\n<\/pre>\n<p>Next, move the script to a bin path (for example\u00a0<strong>~\/bin\/<\/strong>\u00a0or\u00a0<strong>\/usr\/local\/bin\/<\/strong>) to run it like any other Linux commands on your system.<\/p>\n<pre>$ mv bootiso ~\/bin\/\r\n<\/pre>\n<p>Once installed, the syntax for running\u00a0<strong>bootiso<\/strong>\u00a0is to provide the ISO as first argument.<\/p>\n<pre>$ bootiso myfile.iso\r\n<\/pre>\n<p>To create a bootable USB device from ISO file, first you need to list all available USB drives attached to your system using the\u00a0<code>-l<\/code>\u00a0flag as shown.<\/p>\n<pre><strong>$ bootiso -l<\/strong>\r\n\r\nListing USB drives available in your system:\r\nNAME    HOTPLUG   SIZE STATE   TYPE\r\n<strong>sdb           1   14.9G running disk<\/strong>\r\n<\/pre>\n<p>Next, to make the device (<code>\/dev\/sdb<\/code>) as a bootable device, simply provide the ISO as the first argument. Note that if there is only one USB device attached to the system (as in the case above), the script will automatically select it, otherwise, it will ask you to select from an auto-generated list of all attached USB drives.<\/p>\n<pre>$ sudo bootiso <strong>~\/Templates\/eXternOS.iso <\/strong>\r\n<\/pre>\n<div id=\"attachment_29308\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Create-Bootable-USB-in-Linux-Terminal.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29308\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/05\/Create-Bootable-USB-in-Linux-Terminal.png\" alt=\"Create Bootable USB in Linux Terminal\" width=\"762\" height=\"496\" aria-describedby=\"caption-attachment-29308\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29308\" class=\"wp-caption-text\">Create Bootable USB in Linux Terminal<\/p>\n<\/div>\n<p>You may also use the\u00a0<code>-a<\/code>\u00a0flag to enable autoselecting USB drives in conjunction with\u00a0<code>-y<\/code>\u00a0(disables prompting user before formating USB drive) option as shown.<\/p>\n<pre>$ sudo bootiso -a -y ~\/Templates\/eXternOS.iso\r\n<\/pre>\n<p>If you have multiple USB devices connected to the system, you can use the\u00a0<code>-d<\/code>\u00a0flag to explicitly specify the USB device you want to make bootable from the command line as shown.<\/p>\n<pre>$ sudo bootiso -d \/dev\/sdb ~\/Templates\/eXternOS.iso  \r\n<\/pre>\n<p>By default, bootiso uses\u00a0<code>mount + rsync<\/code>\u00a0to employ\u00a0<strong>dd command<\/strong>\u00a0instead, add the\u00a0<code>--dd<\/code>\u00a0flag as shown.<\/p>\n<pre>$ sudo bootiso --dd -d ~\/Templates\/eXternOS.iso      \r\n<\/pre>\n<p>In addition, for non-hybrid ISOs, you can install a bootloader with syslinux with the\u00a0<code>-b<\/code>\u00a0option, as follows. This option however does not support the\u00a0<strong>dd command<\/strong>.<\/p>\n<pre>$ sudo bootiso -b \/ptah\/to\/non-hybrid\/file.iso\r\nOR\r\n$ sudo bootiso -bd \/usb\/device \/ptah\/to\/non-hybrid\/file.iso\r\n<\/pre>\n<p>For more information on other bootiso capabilities and options, see the help message.<\/p>\n<pre>$ bootiso -h  \r\n<\/pre>\n<p><strong>Bootiso Github repository<\/strong>:\u00a0<a href=\"https:\/\/github.com\/jsamr\/bootiso\" target=\"_blank\" rel=\"nofollow noopener\">https:\/\/github.com\/jsamr\/bootiso<\/a><\/p>\n<p>That\u2019s It!\u00a0<strong>Bootiso<\/strong>\u00a0is a powerful Bash script to 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.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/create-bootable-usb-in-linux-commandline\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Bootiso\u00a0is a powerful Bash script to easily and securely create a bootable USB device from one ISO file. It helps you create a bootable USB from an ISO with a single command from the terminal. It is a well tailored script that carefully organized and validated using\u00a0shellcheck. It has to be run with root authority, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/04\/03\/a-bash-script-to-create-a-bootable-usb-from-iso-in-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;A Bash Script to Create a Bootable USB from ISO in Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13572","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13572","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=13572"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13572\/revisions"}],"predecessor-version":[{"id":13573,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/13572\/revisions\/13573"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=13572"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=13572"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=13572"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}