Skip to content

Instantly share code, notes, and snippets.

@WhiteBoardDev
Last active December 20, 2016 03:24
Show Gist options
  • Save WhiteBoardDev/030bbfaf32103c5593937ab69db7ab47 to your computer and use it in GitHub Desktop.
Save WhiteBoardDev/030bbfaf32103c5593937ab69db7ab47 to your computer and use it in GitHub Desktop.
OSX USB Linux Install Disk Creator
#!/bin/bash
echo "##################################"
echo "##"
echo "## Linux bootable USB creator"
echo "## for OSX"
echo "##"
echo "## Needed to run"
echo "## 1. ISO file for the operating system you want to burn to the USB"
echo "##################################"
read -p "do you have an ISO file?...(Y/n)" > IS_ISO_FILE
if [[ $IS_ISO_FILE =~ ^([yY][eE][sS]|[yY])$ ]]
then
read -p "Whats the path to the ISO file? > " ISO_FILE
echo "Creating IMG from ISO...."
rm -f /tmp/dest.img.dmg
hdiutil convert -format UDRW $ISO_FILE -o /tmp/dest.img
echo "Created "
else
rm -f /tmp/dest.img.dmg
read -p "Whats the path to the IMG file? > " IMG_FILE
cp $IMG_FILE /tmp/dest.img.dmg
fi
read -p "Please remove the destination device if inserted and press ENTER" var
echo "Printing disks before inserted"
# Find the SD card / usb location
diskutil list
read -p "Please INSERT the destination device and press ENTER" var
diskutil list
read -p "Enter the Disk # for the device > " DEST_DISK_NUMBER
DEST_DISK=/dev/disk$DEST_DISK_NUMBER
read -p "Going to write to $DEST_DISK press ENTER to continue" var
diskutil unmountDisk $DEST_DISK
echo "going to write $IMG_FILE to $DEST_DISK this may take a few minutes...."
echo "press control-t for a status message...."
sudo dd bs=1m if=/tmp/dest.img.dmg of=/dev/rdisk$DEST_DISK_NUMBER
echo "done!"
echo "adding SSH default file..."
sudo diskutil mountDisk $DEST_DISK
MOUNTED_LOCATION=$(mount | grep $DEST_DISK | awk '{ print $3 }')
touch $MOUNTED_LOCATION/ssh
echo "unmounting disk..."
diskutil unmountDisk $DEST_DISK
@WhiteBoardDev
Copy link
Author

Adding IMG support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment