Last active
August 29, 2015 13:58
-
-
Save geekgonecrazy/10392619 to your computer and use it in GitHub Desktop.
Create USB from ISO
This file contains 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/bash | |
if [ "$(id -u)" != "0" ]; then | |
echo "This script must be run as root" 1>&2 | |
exit 1 | |
fi | |
if [ ! -z "$1"] && [ ! -z "$2" ]; then | |
echo "Usage: ./makeUSB /path/file.iso /dev/sdx" | |
exit 1 | |
fi | |
ISOIMAGE=$1 | |
DEVICE=$2 | |
read -p "Press [Enter] to start writing to $DEVICE" | |
(echo o; echo n; echo p; echo 1; echo ; echo ; echo w) | fdisk $DEVICE | |
mkfs -t vfat $DEVICE1 | |
mkdir -p /mnt/flash | |
mount -t vfat $DEVICE1 /mnt/flash | |
syslinux -s $DEVICE | |
mkdir -p /mnt/iso | |
mount -o loop $ISOIMAGE /mnt/iso | |
cp -R /mnt/iso/isolinux/* /mnt/flash | |
mv /mnt/flash/isolinux.cfg /mnt/flash/syslinux.cfg | |
cp $ISOIMAGE /mnt/flash | |
install-mbr /dev/$DEVICE | |
umount /mnt/flash | |
umount /mnt/iso | |
rm -rf /mnt/flash | |
rm -rf /mnt/iso | |
echo "Done.." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment