Linux CD: Difference between revisions

From miki
Jump to navigation Jump to search
No edit summary
Line 171: Line 171:


=== Rip an Audio CD ===
=== Rip an Audio CD ===
* '''{{red|NEW}}''' CUERipper, under wine.
* '''{{red|NEW}}''' '''CUERipper''', under wine.
: Faster than EAC. Provide accuterip report. My current preferred method.
: Faster than EAC. Provide accuterip report. My current preferred method.
* Exact Audio Copy, under wine.
* '''Exact Audio Copy''', under wine.
* '''[https://github.com/whipper-team/whipper whipper]''', Linux.
: Using Python3. Never tried.

Revision as of 14:15, 4 April 2020

Links

  • CRC / sha1sum database of many game disc. Useful to check a cd rip.
  • CD rip program (windows only).
  • edccchk — Tool to check ECC/ECD in RAW CD image.
  • Useful to check integrity of a RAW image, making sure there is no error that should be corrected (better correct the errors first before burning the CD).
This guide mainly targets standard ISO9660 CD that can be ripped as ISO image (using dd).
Lots of useful information.
Explains the origin of input/output error when using dd (often due to bad sector in the lead out part, 2s blank at the end of the CD).

Tips

Backup a CDROM

Here a script I use to backup cdrom on Linux, named ripcd.sh.

  • Use cdrdao for raw extraction.
  • extra AUDIO tracks.
  • extra MODE2 tracks.
  • Use 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 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 (rip-cdrdao-raw-sub) does not work. At least, it does not produce same data as CloneCD.
rip-dd
  • The rip-dd function in the script (not used) work around that by extracting only the data part, excludind that lead out track.
  • Note however that rip-cd does not make a complete rip (ignore audio tracks for instance).
#! /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

Convert RAW CD image to ISO

Use raw2iso (original) to convert raw image into iso file.

raw2iso MODE1_RAW < data.bin > data.iso

See help for other parameters.

Rip an Audio CD

  • NEW CUERipper, under wine.
Faster than EAC. Provide accuterip report. My current preferred method.
  • Exact Audio Copy, under wine.
  • whipper, Linux.
Using Python3. Never tried.