raw2iso
raw2iso copied to clipboard
Convert raw optical disk images to iso files
raw2iso - Convert raw optical disk images to .iso files
Compiling
The tool is contained in a single .c file, and should compile and
run in any reasonable environment that comes with a C99 compiler and
standard library. If it does not, please file an issue.
Windows binaries can be found in the releases section.
Compiler command line example
cc -o raw2iso raw2iso.c
Depending on your compiler version, additional switches such as
-std=c99 may be required.
Compile directly from GitHub - no git clone or tarball required
curl https://raw.githubusercontent.com/not-a-user/raw2iso/master/raw2iso.c | cc -x c -o raw2iso -
Usage
raw2iso <track-mode> [<sub-channel-mode>] < INPUT.BIN > OUTPUT.ISO
<track-mode>:MODE1_RAW|MODE1|MODE2_RAW|MODE2_FORM1|MODE2_FORM2|MODE2_FORM_MIX<sub-channel-mode>:RW|RW_RAW
Note: Error correction/detection data is not checked (try edccchk) and errors are not corrected. (It is unlikely that an image contains this type of errors, because CIRC detects/corrects errors when reading from the disk - even in raw mode.)
How to determine the image type (track mode and sub-channel mode)
Common extensions for raw image files are .raw, .bin, .img,
.ima, and others.
If you have an accompanying .toc file
The track mode and sub-channel mode can be found in the .toc file. See
cdrdao(1) -> TOC FILES ->
Track Specification -> TRACK.
Note: MODE1 and MODE2_FORM1 images without sub-channel data need
no conversion. These images are .iso files.
If you have an accompanying .cue file
MODE1/2048: No conversion is necessary. The image is an.isofile.MODE1/2352: UseMODE1_RAW.MODE2/2336: UseMODE2_FORM_MIX.MODE2/2352: UseMODE2_RAW.
By looking at the file size
Check if the file size is a multiple of one or more of the following sector sizes:
- 2048 bytes: The image might be an
.isofile. - 2324 bytes: Try
MODE2_FORM2. - 2336 bytes: Try
MODE2_FORM_MIX. - 2352 bytes: Try
MODE1_RAWorMODE2_RAW.
If sub-channel data is present, the sector size is increased by 96 bytes:
- 2144 bytes: Try
MODE1 RW. - 2420 bytes: Try
MODE2_FORM2 RW. - 2432 bytes: Try
MODE2_FORM_MIX RW. - 2448 bytes: Try
MODE1_RAW RWorMODE2_RAW RW.
Example - Create an .iso using cdrdao
Motivation
The standard method
dd if=/dev/cdrom of=image.iso bs=2048
can fail for various reasons.
Step by step
Get cdrdao. (Windows users can get pre-compiled binaries
here.)
Then make a raw image of the disk:
cdrdao read-cd --read-raw --datafile image.bin image.toc
Look for the first TRACK line in the image.toc file to find out
which track mode to use. Then run raw2iso with the correct mode. The
following line automates these steps:
sh -c "raw2iso $(grep '^TRACK ' image.toc | head -1 | cut -d ' ' -f 2-) < image.bin > image.iso"