Skip to content

Dvd and Cd

cd

finding the cd drive

cdrecord -scanbus You get a list like :

cdrecord -scanbus
scsibus2:
    2,0,0   200) 'ATA     ' 'SAMSUNG HD502IJ ' '1AA0' Disk
    2,1,0   201) *
    2,2,0   202) *
    2,3,0   203) *
    2,4,0   204) *
    2,5,0   205) *
    2,6,0   206) *
    2,7,0   207) *
scsibus4:
    4,0,0   400) 'LITE-ON ' 'DVD SOHD-167T   ' '9S19' Removable CD-ROM
    4,1,0   401) 'LITE-ON ' 'LTR-12101B      ' 'LS38' Removable CD-ROM
    4,2,0   402) *
    4,3,0   403) *
    4,4,0   404) *
    4,5,0   405) *
    4,6,0   406) *
    4,7,0   407) *

Decide on the one you want to use and remember the number.

Burning the image

So burning it to 'LITE-ON' 'LTR-12101B' would mean :

burn
cdrecord -v dev=4,1,0 WXPVOL_EN.iso

dvd

ripping dvd

rip dvd
dd if=/dev/cdrom of=/path/to/cdcopy.iso

Or find out what the dvd device is, on power you need :

find device
dd if=/dev/sr0 of=/path/to/cdcopy.iso

burning (copying) dvd's

This is an ultrashort description of how to burn dvd's on linux: install growisofs

burning dvd
apt-get install dvd+rw-tools

get the data from the dvd as a whole

get iso file
cat /dev/hda > big.iso

burning the image

burn iso file
growisofs -Z /dev/cdrom=big.iso

If you want to burn a 'directory':

add directory
growisofs -Z /dev/dvd -R -J /dir/file-name

Note that a command like this :

do not do this
growisofs -Z /dev/dvd -R -J big.iso

Will not burn the image to disk but will make a dvd with big.iso on it as the only file

multi session

An easy way to make more use of a dvd's capacity for instance for backup is to incrementally write multiple sessions to the dvd.

You can actually mount the dvd and make it behave like a normal filesystem. For instance if you write file a in session 1 and file b in session 2 you get both of them in the same directory. Even deletion is possible, though i did not try it.

In my case i actually rather have all copies of the backups available so putting them in different directories with a file stamp works just as well.

starting

The first session is special, and should be started like this.

start new session
growisofs -Z /dev/sr0 -R -J /var/lib/aide

This burns the files inside the aide directory to the root of the cdrom, it does NOT create the aide directory as well.

show content
mount /media/cdrom
ls /media/cdrom
# output :
aide.conf.autogenerated  aide.db  aide.db.new

more sessions

After that you can add sessions with -M (multi ?)

add session
growisofs -M /dev/sr0 -R -J /var/lib/tripwire

Now you have a disk with two sessions, and two alternatives to mounting the dvd. You can steer that with the session mount option. In /etc/fstab

mount specific session
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto,ro,session=0     0       0
# umount /media/cdrom
# mount /media/cdrom
# ls /media/cdrom
# aide.conf.autogenerated  aide.db  aide.db.new

So this gives the state at session 0, only aide files are visible.

show content
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto,ro,session=0     0       0
# umount /media/cdrom
# mount /media/cdrom
# ls /media/cdrom
# aide.conf.autogenerated  aide.db.new  colatic.twd.bak
# aide.db                  colatic.twd  report

As you see, now both sessions appear in the same directory.

examining sessions

You can get a lot of info by installing and using dvd+rw-tools :

info
apt-get install dvd+rw-tools
dvd+rw-mediainfo

This will list all written tracks and where they reside. It is important to find out if you can isolate a single track or at least a snapshot from earlier. This because a compromised system may be used to destroy the dvd attached and we still end up with no backup.

To get any session you want use this method :

find session
dvd+rw-mediainfo | grep Start
Track Start Address:   0*2KB
Track Start Address:   93952*2KB
Track Start Address:   102736*2KB
Track Start Address:   109088*2KB
Track Start Address:   115440*2KB
Track Start Address:   121792*2KB

Now you will have to guess which one, or just try multiple times. Take the address and mount your section with this commandline :

mount a found session
mkdir dvd
mount -o sbsector=102736 /dev/sr0 dvd

You will now have the correct 'snapshot' up to that point, not the separate write done. I added the aide configuration files only once in the very first session, and these files will be present in all mounts !! Still this suffices for me, and i will do daily backups to be able to fixate this dvd as soon as possible.