Skip to content

Instantly share code, notes, and snippets.

@geekgonecrazy
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save geekgonecrazy/10392619 to your computer and use it in GitHub Desktop.
Save geekgonecrazy/10392619 to your computer and use it in GitHub Desktop.
Create USB from ISO
#!/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