Skip to content

Instantly share code, notes, and snippets.

@macowie
Created December 27, 2022 17:32
Show Gist options
  • Save macowie/dfb31c9e5bf650dbd01e3d34d4a30b1a to your computer and use it in GitHub Desktop.
Save macowie/dfb31c9e5bf650dbd01e3d34d4a30b1a to your computer and use it in GitHub Desktop.
Copy disc to ISO
#! /bin/sh
set -e
# Copy disc to ISO script. I believe everyone has to write one of these at some point
input=${1:-/dev/sr0}
info=$(isoinfo -d -i $input)
volume_id=$(echo "$info" | awk '/Volume id/' | awk '{print $NF}')
sector_size=$(echo "$info" | awk '/block size/' | awk '{print $NF}')
sector_count=$(echo "$info" | awk '/Volume size/' | awk '{print $NF}')
output=${2:-$volume_id.iso}
output=${output:-discimage.iso}
echo -e "Backing up $input to $output...\n"
dd if=$input of=$output bs=$sector_size count=$sector_count status=progress
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment