------------------------------------------------------------------------------- CDrom and DVD handling under linux Low level Software mkisofs -- create a ISO9660 image from a directory isoinfo -- directory listing an iso image isosize -- the actual length of the ISO file system isodump -- interactive exporation of image - ?? commands ?? growisofs -- create a ISO image and even add to it devdump -- readcd -- CD/DVD reader with error handling cdrecord -- low level cd burning, for burning individual tracks cdrdao -- low level cd burner, write whole disk once Higher Level Creation xcdroast -- read, create iso's, and burn cdroms k3b -- KDE cdrom/dvd burner (RPM requires a number of extra libraries) vcdimager -- create VCD CUE,BIN files from MPEG videos. k9copy -- compress dual layer video to single layer ISO (set output size to 4400Mb) Mount Extract fuseiso -- userlevel ISO mounts xbiso -- extract xdvdfs??? Modify Existing ISO isomaster -- CD/DVD Image Manipulator ***** AcetoneISO2 -- CD/DVD Image Manipulator (not bootable) Testing and Comparing isomd5sum / isovfy -- iso image comparitors Recovering corrupt Disks ddrescue -- read disks whcih has errors foremost -- make corrupt data files usable DVD ripping libdvdcss -- absolute must (with it mplay can play encrypted dvd dvdrip -- rip and transcode to Xvid Aavi files Thoggen Acidrip ------------------------------------------------------------------------------- Creating ISO images to record onto cdroms... Reading CDROM / DVD Without error checking you can use... cat /dev/cdrom > cdrom.iso or dd conv=noerror if=/dev/cdrom of=disk.iso However many cdroms will overrun, becomming longer than nessary. To copy the ISO correctly include the ISO size in the dd command dd if=/dev/cdrom of=disk.iso bs=2048 \ count=`isosize -d 2048 /dev/cdrom` conv=sync,notrunc Add conv=noerror to ignore read errors that may be present. The "dd_rescue" package can handle bad sectors (intensional on sony ACccOS copy-protection disks) but is very slow. dd_rhelp /dev/cdrom disk.iso The GNU "ddrescue" (not in yum repos) is the newer program which has the dd_rhelp shell script function compiled in. ddrescue /dev/cdrom disk.iso If it reports errors try a second pass with a '-d' flag. The log file allows it to pause and resume a the rescue process. The "readcd" command is suposed to let you read the ISO from the CD with re-reads of disk errors. It is probably the prefered method. If the ISO image is corrupt you can restore functionality using foremost -t all -k 256 -v -b 2048 -i ~/dvd.iso -o ~/dvd/ See http://foremost.sourceforge.net/ List the contents of an image (without mounting it) isoinfo -f -i disk.iso names ending in ";1" are files, directories have not extra ending Create an ISO image from a directory mkisofs -o disk.iso -R -J -V "Volume_Title" directory Options: -R is for Rock Ridge Extensions (Unix long filename) -J is Joliet (Miscrosoft long filenames) -hfs another long file name extension (for macs) Alturnative to copying all files under the directory is to know make symlinks to the real file, and use "-f" option. This replaces all symlinks found in ths directory with a copy of the pointed to file in the created ISO. Of course this also means the resulting ISO will not contain any symlinks! Burn a directory onto a DVD (ISO created on the fly). growisofs -Z /dev/dvdrw -l -r -V "Volume Name" directory Mount a ISO image as a file system (root) mount -t iso9660 -o ro,loop disk.iso /mnt ------------------------------------------------------------------------------- Modifying existing 'bootable' ISO image A CDROM image does not have a MBR like Harddisks and USB flash drives As such the boot file is part of the filesystem (somewhere) So first mount the ISO, and copy it to a normal filesystem sub-directory. Now edit/add/remove files as you like. When finished create a new 'bootable' ISO image For Linux file systems... mkisofs -o output.iso \ -b isolinux/isolinux.bin -c isolinux/boot.msg \ -no-emul-boot -boot-load-size 4 -boot-info-table \ iso_image_root isomaster This is not 'intuitive' in how to use -- help->overview does explain it. You select a ISO image, add and remove files into it, When finished you then 'save-as' a new ISO image. It tells you the name of the "boot file" the extracted ISO is using so should create bootable ISOs from any bootable ISO. AcetoneISO2 The program acetoneiso2 will also generate a ISO image from an extracted directory. But seems to required 'PowerISO' for the extraction of an extract ISO to a folder for modification. Resulting image from a folder was NOT bootable!!!! However it does seem to know how to create video DVDs. ------------------------------------------------------------------------------- Burning non-ISO formats (typically for DVD video) TOC,BIN files cdrdao write --device /dev/dvd image.toc with options --speed --eject eject when finished --overburn add that little bit extra (dangerious) EG: cdrdao write --device /dev/dvd --speed 10 --eject --overburn image.toc Or use K3B burner CUE,BIN files Replace the toc file with the cue file Or use K3B burner You can use 'bchunk' to convert into an iso bchunk IMAGE.bin IMAGE.cue IMAGE.iso Or 'bin2iso' though this may not be in a repo bin2iso IMAGE.CUE CCD,NRG images Not directly posible however two utilities are available nrg2iso and ccd2iso http://gregory.kokanosky.free.fr/v4/linux/nrg2iso.en.html http://ccd2iso.sourceforge.net/ nrg2iso image.nrg image.iso ccd2iso image.img image.iso There is no guarantee that the resulting images will be fully usable since the ISO-image format does not support all the features used by NRG and CCD images. ------------------------------------------------------------------------------- Clone a CD or VCD cdrdao copy --keepimage --device /dev/cdrom --eject To verify the data written (and kept) repeat with copy and abort when the read part of the copy is complete... cdrdao copy --device /dev/cdrom [ctrl-C] Now compare the two data reads to check if they match... Also remove saved data if they do cmp cd*.bin && rm -f cd*.{toc,bin} ------------------------------------------------------------------------------- Burning CDROM/DVD from ISOs (command line) NB: cdrecord MUST run as root due to special fcntl controls needed, you can however make cdrecord suid to root. To find the device numbers to use (typically dev=0,0,0) run as root... cdrecord -scanbus Test burn cd-rw drive (root) cdrecord -eject -multi -dummy -v dev=0,0,0 padsize=600m /dev/null OR cdrecord -eject -multi -dummy -v dev=0,0,0 cdrom.iso Burn an ISO image to cd-rw drive (root) (add -multi to not close CD sesson) cdrecord -eject -v dev=0,0,0 cdrom.iso Or on a 400Mhz or better burn a directory straight from the file system mkisofs -R -J -V "Volume_Title" directory |\ cdrecord -eject -multi -v dev=0,0,0 -data - (See cd burning howto if a size is required). Multiple Image CDs All images must have "-multi" used on all cdrecord sessions. The first mkisofs session is generated as normal. Later must have the track number ( -C # ) included when generated. set next = `cdrecord -msinfo dev=0,0,0` echo "Next Track is $next" mkisofs -R -J -o cdrom_new.iso -C $next -M /dev/cdrom \ -V "Volume_Title" filesystem/ cdrecord -eject -multi -v dev=0,0,0 cdrom_new.iso Bootable CDs For more info read "README.eltorito" in mkisofs distribution. * The first few blocks of the CD image must be replaced with a bootable floppy image. Create a image from a floppy with... dd if=/dev/fd0 of=boot.img bs=10k count=144 * This file is then copied into the cdrom file system, often under the sub-directory as "boot/boot.img". * A second file "boot/catalog" will be automatically created and should ne named something to avoid conflict with the other filenames. It also probably should be (as shown) in the "boot" sub-directory. BOTH file names (the image and created catalog) has to be within the ISO image. * Make ISO image naming the directory for image (containing the "boot" sub-directory). mkisofs -b boot/boot.img -c boot/boot.catalog -R ...as normal... GrowISOfs offers an easy way to store a set of directories and/or files on a DVD or CDrom. It uses mkisofs to create an image, and writes it to the DVD recorder without needing to store a copy of the image on the harddrive before recording it. growisofs -dvd-compat -Z /dev/dvd -J -R /path/to/disc/root creates an image of files located at /path/to/disc/root using ISO9660 filesystem with Joliet (-J) and Rock Ridge (-R) extensions, and record it to a DVD-R(W) media. For a better discussion, and specifically "boot to linux" cdroms, see http://www.au.linuxfromscratch.org/hints/downloads/files/bootcd.txt also http://www.au.linuxfromscratch.org/hints/downloads/files/boot-cd_easy.txt ------------------------------------------------------------------------------- ISO9660 notes.. CD data is stored on the cdrom generally in ISO9660 format The first 32Kb of this format is usally empty (all zeros) The next block contains the cdroms name and title. EG: dd if=/dev/cdrom skip=64 count=1 | strings OR dd if=/dev/cdrom skip=64 count=1 | od -c OR dd if=/dev/cdrom skip=64 count=1 | hex -g =======8<-------- #!/bin/sh # # Read the cdrom information from cdrom # RD=/dev/cdrom # or a iso image file for i in 32768,7 32776,32 32808,32 32958,128 33086,128 33214,128 \ 33342,128 33470,32 33581,16 33598,16 33615,16 33632,16 do old_IFS="$IFS" IFS="," set -- $i IFS="$old_IFS" OFFSET=$1 LENGTH=$2 echo "#`dd if=$RD bs=1 skip=$OFFSET count=$LENGTH 2> /dev/null`#" done =======8<-------- ------------------------------------------------------------------------------- Under Windows... BlindRead makes perfect ISO images from CDROMs, and can write them out in a variety of formats. DaemonTools mounts these ISO images transparently in Windows without the need to burn them to CD. The BlindRead/BlindWrite suite (Not free, but free trial period) http://www.blindwrite.com/ DaemonTools (Free) http://www.daemontools.org/ VaporCD ( http://vaporcd.sourceforge.net) has been suggested a few times too, as a open source solution. ------------------------------------------------------------------------------- Commercial CDROM burning software modify ISO images!!! I was surprised to find that commercial CD writing software does not generally create unadulterated ISO images of CD's. Nero, for example, uses some proprietary format (probably an ISO with a metadata header). ------------------------------------------------------------------------------- Create a linux only ext2 cdrom! Create a ext2 file system for CDROM dd if=/dev/zero of=cd.ext2 bs=1024 count=650k /sbin/mke2fs -b 2048 cd.ext2 mkdir /mnt/ext2 mount -t ext2 -o loop=/dev/loop0 cd.ext2 /mnt/ext2 dd if=/dev/zero of=dvd.ext2 bs=4096 count=1024k /sbin/mke2fs -b 4096 dvd.ext2 mkdir /mnt/ext2 mount -t ext2 -o loop=/dev/loop0 dvd.ext2 /mnt/ext2 Note mke2fs may complain that the device is not a block special. Just tell it to proceed anyway. Copy the files into the file system and when finished unmount it. Now just burn the "ext2" file directly to the cdrom using cdrecord, k3b or some other disk burner, just like it was a 'normal' ISO image. NOTE: If you mount this filesystem via the "fstab" file ensure the last two numbers are 0 (zeros) so the fsck does NOT check the filesystem (it will fail). There are also probably tweeks like the 'free space' limit for root only that should also be applied. ------------------------------------------------------------------------------- Audio CD Ripping abcde -- Rip Audio tracks with cddb and multiple output formats Very easy! Also for mp3 needs packages: id3v2 lame Slightly lower version (Redhat 8.0 and up) grip NOTE: this program by default saves names into the "ogg" sub-directory Configure grip... Rip rip_file: ./%A %t - %n.wav Encode execute: lame cmd_line: -h -b %b --ta %A --tl %d --tt %n -- %w %m enc_file: ./%A %t - %n.mp3 Encode_opt file: ./%A.m3u ID3 remove "Created by grip" Misc remove my email address turn on Do not lowercase names turn on Do not change spaces to underscores Lower Level Rip... You can use "cdda2wav" to get the "wav" files from the cd, instead. This can extract a specific track or interval from the audio cd. You can convert wav files to mp3 using "lame" Example... # extract wav files cdda2wav -D /dev/cdrom -B rm audio_*.inf # Convert to mp3, add info to songs ls audio_*.wav > list vi list :%s/^.*.\([0-9[0-9]\).wav/lame -h --tn "\1" &/ :%s/" /" --tt "title" --ta "artist" --tl "album" / :%s/album/...../ :%s/artist/...../ # edit the song titles :wq sh list rm audio_*.wav # Rename mp3 files vi list :%s/$/.mp3/ :%s/^.*--tt "\([^"]*\)" --ta "\([^"]*\)".* \(.*\)/mv \3 "\2 - \1".mp3 :%s/ */ /g :%s/'//g :wq sh list rm list The "cdparanoia" does a simular job as "cdda2wav" Shell script mp3 rename and re-tag scripts (Uses id3 and id3v2 commands) http://marc.merlins.org/linux/mp3tools/ ------------------------------------------------------------------------------- Decode DVD frames to PNG mplayer file.vob -ss 284 -frames 1000 \ # source and numer frames -vop pp=0x20000 \ # deinterlace images -vo png -nosound # output to png files ------------------------------------------------------------------------------- DVD video from files You might have a Video DVD stored as a series of normal files in your filesystem, perhaps from some DVD authoring software, and want to write this to a disc for usage in your DVD-player. To do this, we yet again turn to growisofs for help, which as usual provides an easy solution to our problem. In the example below, the disc-root refers to a directory containing any, or both of the AUDIO_TS/ and VIDEO_TS/ directories. The main difference from writing an ISO image is the -dvd-video option, that instructs growisofs that it should prepare the disc to be used as a DVD Video disc. growisofs -Z /dev/dvd -dvd-video /path/to/disc/root Below is a sample listing of what the filestructure of a Video DVD might look like: AUDIO_TS/ VIDEO_TS/ VIDEO_TS/VIDEO_TS.BUP VIDEO_TS/VIDEO_TS.IFO VIDEO_TS/VIDEO_TS.VOB VIDEO_TS/VTS_01_0.BUP VIDEO_TS/VTS_01_0.IFO VIDEO_TS/VTS_01_0.VOB VIDEO_TS/VTS_01_1.VOB ... ------------------------------------------------------------------------------- Video files to (S)VCD GNU VCDImager software to convert MPEG to (Super) VideoCD recorded with CDRDAO vcdimager -t type --update-scan-offsets video.mpg The MPEG streams needs to be in somewhat appropriate formats to be used as (S)VCDs -------------------------------------------------------------------------------