The definitive guide to CD writing on recent 2.6 kernels

Despite the fact it happened a few months ago, I still see people claiming that it is impossible to write CD’s with recent 2.6 kernels due to the internal changes. This is not true!

The first thing to check is that you aren’t using SCSI emulation. You don’t need this in Linux 2.6 – its ugly, and apparently doesn’t work. Disable SCSI emulation and use the new ATAPI features to burn “directly” (no extra configuration options needed other than general ATAPI cdrom support).

Next up, check you are running the latest version of cdrtools/cdrecord, even if this means going into the testing/unstable tree. The latest at the moment is cdrtools-2.01.01_alpha01-r1. The same applies for any other cd recording software you might be using.

It’s also important that you are running the latest stable kernel. This is currently 2.6.11. If you aren’t running this, then you are in no position to complain that things don’t work or file bugs.

A few months ago, the kernel code changed to restrict the commands which can be sent to CD writers. The restriction only allows commands that are related to CD reading and writing. The commands are listed in a table. At first, the table was too small, but thanks to user feedback I helped expand it to cover all commands needed for CD writing.

It seems that many users keep advocating a patch which completely bypasses the command table – and this patch is still included in some patchsets! This is no longer needed! If it does make a difference, then its a bug in either your CD writing software or the kernel command table is missing a valid command entry. If this is the case, send me an email, and I’ll fix things up with minimum effort involved. I’ve done this a few times before and I’m happy to do it again.

Another kernel change made at the same point in time resulted in the ability to write CD’s being restricted to users with write access to the CDROM device. That makes sense, right? (Previously you just needed read access.)

So the first thing to do is check that you have write access to your CDROM node. Assuming your CDROM drive is /dev/hdc, run the following:

# [ -w /dev/hdc ] && echo "OK" || echo "Fix up your permissions"

If you see a message telling you to fix up your permissions, the usual procedure is to use ls to see which group owns the node (usually cdrw or cdrom), add yourself to that group, and then try again. This requires that the group has access to write to the node too.

Moving on. Some software used to advise that you set the suid bit on your cdrecord binary. This means that cdrecord will always run with root priveleges, even if you execute it from a standard user account. Some kernel memory management changes broke cdrecord’s ability to run as root for a while. Even though it’s fixed now, it’s worth turning this off for the security implications alone:

# chmod -s /usr/bin/cdrecord

Note that xcdroast does weird things with suid bits too. For the purpose of testing, I suggest you keep away from xcdroast.

In terms of software usage, people seem to be historically used to running commands like cdrecord dev=ATAPI:0,0,0. An alternative method is cdrecord dev=/dev/hdc. There’s been an eternal debate as to which way should be encouraged – the cdrecord author doesn’t like the dev=/dev/hdc method, as you can probably gather from the warnings that appear. Right now, all you want to do is write CD’s, so no matter what you think, you need to use the dev=/dev/hdc method. Also, do avoid the dev=ATA:x,y,z notation too.

Another possible problem is that your CD writing software is opening up the CD node as read-only. The kernel will reject any write commands sent to it. The software needs to be modified to open the CD node as read-write. I fixed up some of the software such as dvd+rw-tools and cdrwtool a while back – but if there is any more problematic software, please let me know. (This is why its essential that you are running the latest versions of the software in question)

Finally, burn as your standard user account, not as root.

Hopefully this clears some things up. If you do experience problems after following the above precisely, please file a bug.

21 Responses to “The definitive guide to CD writing on recent 2.6 kernels”

  1. pharon Says:

    Thanks for clearing up that bit.

    But what about UDMA and write speeds that the warnings from cdrecord talk about? With dev=/dev/hdc I cannot write faster than 22X and with dev=ATAPI:0,0,0 I can go upto 32X. If I increase speed any higher in either situation, burn speed suddenly drops to 16X. My burner should theoretically be able to go upto 52X.

    Of course it could be a whole other issue causing my problem, but maybe you have insight about this one.

    thanks.

  2. fuoco Says:

    when I check the permissions on hdc, with ls -l, i see that it’s owned by myself (my user), with perms 600 (and a ‘b’ at the beginning which i dunno what it means). That means I’ll have read-write perms to the drive, but not all other users logged in at the same time? (right now there’s no other users logged in, but yet…) Is that a normal thing? I’m using udev and gnome-volume-manager in gnome, and haven’t changed any relevant settings.

    Thanks

  3. dsd Says:

    pharon: Make sure that you have DMA enabled and you are burning with burnfree – its a cdrecord option. Make sure your media supports 52x burning.

    fuoco: Sounds like pam-console, overwriting udev permissions every time you login. The person who last logged in will own the nodes. You probably want to get rid of pam, or at least remove the permissions part, unless you explicitly need it.

  4. pharon Says:

    I have DMA enabled in the bios and using hdparm, the cables are 80 pin cables, the media supports upto 52X, I am using driveropts=burnfree, the kernel doesn’t complain about DMA time-outs ( it used to do that when I had a bad HDD ),

    It seems that burnfree is always assuming the drive can’t burn fast enough, although the fifo and the buffer are almost always at 100%. Could it be really a bug, or is it something else?

  5. dsd Says:

    How about the speed= argument?
    Did you get better speeds before the burning changes took place (2.6.7)?
    Do any messages appear in dmesg relating to ‘unknown opcode’ ?
    Does it go any faster using cdrdao?

  6. Chewi Says:

    I investigated the problem with X-CD-Roast a few days ago and e-mailed the developer about it. He told me that he’d left Linux for OSX and wouldn’t be working on it anymore, complaining about constant changes giving him nothing but headaches. I think he was being a little short-sighted since it didn’t take me very long to figure out what the problem was. It’s easy to sort out, I’ll make a bug report about it soon.

  7. bob Says:

    Such stuff would be *nice* to be seen there:
    http://gentoo-wiki.com
    and linked
    very good info there ;)

  8. Daniel Brewer Says:

    Hi,

    First off, thanks for the excellant guide. Unfortunately though I am still having problems. I have followed your instructions ot the letter but still get errors. This is what I get:
    daniel@dan music $ cdrecord dev=/dev/hdd beach.iso
    cdrecord: No write mode specified.
    cdrecord: Asuming -tao mode.
    cdrecord: Future versions of cdrecord may have different drive dependent defaults.
    cdrecord: Continuing in 5 seconds…
    Cdrecord-Clone 2.01.01a01 (i686-pc-linux-gnu) Copyright (C) 1995-2004 Jörg Schilling
    on-the-fly encryption (version 1.0-rc1) built-in, (C) 2004,2005 Maximilian Decker
    ….
    cdrecord: Warning: Running on Linux-2.6.11-gentoo-r6
    cdrecord: There are unsettled issues with Linux-2.5 and newer.
    cdrecord: If you have unexpected problems, please try Linux-2.4 or Solaris.
    cdrecord: Cannot allocate memory. WARNING: Cannot do mlockall(2).
    cdrecord: WARNING: This causes a high risk for buffer underruns.
    scsidev: ‘/dev/hdd’
    devname: ‘/dev/hdd’
    scsibus: -2 target: -2 lun: -2
    Warning: Open by ‘devname’ is unintentional and not supported.
    Linux sg driver version: 3.5.27
    Using libscg version ‘schily-0.8′.
    Device type : Removable CD-ROM
    Version : 0
    Response Format: 1
    Vendor_info : ‘CyberDrv’
    Identifikation : ‘CW038D CD-R/RW ‘
    Revision : ’120C’
    Device seems to be: Generic mmc CD-RW.
    Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).
    Driver flags : MMC-2 SWABAUDIO BURNFREE
    Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R16 RAW/R96P RAW/R96R

    And then it just freezes. We /var/log/messages showing the following:
    Apr 19 20:36:56 dan hdd: drive_cmd: error=0×04 { AbortedCommand }
    Apr 19 20:36:56 dan ide: failed opcode was: 0xec
    Apr 19 20:37:06 dan hdd: irq timeout: status=0xd0 { Busy }
    Apr 19 20:37:06 dan ide: failed opcode was: 0xa1
    Apr 19 20:37:11 dan hdd: status timeout: status=0xd0 { Busy }
    Apr 19 20:37:11 dan ide: failed opcode was: unknown
    Apr 19 20:37:11 dan hdd: DMA disabled
    Apr 19 20:37:11 dan hdd: drive not ready for command
    Apr 19 20:37:11 dan hdd: ATAPI reset complete
    Apr 19 20:38:38 dan hdd: lost interrupt
    Apr 19 20:39:18 dan hdd: lost interrupt
    Apr 19 20:41:18 dan hdd: lost interrupt
    Apr 19 20:41:58 dan hdd: lost interrupt
    Apr 19 20:42:38 dan hdd: lost interrupt
    Apr 19 20:43:18 dan hdd: lost interrupt
    Apr 19 20:39:58 dan hdd: lost interrupt
    Apr 19 20:40:38 dan hdd: lost interrupt
    …..

    And so on. Any ideas what is going wrong? Any help would be great. Note that I can record using cdrdao just fine.

    Thanks

  9. Daniel Brewer Says:

    Note that even though it says “dan hdd: DMA disabled” I have enabled it using hdparm.

  10. dsd Says:

    It disabled DMA because it had trouble accessing it through DMA. Does reading cd’s work flawlessly? Do any “unknown opcode” messages appear in dmesg?

  11. pharon Says:

    thanks for your reply.

    Actually performance improved with new kernel releases ( regardless of the changes ). I think it has to do with the recent IDE DMA cleanups.

    As I said when I use any speed=x where x is bigger than 32 , burnfree kicks in when the speed goes above 32X , although at the end of the burn cdrecord says burnfree was never needed.

    back in 2.4 kernel days I did have opcode errors in demsg. now I never get them.

    I never tried with cdrdao, I don’t use it.. does it usuallt make a difference?

  12. dsd Says:

    The “unknown opcode” messages I’m thinking of would never have been produced by 2.4 as they are specific to the 2.6 command filter.

    Burning with cdrdao is useful because its completely separate from cdrecord. The issues you are seeing might well be problems with cdrecord as opposed to kernel stuff.

    When you say performance has now improved, do you mean that everything is fine and dandy now with the latest kernels?

  13. pharon Says:

    I must have mixed things up. I remeber older kernel ( not sure now 2.4 or early 2.6 ) produced errors similar to ” DMA reset ” and ” unkown command sent to scsi device”, if I remeber correctly. That was when I was using scsi emulation. So yeah maybe it wasn’t “unkown opcode”. I can’t make sure now because I don’t have these kernels around.

    Performance has improved relatively, older kernels couldn’t write faster than 22X now I can get 32X. But this is still not the performance expected from a 52X writer. Back in the days of windows ( I don’t have windows installed now ) I could burn at 40X and more.

    I know it’s a silly difference, but I just want to know where to file a bug reprot. kernel ? cdrecord ? or maybe broken hardware.

    I will try cdrdao and see if there is any difference.

    Thanks.

  14. Michael Says:

    I’m also having problems writing with a SONY burner. It should write at 48x, but only burns at 4x, and won’t read many good CDs, CDs that work fine in my mutch older DVD/CD-ROM.

    DMA is enabled in the bios for both drives, but disabled only for /dev/hdd (the burner) by the OS at boot, as reported by dmesg…
    ====================
    mydebian:/home/nume# dmesg|grep hdd
    ide1: BM-DMA at 0xb808-0xb80f, BIOS settings: hdc:DMA, hdd:DMA
    hdd: SONY CD-RW CRX215E1, ATAPI CD/DVD-ROM drive
    hdd: ATAPI 40X CD-ROM CD-R/RW drive, 2048kB Cache, UDMA(33)
    hdd: irq timeout: status=0xd0 { Busy }
    hdd: irq timeout: error=0×00
    hdd: DMA disabled
    hdd: ATAPI reset complete
    hdd: irq timeout: status=0xd0 { Busy }
    hdd: irq timeout: error=0×00
    hdd: ATAPI reset complete
    hdd: irq timeout: status=0xd0 { Busy }
    hdd: irq timeout: error=0×00
    hdd: ATAPI reset complete
    hdd: irq timeout: status=0xd0 { Busy }
    hdd: irq timeout: error=0×00
    hdd: DMA disabled
    hdd: ATAPI reset complete
    ====================

    using hdparm -d 1 /dev/hdd doesn’t seem to make a difference either.

    I’m running Debian Sarge with kernel 2.6.7 and otherwise fully upgraded as of yesterday. I’ll look for a newer kernel in Sid, Do you think that could be the problem?

  15. Shawn Says:

    Recently I decided to try kernel 2.6.13.4 and was happy to see the annoying error “drive appears confused� that plagued all versions above 2.6.10 has been fixed. Unfortunately, the ability to write to CD/DVD still seems buggy given the permission problems in kernel 2.6.x. I was very happy once I cam across your suggestion to enable DMA with hdparm because even though there are still permission issues I once again can write CD/DVD without having to go back to kernel version 2.6.10. Thanks again! Shawn

  16. linxlvr Says:

    Thank you for this page on 2.6.x cdr. It bailed me out when I was about ready to give it up. One note though. In the snippet for checking write perms, the exclamation point on the end of the echo quote made the snippet puke. Might want to change that.
    TY again for a wonderful guide where none others worked. :-)

    dw

  17. dsd Says:

    Thanks, changed.

  18. panoramix Says:

    After update to Mandriva 2006.0 Powerpack from Mandrake 10.1, I find out my old CD toaster RICOH CD-R/RW MP7083A it doesn’t work anymore even just when I tried to insert in a CD the device “freeze” the system.

    I googled and it seems to me the prob is something about devfs or about new 2.6.12.12 kernel but as I’m a such of almost dummy newbie I’m not able to fix it. Here some outputs:

    Note.- devfs changes “dev/hdc” to “/dev/ide/host0/bus1/target0/lun0/cd”

    [panoramix@panoramix ~]$ ls -la /dev/hdc
    brw-rw—- 1 panoramix cdrom 22, 0 ene 12 00:57 /dev/hdc
    [panoramix@panoramix ~]$ ls -la /dev/ide/host0/bus1/target0/lun0/cd
    lrwxrwxrwx 1 root root 18 ene 12 00:57 /dev/ide/host0/bus1/target0/lun0/cd -> ../../../../../hdc

    I tested changing perms as follows and rebooting…

    root@panoramix /]# chown root.cdrom /dev/ide/host0/bus1/target0/lun0/cd
    [root@panoramix /]# chmod 666 /dev/ide/host0/bus1/target0/lun0/cd

    …but the prob still out there. I checked out:

    [panoramix@panoramix ~]$ cdrecord dev=/dev/hdc -checkdrive
    Cdrecord-Clone 2.01.01a03-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2005 Jörg Schilling
    Note: This version is an unofficial (modified) version with DVD support
    Note: and therefore may have bugs that are not present in the original.
    Note: Please send bug reports or support requests to warly at mandriva.com.
    Note: The author of cdrecord should not be bothered with problems in this version.
    scsidev: ‘/dev/hdc’
    devname: ‘/dev/hdc’
    scsibus: -2 target: -2 lun: -2
    Warning: Open by ‘devname’ is unintentional and not supported.
    Linux sg driver version: 3.5.27
    Using libscg version ‘schily-0.8′.
    Device type : Removable CD-ROM
    Version : 0
    Response Format: 1
    Vendor_info : ‘RICOH ‘
    Identifikation : ‘CD-R/RW MP7083A ‘
    Revision : ’1.20′
    Device seems to be: Generic mmc CD-RW.
    Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).
    Driver flags : MMC SWABAUDIO
    Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R96R

    …and in order to compare

    [root@panoramix panoramix]# cdrecord dev=/dev/ide/host0/bus1/target0/lun0/cd -checkdrive
    Cdrecord-Clone 2.01.01a03-dvd (i686-pc-linux-gnu) Copyright (C) 1995-2005 Jörg Schilling
    Note: This version is an unofficial (modified) version with DVD support
    Note: and therefore may have bugs that are not present in the original.
    Note: Please send bug reports or support requests to warly at mandriva.com.
    Note: The author of cdrecord should not be bothered with problems in this version.
    scsidev: ‘/dev/ide/host0/bus1/target0/lun0/cd’
    devname: ‘/dev/ide/host0/bus1/target0/lun0/cd’
    scsibus: -2 target: -2 lun: -2
    Warning: Open by ‘devname’ is unintentional and not supported.
    Linux sg driver version: 3.5.27
    Using libscg version ‘schily-0.8′.
    Device type : Removable CD-ROM
    Version : 0
    Response Format: 1
    Vendor_info : ‘RICOH ‘
    Identifikation : ‘CD-R/RW MP7083A ‘
    Revision : ’1.20′
    Device seems to be: Generic mmc CD-RW.
    Using generic SCSI-3/mmc CD-R/CD-RW driver (mmc_cdr).
    Driver flags : MMC SWABAUDIO
    Supported modes: TAO PACKET SAO SAO/R96P SAO/R96R RAW/R96R

    IMHO nothing wrong.

    I tested including into lilo.conf “hdc=ide-scsi and in fact the device is mounted but the system doesn’t recognize it.

    panoramix@panoramix /]$ ls -la /dev/cdrom3
    ls: /dev/cdrom3: No existe el fichero o el directorio

    I also tested “playing” with /etc/modules.conf, /etc/devfs, /etc/default and others but nothing seems to work. This is my /etc/modules.devfs connfig

    # /etc/modules.devfs
    # Richard Gooch 24-MAR-2002
    #
    # THIS IS AN AUTOMATICALLY GENERATED FILE. DO NOT EDIT!!!
    # THIS FILE WILL BE OVERWRITTEN EACH TIME YOU INSTALL DEVFSD!!!
    # Modify /etc/modules.conf instead.
    # This file comes with devfsd-vDEVFSD-VERSION which is available from:
    # http://www.atnf.csiro.au/~rgooch/linux/
    # or directly from:
    # ftp://ftp.atnf.csiro.au/pub/people/rgooch/linux/daemons/devfsd-vDEVFSD-VERSION.tar.gz

    ###############################################################################
    # Sample configurations that you may want to place in /etc/modules.conf
    #
    #alias sound-slot-0 sb
    #alias /dev/v4l bttv
    #alias /dev/misc/watchdog pcwd
    #alias gen-md raid0
    #alias /dev/joysticks joystick
    #probeall scsi_hostadapter sym53c8xx

    ###############################################################################
    # Generic section: do not change or copy
    #
    # All HDDs
    probeall /dev/discs scsi_hostadapter sd_mod ide-probe-mod ide-disk ide-floppy DAC960
    alias /dev/discs/* /dev/discs

    # All CD-ROMs
    probeall /dev/cdroms scsi_hostadapter sr_mod ide-probe-mod ide-cd cdrom
    alias /dev/cdroms/* /dev/cdroms
    alias /dev/cdrom /dev/cdroms

    # All tapes
    probeall /dev/tapes scsi_hostadapter st ide-probe-mod ide-tape
    alias /dev/tapes/* /dev/tapes

    # All SCSI devices
    probeall /dev/scsi scsi_hostadapter sd_mod sr_mod st sg

    # All IDE devices
    probeall /dev/ide ide-probe-mod ide-disk ide-cd ide-tape ide-floppy
    alias /dev/hd* /dev/ide

    # IDE CD-ROMs
    alias /dev/ide/*/cd ide-cd

    # SCSI HDDs
    probeall /dev/sd scsi_hostadapter sd_mod
    alias /dev/sd* /dev/sd

    # SCSI CD-ROMs
    probeall /dev/sr scsi_hostadapter sr_mod
    probeall /dev/scd scsi_hostadapter sr_mod
    alias /dev/scd* /dev/scd
    alias /dev/scsi/*/cd /dev/scd

    # SCSI tapes
    probeall /dev/st scsi_hostadapter st
    alias /dev/st* /dev/st
    alias /dev/nst* /dev/st

    # SCSI generic
    probeall /dev/sg scsi_hostadapter sg
    alias /dev/sg* /dev/sg
    alias /dev/scsi/*/generic /dev/sg
    alias /dev/pg /dev/sg
    alias /dev/pg* /dev/sg

    # Floppies
    alias /dev/floppy floppy
    alias /dev/fd* floppy

    # RAMDISCs
    alias /dev/rd rd
    alias /dev/ram* rd

    # Loop devices
    alias /dev/loop* loop

    # Meta devices
    alias /dev/md* gen-md

    # Parallel port printers
    alias /dev/printers* lp
    alias /dev/lp* /dev/printers

    # Soundcard
    #alias /dev/sound sound-slot-0
    #alias /dev/audio /dev/sound
    #alias /dev/mixer /dev/sound
    #alias /dev/dsp /dev/sound
    #alias /dev/dspW /dev/sound
    #alias /dev/midi /dev/sound

    # Joysticks
    alias /dev/js* /dev/joysticks

    # Serial ports
    alias /dev/tts* serial
    alias /dev/ttyS* /dev/tts
    alias /dev/cua* /dev/tts

    # Input devices
    alias /dev/input/mouse* mousedev

    # Miscellaneous devices
    alias /dev/misc/atibm atixlmouse
    alias /dev/misc/inportbm msbusmouse
    alias /dev/misc/logibm busmouse
    alias /dev/misc/rtc rtc
    alias /dev/misc/agpgart agpgart
    alias /dev/rtc /dev/misc/rtc

    # PPP devices
    alias /dev/ppp* ppp_generic

    # Video capture devices
    alias /dev/video* /dev/v4l
    alias /dev/vbi* /dev/v4l

    # agpgart
    alias /dev/agpgart agpgart
    alias /dev/dri* agpgart

    # Irda devices
    alias /dev/ircomm ircomm-tty
    alias /dev/ircomm* /dev/ircomm

    # Raw I/O devices
    alias /dev/rawctl /dev/raw

    # Nvidia driver
    alias /dev/nvidia* NVdriver

    # Pull in the configuration file. Do this last because modprobe(8) processes in
    # per^H^H^Hreverse order and the sysadmin may want to over-ride what is in the
    # generic file
    include /etc/modules.conf

    If I load Knoppix everything is OK and the toaster works fine (I gess this is the only way I get to make backup!!)

    This is my first big challenge with Linux and my one and only neuron really wants to win so it would be appreciated any kind of help

    PD.- Sorry for my english

    TIA

  19. pabloa Says:

    For Madriva just include your user in “cdwriter” group. You will be able to use de cd burner to 16x or less.. but at least you will can burn cds!

  20. (( �(�´ω`)� 。oO( デスクトップ生中継 ) Says:

    (( �(�゚ ω゚)� < CD-R内機密情報処分法

    �ん�もん����・・

  21. Michael Fortenberry Says:

    Hi,
    I have a problem using 82801 FB/FBM/FR/FW/FRW (ICH6 Family) PCI Express. in a Dell XPS Gen3 system. One one point I had cdrw and dvd under /dev/hdc and /dev/hdd (as far as I recollect) but someone on gentoo forums had suggested I go SCSI and get DMA for free using /dev/sg or /dev/sr. That didn’t work and now I can’t get back to seeing my cdrw and dvd at all. I’ve posted on forums and no one seems able to help. Is it possible you could help me figure this out and get my cdrw and dvd back ? I’m a software developer, but unfortunately not very experienced at hard ware as regards Linux. I’m on Gentoo 2.6.17-r4 kernel with 3Gig memory and two SATA HardDrivers as sda and sdb.

Leave a Reply

You must be logged in to post a comment.