Skip to content

Instantly share code, notes, and snippets.

@Friz-zy
Created July 2, 2017 20:42
Show Gist options
  • Save Friz-zy/15b77a1b05a9d44b08c25d3d0e210ec6 to your computer and use it in GitHub Desktop.
Save Friz-zy/15b77a1b05a9d44b08c25d3d0e210ec6 to your computer and use it in GitHub Desktop.
Script for extracting linux bootable iso into usb drive
#!/bin/sh
usage ()
{
echo 'Usage : bootable.sh <path to iso> <device for install like /dev/sdb>'
echo 'This script install linux bootable iso into first partition of your usb flash drive'
echo 'You need root privileges for run this script'
exit 0
}
if [ `id -u` = 0 ]
then
usage
fi
if [ "$#" -ne 2 ]
then
usage
fi
mkdir /mnt/iso
mkdir /mnt/flash
echo "Mounting $1 into /mnt/iso"
mount -o loop $1 /mnt/iso
echo "Mounting "$2"1 into /mnt/flash"
mount "$2"1 /mnt/flash
echo "Copying data from iso into flash"
cp -a /mnt/iso/. /mnt/flash
echo "Installing grub into flash"
grub-install --removable --boot-directory=/mnt/flash/boot --efi-directory=/mnt/flash/EFI/BOOT $2
umount /mnt/iso
umount /mnt/flash
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment