Linux cdrom: Difference between revisions

From miki
Jump to navigation Jump to search
(Redirected page to Linux CD)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
#REDIRECT [[Linux CD]]
== Tips ==
=== Backup cdrom ===
Here a script I use to backup cdrom on Linux, named {{file|ripcd.sh}}.
* Use '''cdrdao''' for raw extraction.
:* extra AUDIO tracks.
:* extra MODE2 tracks.
* Use [https://github.com/claunia/edccchk edccchk] to check ECC/ECD on raw image
:* Make sure raw image has no ECC/ECD warning/error (if so, better extract ISO to have errors corrected).
* Use [https://github.com/xeyownt/raw2iso raw2iso] ([https://github.com/not-a-user/raw2iso original]) to convert raw image into iso file.
* Compare files on ISO with those on cdrom.

;Limitations:
* Note that some CD may have extraction errors in the 2s lead out (150 last sectors). This is normal.
* Sub-channel extraction (<code>rip-cdrdao-raw-sub</code>) does not work. At least, it does not produce same data as CloneCD.

;rip-dd
* The <code>rip-dd</code> function in the script (not used) work around that by extracting only the data part, excludind that lead out track.
* Note however that <code>rip-cd</code> does not make a complete rip (ignore audio tracks for instance).

<source lang="bash">
#! /bin/bash
#
# ./ripcd.sh [--sub] image_name

unset SUB
NAME="$1"
if [ "$NAME" = "--sub" ]; then
SUB=sub
shift
NAME="$1"
fi
if [ -z "$NAME" ]; then
echo "Usage: ripcd.sh [--sub] image_name"
exit 1
fi

MNT1=/mnt/any
MNT2=/mnt/cdrom
DEV=/dev/cdrom

cmd=$(basename "$0")

die()
{
echo "cmd -- ERROR: $@" >&2
exit 1
}

rip-dd()
{
isoinfo -d -i $DEV

# Reading block size/count - rawread http://www.troubleshooters.com/linux/coasterless.htm
BLOCKSIZE=`isoinfo -d -i $DEV | grep "^Logical block size is:" | cut -d " " -f 5`
[ -n "$BLOCKSIZE" ] || die Blank blocksize

BLOCKCOUNT=`isoinfo -d -i $DEV | grep "^Volume size is:" | cut -d " " -f 4`
[ -n "$BLOCKCOUNT" ] || die Blank blockcount

mkdir "$NAME"
echo "Ripping cd to '$NAME/$NAME.iso' (${BLOCKCOUNT}x${BLOCKSIZE} bytes)"
sudo dd if=$DEV of="$NAME/$NAME.iso" bs=$BLOCKSIZE count=$BLOCKCOUNT conv=notrunc,noerror
}

rip-cdrdao-raw()
{
mkdir "$NAME"
pushd "$NAME"
echo "Ripping cd to '$NAME/$NAME.bin' (cdrdao-raw)"
cdrdao read-cd --device $DEV --read-raw --datafile "$NAME.bin" -v 2 "$NAME.toc"
# Note: Convert .bin to .iso using https://github.com/not-a-user/raw2iso (or ccd2iso)
popd
}

rip-cdrdao-raw-sub()
{
# Not working properly? sub-channel not the same as extracted by clonecd

mkdir "$NAME"
pushd "$NAME"
echo "Ripping cd to '$NAME/$NAME.bin+sub' (cdrdao-raw-sub)"
cdrdao read-cd --device $DEV --read-raw --read-subchan rw_raw --datafile "$NAME.bin+sub" -v 2 "$NAME.toc+sub"
echo "Reading normal TOC"
cdrdao read-toc --device $DEV --read-raw --datafile "$NAME.bin" -v 2 "$NAME.toc"
# Separate RAW and SUB data
# raw2iso - https://github.com/not-a-user/raw2iso
TYPE=$(egrep -o '(MODE1_RAW|MODE1|MODE2_RAW|MODE2_FORM1|MODE2_FORM2|MODE2_FORM_MIX)' "$NAME.toc+sub")
echo "Extracting RAW from type $TYPE"
raw2iso $TYPE RW_RAW RAW < $NAME.bin+sub > $NAME.bin
echo "Extracting SUBCHANNEL from type $TYPE"
raw2iso $TYPE RW_RAW SUB < $NAME.bin+sub > $NAME.sub
rm $NAME.bin+sub
# Note: Convert .bin to .iso using https://github.com/not-a-user/raw2iso (or ccd2iso)
popd
}

check-raw()
{
pushd "$NAME"

echo "Checking EDC/ECC in RAW image."
# edccchk - https://github.com/claunia/edccchk
edccchk "$NAME.bin"

TYPE=$(egrep -o '(MODE1_RAW|MODE1|MODE2_RAW|MODE2_FORM1|MODE2_FORM2|MODE2_FORM_MIX)' "$NAME.toc")
echo "Converting RAW image (type $TYPE) to ISO"
# raw2iso - https://github.com/not-a-user/raw2iso
raw2iso $TYPE < $NAME.bin > $NAME.iso

echo "Comparing files on ISO image with CDROM..."
sudo mkdir -p $MNT1 $MNT2
sudo mount -o loop "$NAME.iso" $MNT1
sudo mount /dev/cdrom $MNT2
diff -r $MNT1 $MNT2
sudo umount $MNT1 $MNT2

rm $NAME.iso
popd
}

rip-cdrdao()
{
mkdir "$NAME"
pushd "$NAME"
echo "Ripping cd to '$NAME/$NAME.iso' (cdrdao-raw)"
cdrdao read-cd --device $DEV --datafile "$NAME.iso" -v 2 "$NAME.toc"
popd
}

check()
{
echo "Verifying..."
sudo mkdir -p $MNT1 $MNT2
sudo mount /dev/cdrom $MNT2
sudo mount -o loop "$NAME/$NAME.iso" $MNT1
diff -r $MNT1 $MNT2
sudo umount $MNT1 $MNT2
}

# Updat sudo credentials
sudo -v

[ -n "$SUB" ] && rip-cdrdao-raw-sub || rip-cdrdao-raw
# rip-cdrdao

check-raw
# check
</source>

Latest revision as of 14:13, 4 April 2020

Redirect to: