Last active
March 9, 2025 13:37
-
-
Save Nidal-Bakir/458b8f4a006265309021620404018a23 to your computer and use it in GitHub Desktop.
Make bootable USB using dd command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # MIT License | |
| # | |
| # Copyright (c) 2025 Nidal Bakir | |
| # | |
| # Permission is hereby granted, free of charge, to any person obtaining a copy | |
| # of this software and associated documentation files (the "Software"), to deal | |
| # in the Software without restriction, including without limitation the rights | |
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
| # copies of the Software, and to permit persons to whom the Software is | |
| # furnished to do so, subject to the following conditions: | |
| # | |
| # The above copyright notice and this permission notice shall be included in all | |
| # copies or substantial portions of the Software. | |
| # | |
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | |
| # SOFTWARE. | |
| # | |
| iso_path="" | |
| flash_mount_point="" # e.g: /dev/sdb1 use lsblk to know for sure! | |
| Help() { # Display Help | |
| echo "make bootable usb using dd command." | |
| echo "Please use this script with extra care, it may delete all your data or currupt your system." | |
| echo | |
| echo "Syntax: makeBootable <-f <path> -o <path> >|-h " | |
| echo "options:" | |
| echo " -f path to iso file." | |
| echo " -o path to usb mount point. hint: use lsblk to know the mounting point." | |
| echo " -h print this help message." | |
| echo | |
| } | |
| # Get the options | |
| while getopts :f:o:h option; do | |
| case $option in | |
| f) # path to iso file | |
| iso_path=$OPTARG | |
| ;; | |
| o) # flash mount point | |
| flash_mount_point=$OPTARG | |
| ;; | |
| h) # dispaly help message | |
| Help | |
| exit;; | |
| \?) # Invalid option | |
| echo "Error: Invalid option" | |
| exit;; | |
| esac | |
| done | |
| [ -z "$iso_path" ] && echo " error iso path empty." && exit | |
| [ -z "$flash_mount_point" ] && echo " error flash mount empty." && exit | |
| dd bs=4M if=$iso_path of=$flash_mount_point conv=fdatasync status=progres |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment