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.

Revisions

  1. Friz-zy created this gist Jul 2, 2017.
    39 changes: 39 additions & 0 deletions bootable.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    #!/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!"