0

I need to copy Codonics medical data from CD to ISO. I insert an CDROM in the CD drive TSSTcorp DVD+-RW TS-H653H of my Dell Precision T1600. The system detects and mounts the CD when you insert it in Debian. In copying, dd fails systematically but readom is the only successful differential tool. However, cp also fails so there must be better differential tools in copying CDs to ISO in commandline, related LinuxJournal's article here. Workflow

  1. Unmount cdrom

    root@masi:/home/masi# unmount /dev/sr0
    
  2. Run copy command as pseudocode

    readom... / cp... / dd... / ...
    

Successful workflow with readom but some error

Atoponce's command proposal of readom

# http://www.commandlinefu.com/commands/view/1396/create-a-cddvd-iso-image-from-disk.
readom dev=/dev/scd0 f=/path/to/image.iso
  • Its docs

    Create a CD/DVD ISO image from disk.
    

    Many like to use 'dd' for creating CD/DVD iso images. This is bad. Very bad. The reason this is, is 'dd' doesn't have any built-in error checking. So, you don't know if you got all the bits or not. As such, it is not the right tool for the job. Instead, 'reaom' (read optical media) from the wodim package is what you should be using. It has built-in error checking. Similarly, if you want to burn your newly creating ISO, stay away from 'dd', and use: wodim -v -eject /path/to/image.iso

Workflow

root@masi:/home/masi# umount /dev/sr0

root@masi:/home/masi# readom dev=/dev/sr0 f=/home/masi/Desktop/image.iso
Read  speed:  8467 kB/s (CD  48x, DVD  6x).
Write speed:  8467 kB/s (CD  48x, DVD  6x).
Capacity: 35829 Blocks = 71658 kBytes = 69 MBytes = 73 prMB
Sectorsize: 2048 Bytes
Copy from SCSI (3,0,0) disk to file '/home/masi/Desktop/image.iso'
end:     35829
Errno: 5 (Input/output error), read_g1 scsi sendcmd: no error
CDB:  28 00 00 00 8B C0 00 00 35 00
status: 0x2 (CHECK CONDITION)
Sense Bytes: 70 00 03 00 00 00 00 0A 00 00 00 00 11 00 00 00
Sense Key: 0x3 Medium Error, Segment 0
Sense Code: 0x11 Qual 0x00 (unrecovered read error) Fru 0x0
Sense flags: Blk 0 (not valid) 
cmd finished after 7.038s timeout 40s
readom: Input/output error. Cannot read source disk
readom: Retrying from sector 35776.
.....................................................~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~+~~~-~~~
readom: Input/output error. Error on sector 35828 not corrected. Total of 1 errors.

Time total: 1259.495sec
Read 71552.00 kB at 56.8 kB/sec.
Max corected retry count was 0 (limited to 128).
The following 1 sector(s) could not be read correctly:
35828

Output: seems to be correctly copied CDROM to .iso but not sure why the error. Tested CDs: 3.

Unsuccessful cp workflow

root@masi:/home/masi# unmount /media/

root@masi:/home/masi# cp /dev/sr0 /home/masi/Desktop/image.iso
cp: error reading ‘/dev/sr0’: Input/output error
cp: failed to extend ‘/home/masi/Desktop/image.iso’: Input/output error

Failed dd attempts so deprecate dd for the task

I get the following message with the command dd if=/dev/cdrom of=/home/masi/Desktop/image.iso in Debian

dd: error reading '/dev/cdrom': Input/output error
143312+0 records in
143312+0 records out
73375744 bytes (73 MB) copied, 37.6356 s, 1.9 MB/s

Other failed copy commands with dd

  1. with bs and conv

    # http://crunchbang.org/forums/viewtopic.php?id=23659
    dd if=/dev/scd0 of=whatever.iso bs=2048 conv=sync,notrunc
    
  2. with conv only

    dd if=/dev/scd0 of=whatever.iso conv=sync,notrunc
    

Testing jc___ profiling proposal successfully

root@masi:/home/masi# mkdir /media/cdMP

root@masi:/home/masi# mount /dev/cdrom /media/cdMP/
mount: /dev/sr0 is write-protected, mounting read-only

root@masi:/home/masi# umount /dev/cdrom

root@masi:/home/masi# mount /dev/cdrom /media/cdMP/
mount: /dev/sr0 is write-protected, mounting read-only

root@masi:/home/masi# readom dev=/dev/sr0 -scanbus
Error trying to open /dev/sr0 exclusively (Device or resource busy)... retrying in 1 second.
Error trying to open /dev/sr0 exclusively (Device or resource busy)... retrying in 1 second.

So do instead where non-root works, ensuring that nothing is keeping CDROM busy, and activating filebrowser of the CDROM explicitly

masi@masi:~$ readom dev=/dev/sr0 -scanbus
scsibus3:
    3,0,0   300) 'TSSTcorp' 'DVD+-RW TS-H653H' 'D700' Removable CD-ROM
    3,1,0   301) *
    3,2,0   302) *
    3,3,0   303) *
    3,4,0   304) *
    3,5,0   305) *
    3,6,0   306) *
    3,7,0   307) *

Testing ThomasSchmitt's proposal

I do unsuccessfully by umounting and xorriso

masi@masi:~$ umount /dev/sr0 

masi@masi:~$ xorriso -outdev /dev/sr0 -check_media use=outdev sector_map="$HOME"/cdrom_sector_map data_to="$HOME"/cdrom_copy.iso abort_file="$HOME"/cdrom_copy_abort --
xorriso 1.3.2 : RockRidge filesystem manipulator, libburnia project.

xorriso : NOTE : Disc status unsuitable for writing
Drive current: -outdev '/dev/sr0'
Media current: CD-R
Media status : is written , is closed
Media summary: 1 session, 35829 data blocks, 70.0m data,     0 free
xorriso : UPDATE : 32 blocks read in 7 seconds , 0.1xC
xorriso : UPDATE : 352 blocks read in 9 seconds , 2.8xC
xorriso : UPDATE : 1216 blocks read in 10 seconds , 11.5xC
xorriso : UPDATE : 2784 blocks read in 11 seconds , 20.7xC
xorriso : UPDATE : 4416 blocks read in 12 seconds , 21.4xC
xorriso : UPDATE : 6048 blocks read in 13 seconds , 21.6xC
xorriso : UPDATE : 7712 blocks read in 14 seconds , 21.9xC
xorriso : UPDATE : 9376 blocks read in 15 seconds , 22.1xC
xorriso : UPDATE : 11072 blocks read in 16 seconds , 22.3xC
xorriso : UPDATE : 12768 blocks read in 17 seconds , 22.5xC
xorriso : UPDATE : 14496 blocks read in 18 seconds , 22.7xC
xorriso : UPDATE : 16224 blocks read in 19 seconds , 22.9xC
xorriso : UPDATE : 17984 blocks read in 20 seconds , 23.1xC
xorriso : UPDATE : 19744 blocks read in 21 seconds , 23.3xC
xorriso : UPDATE : 21536 blocks read in 22 seconds , 23.5xC
xorriso : UPDATE : 23328 blocks read in 23 seconds , 23.7xC
xorriso : UPDATE : 25152 blocks read in 24 seconds , 23.9xC
xorriso : UPDATE : 26976 blocks read in 25 seconds , 24.1xC
xorriso : UPDATE : 28832 blocks read in 26 seconds , 24.3xC
xorriso : UPDATE : 30688 blocks read in 27 seconds , 24.5xC
xorriso : UPDATE : 32576 blocks read in 28 seconds , 24.8xC
xorriso : UPDATE : 34464 blocks read in 29 seconds , 25.0xC
libburn : SORRY : SCSI error on read_10(35828,1): [3 11 00] Medium error. Unrecovered read error.
xorriso : UPDATE : 35829 blocks read in 37 seconds , 2.4xC
xorriso : UPDATE : 35829 blocks read in 37 seconds = 13.0xC
Media checks :        lba ,       size , quality
Media region :          0 ,      35828 , + good
Media region :      35828 ,          1 , - unreadable
xorriso : NOTE : Tolerated problem event of severity 'SORRY'
xorriso : NOTE : -return_with SORRY 32 triggered by problem severity SORRY

Testing the quality of the output

masi@masi:~$ ls /home/masi/
cdrom_copy.iso    Desktop    Downloads  Pictures  Templates  WolframWorkspaces
cdrom_sector_map  Documents  Music      Public    Videos

masi@masi:~$ su

root@masi:/home/masi# mkdir /mnt/iso

root@masi:/home/masi# mount -o loop /home/masi/cdrom_copy.iso /mnt/iso
mount: /dev/loop0 is write-protected, mounting read-only
root@masi:/home/masi# exit
exit

masi@masi:~$ tar cf - /mnt/iso/ | wc
tar: Removing leading `/' from member names
 303452  886038 72867840

masi@masi:~$ tar cf - /dev/sr0 | wc
tar: Removing leading `/' from member names
      0       3   10240

 masi@masi:~$ umount /dev/sr0 

 masi@masi:~$ tar cf - /dev/sr0 | wc
 tar: Removing leading `/' from member names
       0       3   10240

It seems that the copied ISO file does to have any errors so it should be a complete duplicate of the CD. Do for certainty by looking both file trees

masi@masi:~$ su

root@masi:/home/masi# mkdir /mnt/orig_cd

root@masi:/home/masi# mount /dev/sr0 /mnt/orig_cd
mount: /dev/sr0 is write-protected, mounting read-only

root@masi:/home/masi# mount -o loop /home/masi/Desktop/image.iso /mnt/iso
mount: /dev/loop0 is write-protected, mounting read-only

root@masi:/home/masi# diff -q -r /mnt/orig_cd/ /mnt/iso/ | less

Output: no lines in less output meaning complete equivalence; I tested also completely different contents where complete difference so the output is the same as expected output in both cases.

System characteristics

  • I do dmesg | grep cd returns

    cdrom: Uniform CD-ROM driver Revision: 3.20
    Volume set (in), Read cd: be 00 00 00 8b f3 00 00 02 00 00 00 
    
  • Doing lsscsi -s gives

     cd/dvd TSSTcorp DVD+-RW TS-H653H D700 /dev/sr0 - 
    

OS: Debian 8.5
Linux kernel: 3.16.0-4-amd64, the one which comes default in Debin 8.5
Hardware: customer Dell PC 2011 (Dell Precision T1600); customer service tag 1CY515J
CD Drive: default of the Dell PC - TSSTcorp DVD+-RW TS-H653H
Test CDs: one full and one blank
Documentation about CDs in Debian: DiskImage
Differential condition: something wrong in CD drive's drivers
Related threads: readom and dd are creating different ISO-Images, Archiving CDs to ISO from the Command Line, "dd" to read CD-ROM and its effects (Re: howto verify burn?), dd command to copy a cd to a hard disk - Input/output error where some looping of I/O, ...

  • 1
    What can you tell us about the CD-ROM device? Make, type, anything. – schaiba Sep 21 '16 at 14:58
  • 1
    does the media, disk, auto-mount when you insert it? – jc__ Sep 21 '16 at 16:42
  • 1
    How about sudo cp /dev/sr0 image.iso? – Rui F Ribeiro Sep 21 '16 at 16:44
  • 1
    What is final output of this sequence. 1- get mount point. mount 2- sudo umount /media/mountPoint. 3- sudo readom dev=/dev/sr0 -scanbus. – jc__ Sep 21 '16 at 17:20
  • 2
    I think the trick is to unmount the drive before using readom, no mount points on the /dev/sr0 then calling readom as root. I was getting the same error untll I unmounted it. Error trying to open /dev/sr0 exclusively (Device or resource busy)... – jc__ Sep 21 '16 at 17:40
7

I am developer of libburn and work since a year with about the same system as mentioned here. Kernel 3.16 has a few CD regressions towards 2.6, but the use case of copying data should work fine.

I rather see bit rot here (readom is unmaintained), user errors (wrong device files, readom on mounted medium), and the "read-ahead bug" with CD media written with write type Track-At-Once (i/o error). The i/o error could have been caused by a poorly readable medium as well.

In detail:

There is no /dev/scd0 on vanilla Debian 8. Only /dev/sr0 and possibly symbolic links like /dev/cdrom, dev/dvd, ... So all failures with scd0 are trivially explainable. The advise to run wodim -scanbus is futile without having /dev/scdX, as wodim looks only at those addresses.

readom docs are typically copied from readcd and thus reflect the peculiar view of the author of cdrecord and readcd. Nevertheless it should work, of course.

For copying from a data CD, a DVD, or a BD medium, dd and cp are well ok. There is few use of dd options conv=sync,notrunc here. conv=sync is indeed dangerous with certain data sources as it will inject zeros when the data source delivers less than bs bytes per read operation. (Should never happen with CD and bs=2048.)

"Input/output error" is not caused by the copy program but a message from the kernel to those programs. It is normally caused by an error indication of the drive.

In this special case it turned out to be the classic "CD read-ahead bug". The last one or two blocks of a CD (not of DVD or BD) may stay unreadable because some drives report one or both Track-At-Once run-out blocks as part of the payload data, which they are not.

In most cases dd and cp on kernel 3.16 deliver all payload blocks before they abort by i/o error. For older kernels or unlucky situations, there is the mkisofs tradition to add 300 kB of padding when ISOs get produced. If some of these 300 KB are not delivered by the kernel, then this does not damage the content of files in the ISO.

If the i/o error had happened before the last two blocks of a CD, then it would more likely have been caused by poorly readable medium. In this case the advice would be to look in dmesg output or /var/log/messages for reports like:

Aug 29 15:51:12 NN kernel: [9852911.947547] sr 2:0:0:0: [sr0] Unhandled sense code
Aug 29 15:51:12 NN kernel: [9852911.947549] sr 2:0:0:0: [sr0]
Aug 29 15:51:12 NN kernel: [9852911.947550] Result: hostbyte=DID_OK driverbyte=DRIVER_SENSE
Aug 29 15:51:12 NN kernel: [9852911.947551] sr 2:0:0:0: [sr0]
Aug 29 15:51:12 NN kernel: [9852911.947552] Sense Key : Medium Error [current]
Aug 29 15:51:12 NN kernel: [9852911.947554] Info fld=0x710
Aug 29 15:51:12 NN kernel: [9852911.947554] sr 2:0:0:0: [sr0]
Aug 29 15:51:12 NN kernel: [9852911.947555] Add. Sense: Unrecovered read error
Aug 29 15:51:12 NN kernel: [9852911.947556] sr 2:0:0:0: [sr0] CDB:
Aug 29 15:51:12 NN kernel: [9852911.947557] Read(10): 28 00 00 00 06 f8 00 00 40 00

This was a classic medium error. No software problem. Not even a drive problem on the first hand.

"(Device or resource busy)" error comes from the attempt to open a device file with open(2) flag O_EXCL in its non-portable role for Linux devices. See here for open() peculiarities on CD burner device files.

mount(8) has the device open with that flag. Well behaved burn programs should use the flag too and thus learn when they try to use a mounted or burning drive.

readom uses it in order to avoid spoiling ongoing burn runs.

So for readom or burn programs one has to first unmount the medium. The advise to unmount before copying is not mandatory with dd and cp.

Answer to question about libburn based data reading:

One could try a dd_rescue-ish command of xorriso

xorriso -outdev /dev/sr0 -check_media use=outdev sector_map="$HOME"/cdrom_sector_map data_to="$HOME"/cdrom_copy.iso abort_file="$HOME"/cdrom_copy_abort --

The copy should emerge as file ~/cdrom_copy.iso. Read errors will be reported and copy attempts will go on with the next block. The file ~/cdrom_sector_map will record the pattern of failed and successful reads. Another read run will load it and then try only those blocks which were not yet copied successfully.

A successful run should end by a message like

Media checks :        lba ,       size , quality
Media region :          0 ,     359062 , + good

A run with remaining bad blocks would have "Media region" lines with "-" characters in the quality column. "+" indicates successfully read intervals of blocks. "0" indicates blocks which were not tried yet. (Between tracks they may stay that way. A CD-ROM is supposed to have only one track.)

CD Track-At-Once run-out blocks cause "-" quality. If this occurs only at one of the last two blocks of a CD, then most likely all payload blocks have been copied to ~/cdrom_copy.iso.

If you want to abort this quite stubborn program run then it is better to do in another shell:

touch "$HOME"/cdrom_copy_abort

If you kill the process instead, then the sector map will not be written and the next run will re-read already copied blocks.

After full success or with only the last one or two blocks missing you should next test whether no files in the copied ISO point to missing block addresses.

As superuser (or via sudo):

mkdir /mnt/iso
mount -o loop ...your.users.home.../cdrom_copy.iso /mnt/iso

which should report this note but no further error messages:

mount: /dev/loop0 is write-protected, mounting read-only

As normal user let tar read all file and consume the output by wc:

tar cf - /mnt/iso | wc

which should report no i/o error but only a warning and finally three numbers

tar: Removing leading `/' from member names
1343012 7725571 331386880

If the CD is readable enough to be mountable, then compare the files of cdrom_copy.iso and the CD by creating another mount directory and mount /dev/sr0:

mkdir /mnt/orig_cd
mount /dev/sr0 /mnt/orig_cd

and then compare both file trees. Pipe the output into less so that in case of many differences it does not flood your terminal

diff -q -r /mnt/orig_cd /mnt/iso 2>&1 | less

Empty output indicates no differences. Try with mounting a different CD and you should get lots of messages like

Only in /mnt/iso: ...some_name...
...
Only in /mnt/orig_cd: ...some_other_name...

If files with same relative path in both trees have different content you will see messages like

Files /mnt/cd_orig/...some_file... and /mnt/iso/...some_file... differ

When all is ok, then remove file ~/cdrom_sector_map so that it cannot keep xorriso from reading blocks from the next CD to which you have to apply this whole procedure.

  • 1
    I added a proposal to the end as "Answer to question about libburn based data reading:". – Thomas Schmitt Sep 22 '16 at 11:21
  • 1
    Looks good so far. See new end of my answer, beginning at "After full success or with only the last one or two blocks missing". – Thomas Schmitt Sep 24 '16 at 11:50
  • 1
    Added explanation how to compare mounted CD and mounted ISO image. – Thomas Schmitt Sep 24 '16 at 19:58
  • Now that everything is clear, i corrected the diagnosis of "i/o error" (CD read ahead bug, not bad medium). Further i redirected the stderr output of diff into the pipe to less. So one will see CD i/o error messages. – Thomas Schmitt Sep 25 '16 at 9:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.