Optional Info

Sidebar image descriptionAny information can be placed in the sidebar to help your website visitors navigate your site.

To make a boxed heading like the one above, simply apply the H3 tag.

To make a box like this, assign the "sidebarlt" class.

You can do anything with a sidebar box. Insert images, ads or other web content.

Here's a text link.

To make a box like this, assign the "sidebardk" class.

You can do anything with a sidebar box. Insert images, ads or other web content.

Here's a text link.

Site Search:


Reference Links:

Hardware & Software Basics (Wiki)

Ubuntu vs. Windows Vista vs. Windows 7

Security Standards

Linux CLI Commands Wallpaper

avatar48320_2.gifav-611.gif
zd_ubuntu_jauntyjackalope2.png




loadingbar.gifCD Image Manipulation in Linuxloadingbar.gif

Ive done everything in this howto except that cdemu did not work for me. Everything else worked perfectly, the info is solid. -M

Warning: This HOWTO comes with no explicit or implicit warranty whatsoever. Use at your own risk!
Table of Content

Due to some forum posts about creating and mounting cd-images under linux, I made this howto, in which I show the different types of CD-images and how to convert between each other and howto mount them into the linux filesystem.
CD specifications

1. A 74 min CD consists of 333,000 sectors, a 80min CD of 360,000.
2. A sector is 2352 bytes, what corresponds to 2048 bytes of PC (MODE1) Data, 2336 bytes of PSX/VCD (MODE2) Data or 2352 bytes of AUDIO. The variable number of bytes in a sector result of different header sizes and different error correction codes of those modes.
3. When extracting data from a CD in RAW format, you always get 2352 bytes per sector, ignoring in which mode the data is formated on CD.

Handling with .iso files

Creating an .iso file is the easiest way to create an image from a CD and mount it into the linux filesystem;

Just insert the cd into your cd-drive and copy all data from the device file to any file:

# cat /dev/cdrom > /path/to/the/image.iso

or

# dd if=/dev/cdrom of=/path/to/the/image.iso

To mount it, you have to ensure that the loopback device driver (in kernel "make menuconfig" "Device Drivers -> Block devices -> Loopback device support") is enabled as module or built in, what should be the case in all standard kernels.

Now just enter this command as root to mount your .iso file:

# mount -o loop -t iso9660 /path/to/the/image.iso /path/to/mountpoint

The option "-t iso9660" can usually be left out, because the mount program guesses the right filesystem automatically.

BUT with the creation of an .iso image only data files of the iso9660 filesytem are copied. Thus there are no error correction codes and headers copied, also there's no possibility to copy a cd consisting of multiple data or audio tracks, you'll just get the iso9660 formated data. The only advantage of creating an .iso file instead of copying the data manually from the mounted cd, is that the bootable block of the CD is also copied to the image. So the .iso format is great for purposes like holding a collection of distribution CDs. But e.g. PlayStation cds consist normally of more than one track, so an .iso image wouldn't work here.

Burning an .iso file works with following command:

# cdrecord -v dev=0,0,0 /path/to/the/image.iso

To find the right device use the command:

# cdrecord -scanbus

Handling with .bin/.cue/.toc files

The advantage of .bin/.cue image files is, that it is a "RAW" copy of the cd. What means, that every bit (including header and error correction) is copied to the image file. Generation of such a RAW CD copy can easily be done with cdrdao:

# cdrdao read-cd --read-raw --datafile /path/to/image.bin --device ATAPI:0,0,0 --driver generic-mmc-raw /path/to/image.toc

The command generates the image.bin, the RAW copy of the CD and a image.toc file, which just contains information about the different tracks in the image. Some programs need exactly this information, but formated in a .cue file. The program bin2iso can be used to get such a .cue file from the image.

# bin2iso /path/to/image.cue -c /path/to/image.bin

The correct device for the cdrdao command can, like in the section above, be found with:

# cdrecord -scanbus

The disadvantage of the .bin/.cue format is, that it can't be mounted into the linux filesystem with standard kernels. You need the kernelmodule and program of the cdemu project. Howto get this thing working is described later in this document.

Burning a CD of a .bin file works this way:

# cdrdao write --device ATAPI:0,0,0 /path/to/image.toc
Installing cdemu

As already mentioned, there is a module and a program needed to mount .bin/.cue files. A project which supports us with such a program and kernelmodule is called cdemu. The latest version supports .mds, .ccd and .nrg files as well.

The following instructions are for compiling cdemu from source, if there's a distribution specific cdemu package you may download it and skip the whole compiling process.
Before you continue reading, ensure that you installed the sources of your running kernel and things you need to compile, like the gcc compiler, autotools and so on!

Get the package from http://prdownloads.sourceforge.net/cdemu/cdemu-0.8.tar.bz2

Extract:

# tar xvfj cdemu-0.8.tar.bz2

Build it:

# cd cdemu-0.8
# make

If you get the error:

/cdemu.c:211: error: too few arguments to function 'do_generic_file_read'

you simply have to add a ",0" to line 211 of cdemu.c: the original line:
do_generic_file_read(vc->backing_file, &position, &desc, cdemu_read_actor);

the "patched" one:

do_generic_file_read(vc->backing_file, &position, &desc, cdemu_read_actor,0);

Install it (as _root_!):
# make install

If you've got a distribution which uses udev (e.g. fedora, suse,..) you should add following line to /etc/udev/rules.d/50-udev.rules:
KERNEL="cdemu[0-9]*", NAME="cdemu/%n", MODE="0666"

The module can be loaded using modprobe (you should insert this command somewhere that it is executed everytime you boot your system, for fedora you can add it to the file /etc/rc.local):
# modprobe cdemu

After you inserted the module, the device files /dev/cdemu/0 - /dev/cdemu/7 should be created.
Loading .bin images

To load a .bin image into a "virtual" CD-drive you need the correct .cue file. If you don't have it, have a look into the section "3. Handling with .bin/.toc/.cue files".

Cdemu supports 8 devices for loading imagefiles, to load the 3. device, just enter:

# cdemu 2 /path/to/image.cue

The argument "2" stands for the device number, in this case the image can be accessed at /dev/cdemu/2.

To unload the image, enter:

# cdemu -u 2

And to get the status of loaded CD images execute:

# cdemu -s
Convertion between different types of images

.nrg (Nero image) to iso:

# dd if=/path/to/image.nrg of=/path/to/image.iso bs=2048 skip=150

.bin (RAW CD copy) to iso:

# bin2iso /path/to/image.cue /path/to/extract/
or
# bchunk /path/to/image.bin /path/to/image.cue NameOfGeneratedIso

.mdf (alcohol 120%) to iso:
install mdf2iso and execute:
# mdf2iso image.mdf

Credits
Robert Penz, Mike Frysinger and Marc Thoben for developping cdemu
wikipedia.org for holding the knowledge about cd specifications

Original Text from: http://www.linux-gamers.net/modules/wiwimod/index.php?page=HOWTO+CD-IMAGES

 

Website templates by JustDreamweaver.com