Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
# You want to create a bootable Linux USB thumdrive. But you don’t have the current ISO in hand.
# This script will download the ISO to the current directory while burning it to your USB device at the same time.
# You can use this script to write an ISO to the USB drive directly from the Internet, and having a copy of the actual ISO in your current directory.
# Sample one-liner for the same job:
# wget -O - http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-i386/current/images/netboot/mini.iso | tee mini32-1.iso > mini32-2.iso
function usage {
mybasename=$(basename $0)
echo "
Usage: $mybasename URL DEVICENAME
URL : URL of the ISO file
DEVICEPATH : Path for the usb device
Example:
$mybasename http://archive.ubuntu.com/ubuntu/dists/devel/main/installer-amd64/current/images/netboot/mini.iso /dev/sdx
You can learn the DEVICEPATH of your USB drive by using one of the commands below:
1. lsblk -o MODEL,NAME,FSTYPE,LABEL,UUID,MOUNTPOINT
2. blkid
3. sudo fidsk -l
4. sudo parted -ls
"
exit 1
}
if [ $# -lt 2 ]
then
echo "Error: Not enough arguments supplied!"
usage
fi
URL=$1
DEVICE=$2
FILE=$(basename $URL)
echo "URL : $URL"
echo "FILENAME : $FILE"
echo "DEVICE : $DEVICE"
wget -O - $URL | tee $FILE > $DEVICE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.