Make an ISO from a CD

apt install -y genisoimage gddrescue

DISK=/dev/sr0

# 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 ./img.map

# 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 ./img.map