Make an ISO from a CD

apt install -y genisoimage gddrescue


# get the disk's dimensions
BLK_SIZE=$(isoinfo -d -i ${DISK} | sed -rne '/^Logical block size is: /{s/^.+: ?//;p;q}')
VOL_SIZE=$(isoinfo -d -i ${DISK} | sed -rne '/^Volume size is: /{s/^.+: ?//;p;q}')
echo "${BLK_SIZE} * ${VOL_SIZE} = $(( ${BLK_SIZE} * ${VOL_SIZE} )) bytes"

# Old CDs can be problematic... use ddrescue over dd for an easier time
ddrescue -Ou -r 0 -b ${BLK_SIZE} -c 1 -s $(( ${BLK_SIZE} * ${VOL_SIZE} )) ${DISK} ./img.iso ./

# if you have issues, you can try again, with the following
# add -A to retry all
# add -M to retrim all
ddrescue -Ou -r 100 -b ${BLK_SIZE} -c 1 -s $(( ${BLK_SIZE} * ${VOL_SIZE} )) ${DISK} ./img.iso ./