How do I write CD at Debian Linux command prompt

We have couple of Debian Linux boxes with CD/DVD combo drive. We have an automated solution over network to backup all data everyday. However recently we decided to make backup of logs and few modified application on a CD. Don’t ask me why but my manager asked me to do so. He said if not possible to take backup using command line fetch all files using ftp/http to windows XP and then write them :/?

Since I was aware of command line based cd-writing utilities, I told him I can do it on server itself. Here is my server setup:

P4 System running Debain Linux with custom compile 2.6.xx.xx series kernel. In order to write CDs at command prompt you need programs:
1)mkisofs – Create an ISO file image so that cdrecord can use the same to burn on a CD.
2)cdrecord – It is a utility capable of burning an actual disc i.e. ISO images created with mkisofs.
Since these packages were not installed I quickly run the commands to install it:
# apt-get install mkisofs
# apt-get install cdrecord

Configure cdrecord to write a CD

Under kernel version 2.6 you would not want to use ide-scsi for
CD-writing, the new kernel provides a superior access method that finally supports DMA access when writing CDs. Find out the device name used by your cdwriter i.e. find out the virtual SCSI ID of your device:
# cdrecord dev=ATA: -scanbusOutput:

Cdrecord-Clone 2.01a34 (i686-pc-linux-gnu)
Copyright (C) 1995-2004 Jrg Schilling
scsidev: 'ATA:'
devname: 'ATA'
scsibus: -1 target: -1 lun: -1
Warning: Using badly designed ATAPI via /dev/hd*
interface.
Linux sg driver version: 3.5.27
Using libscg version 'schily-0.8'.
scsibus1:
 1,0,0 100) 'SONY' 'CD-Writer' '1.0g'
 1,1,0 101) *
 1,2,0 102) *
 1,3,0 103) *
 1,4,0 104) *
 1,5,0 105) *
 1,6,0 106) *
 1.7.0 107) *

As you see SONY CD-WRITER at 1,0,0. The comma separated number you need to pass to command line option as -dev=1,0,0. You can write an ISO image to CD with the following command:
# cdrecord -v -dev=ATA:1,0,0 speed=4 mydata.iso

Where,

  • -speed=XX : Specify writing speed.
  • -v : Verbose output.
  • -dev : The virtual SCSI ID of your device

Here is an example, to create backup of /home/hosting-app/ directory:

a) Create an ISO file that can be opened on both windows and Linux computer:
$ mkisofs -v -o /tmp/happ.iso -R /home/hosting-app

b) Write an ISO (happ.iso) to CD i.e. burn an image:
$ cdrecord -v -dev=ATA:1,0,0 speed=4 /tmp/happ.iso

Read man pages of cdrecord and mkisofs for more information.

Update: The latest version of Debian Linux, try updated package called wodim.


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 7 comments so far... add one


CategoryList of Unix and Linux commands
Disk space analyzersdf duf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Modern utilitiesbat exa
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg glances gtop jobs killall kill pidof pstree pwdx time vtop
Searchingag grep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
7 comments… add one
  • imp Sep 11, 2005 @ 20:52

    Or, you can simply use BashBurn:

    http://bashburn.sourceforge.net/

  • imp Sep 11, 2005 @ 20:54

    …when you want to do it from command line, but interactively.

  • Rock Da Linux Sep 12, 2005 @ 0:10

    Thanks imp pointing out nice little tool 🙂

  • Allotment Mar 23, 2007 @ 13:21

    debain typo in title

  • 🐧 nixCraft Mar 23, 2007 @ 14:20

    Allotment,

    Thanks for heads up!

  • sujith Aug 28, 2009 @ 6:29

    This brief explanation is simple and very usable.we need to know how to configure if it is a SATA CD/DVD writer?

  • Anonymous Jun 22, 2010 @ 18:45

    [code]
    WARNING: the ATA: method is considered deprecated on modern kernels!
    Use –devices to display the native names.
    [/code]

    Update please?

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum