#!/bin/bash echo "=== make_stick.sh ===" echo "copy 1:1 image.iso to (hopefully bootable) usb stick" echo "(some usb sticks can not boot)" echo "first parameter: the drive to write to in the format /dev/sdx" echo "second parameter: the image.iso" if [ -z "$1" ] then echo "please pass device like this: /dev/sdx TARGET THE WHOLE DEVICE (sdb) NOT A PARTITION! (sdb1)" else echo "" echo "please read carefully, a mistake could overwrite critical data" echo "physically disconnect all critical data-drives before procedure" echo "" echo "========== do you want to copy the $2 image on device $1 ?" echo "" echo "=========== harddisk overview"; echo "==== where is what"; lsblk -o 'NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,MOUNTPOINT,UUID' echo "==== harddisk usage"; df -Th; echo "" echo "==== info about this specific harddisk:"; hdparm -I $1 | grep Model echo "" read -p "Continue (y/n)?" choice case "$choice" in y|Y ) echo "yes";; n|N ) echo "no";; * ) echo "invalid";; esac umount $1*; dd if=$2 of=$1 status=progress; sync; # if the image.iso.gz is compressed, unpack on the fly ## multi core ### pigz -dc /media/user/EXTERNALHARDDISK/software/iso/IdealLinux/IdealLinux2021.usb.stick.img.gz | pv | dd bs=1M of=$1; # write image to usb stick ## single core ### gunzip -c /run/media/user/SOFTWARE/LINUX/ideal-linux-stick/ideal-linux-usb_stick_image_full_16GByte_2017-04.img.gz | pv | dd of=$1; # write image to usb stick echo "the image $2 was written to stick $1. process finished. try booting it now :)" fi