Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Tutorials & Tips
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Tutorials & Tips
The place to find Ubuntu related Tips & Tricks.

 
Thread Tools Display Modes
Old February 12th, 2006   #1
dradul
Ubuntu Extra Shot
 
dradul's Avatar
 
Join Date: Apr 2005
Location: 2630m closer to the stars
My beans are hidden!
HOW-TO: Packet Writing without tears

Packet Writing Without Tears: How to use Rewritable Optical Media in Ubuntu
Pedro A. López-Valencia
python -c 'print "cGFsb3BlenZAZ21haWwuY29t".decode("base64")'

The Linux kernel supports packet writing on read-only and rewritable media since kernel 2.6.8, as was the case in Hoary. Yet I only managed to have it work consistently in Breezy. It took some head scratching, but then it hit like a truck: You don't need to be a rocket scientist to do it!!!. But trying to understand how to do it can make a grown man cry.

What the heck is Packet Writing?

Good question! One of the design goals of the UDF filesystem was to allow incremental data addition to optical media. That is, to be able to write packets of data. In essence it allows one to use a CD or a DVD as an oversized floppy disk. In fact, many of you may have used EasyCD, Roxio's Write-On-CD, Nero InCD, or some other commercial product in MS Windows to read and write CDs, particularly CDRWs, this way.

As it is the case with floppy disks, reliability is poor; any glitch and your data is done for. Furthermore many software vendors in the MS Windows world have managed to make their implementations incompatible to each other, to the point that you may not be able to open for writing a disk created with a different utility, and even fail to read it. And they may claim to use the same UDF format version!

In other words, if you think you will be doing your critical data backups with packet writing instead of old-fashioned CD mastering and burning or tape backups or whatnot, you are playing with fire. Now that I've given you dire warnings, let me tell you that packet writing has its uses. It is up to you to take the risk or not.

The ingredients

Although the kernel has support for packet writing, you need to install the user space tools to be able to access the kernel services. Enable the universe repositories and:
Code:
sudo apt-get install udftools
Now add the cd writer to the init files:
Code:
sudo <your_editor> /etc/default/udftools
In my particular case I'm using a CD writer in /dev/hdd, thus I edited the file to contain this line:
Code:
DEVICES="/dev/hdd"
Do read the comments in that file but don't bother trying to be creative with the device filenames defined in NEWINTNAMES, else you'll have access permissions trouble later on.

Now, set up your drive:
Code:
sudo /etc/init.d/udftools start
This init script loads the kernel module and sets up the link between the block device (/dev/hdd in this case) and the virtual packet drive device /dev/pktcdvd/0 (there is only one device defined and it gets the first alllocated name). If you want to know more, I strongly recommend you read the manual pages for mkudffs, cdrwtool and pktsetup.

Formatting your CD-RW

Take a CD-RW or DVD-/+RW and format it:
Code:
sudo cdrwtool -t 4 -d /dev/hdd -q
Go brew a carafe of cofee and grab some muffins. Drink slowly... There are several options you can set up including the UDF version, you'll find that information in the manual pages.

cdrwtool burns at a speed of 12x by default, yet most CDRWs and DVD-/+RWs, particularly the cheap ones, support slower burning speeds. 4x seems to be a very common maximum speed for rewritable media, so I've put it in the example above. It is always a good idea to define explicitly the max writing speed of your media, or formatting will fail.

Before you start formatting your CD, make sure that you have DMA active in your burner; else you'll get funny formatting errors and failures. By default, Ubuntu's kernels do not activate DMA busmastering on anything different to PATA disks, because older CD readers and burners tend to belly up when you activate DMA in the IDE bus and lock up the system.

In order to activate permanently DMA, you must edit your /etc/hdparm.conf. Suppose you have a CD or DVD burner in /dev/hdc then you would add the following lines:
Code:
/dev/hdc {
    dma = on
    io32_support = 1
}
/etc/hdparm.conf is read every time your box boots up. If you can't wait, you can activate the settings from the command line too. Open a terminal window and type:
Code:
sudo hdparm -c1 -d1 /dev/hdc
Mounting your cd

There is only one thing to consider. You need to use the special packet writing device, not the normal disk device!!! Like this:
Code:
sudo mount -t udf -o utf8,noatime /dev/pktcdvd/0 /your/mount/point
I've added the utf8 option because that's the default filesystem encoding in Ubuntu, and noatime because that reduces drastically the number of access writes to the disc. This is particularly important if using a DVD-/+RW, because writable DVDs are programmed to allow 1000 writes, not one more!!!

Making the CD/DVD-RW writable by you

Before you start using your CD-RW, you need to make it writable by other users different to root:
Code:
sudo chown 777 /your/mount/point/.
Note the dot at the end.

Making a permanent addition to your system

Now you are ready to set up your system to mount and unmount your CDs without effort. Create an entry in /media:
Code:
sudo mkdir -p /media/cdwriter
and add the following to /etc/fstab:
Code:
/dev/pktcdvd/0  /media/cdwriter  udf  user,noauto,noatime,utf8  0  0
You will be able to mount the CD/DVD-RW by double-clicking on an icon in the computer browser, if using Ubuntu. If using KDE, you are on your own.

Last edited by dradul; February 17th, 2006 at 09:41 AM..
dradul is offline   Reply With Quote
Old February 17th, 2006   #2
Zeroangel
Ubuntu Extra Shot
 
Zeroangel's Avatar
 
Join Date: Feb 2006
Location: Saskatoon, SK
Beans: 381
Ubuntu 9.04 Jaunty Jackalope
Send a message via MSN to Zeroangel
Re: HOW-TO: Packet Writing without tears

I seem to be getting illegal seek errors during formatting.

Code:
dave@ubuntu:~$ sudo cdrwtool -d /dev/hdc -q
Password:
using device /dev/hdc
672KB internal buffer
setting write speed to 12x
Settings for /dev/hdc:
        Fixed packets, size 32
        Mode-2 disc

I'm going to do a quick setup of /dev/hdc. The disc is going to be blanked and formatted with one big track. All data on the device will be lost!! Press CTRL-C to cancel now.
ENTER to continue.

Initiating quick disc blank
wait_cmd: Input/output error
Command failed: a1 01 00 00 00 00 00 00 00 00 00 00 - sense 05.30.00
blank disc: Illegal seek
dave@ubuntu:~$
I'm aware that it may be a firmware problem thats causing this, unfortunately I can't seem to update my firmware in Linux. Is there a workaround I can use to write UDF filesystem to the disk in this application?

mkudffs + dvd+rw-format haven't been working for me.
Zeroangel is offline   Reply With Quote
Old February 17th, 2006   #3
dradul
Ubuntu Extra Shot
 
dradul's Avatar
 
Join Date: Apr 2005
Location: 2630m closer to the stars
My beans are hidden!
Re: HOW-TO: Packet Writing without tears

Quote:
Originally Posted by Zeroangel
seem to be getting illegal seek errors during formatting.
Yes, that has happened to me as well. That would happen if you don't have DMA active in your CDRW block device. You can use
Code:
sudo hdparm -d1 /dev/hdc
before starting to format your CDRW, and add it to /etc/hdparm.conf so it is set up everytime your system boots up.

I forgot to mention it in the howto.

EDIT: Added.

Another thing I missed. cdrwtool defaults to burning to 12x. Most CD-RW and DVD-/+RW disks support slower sppeds and you should use the speed flag explicitly.

Last edited by dradul; February 17th, 2006 at 08:23 AM..
dradul is offline   Reply With Quote
Old February 19th, 2006   #4
dcstar
Ubuntu addict and loving it
 
Join Date: Feb 2005
Location: Melbourne, Australia
Beans: 7,836
Ubuntu 9.04 Jaunty Jackalope
Re: HOW-TO: Packet Writing without tears

I have my UDF set up in a similar manner to what has been described, I also have my UDF disk auto-mounted at boot up, here is how I did that:

http://ubuntuforums.org/showpost.php...18&postcount=2
__________________
Regards, David.

The Forum search function is useful for immediate help (give it a try).
Please mark your thread as "Solved" (using the Thread Tools) when appropriate.
dcstar is offline   Reply With Quote
Old February 19th, 2006   #5
dradul
Ubuntu Extra Shot
 
dradul's Avatar
 
Join Date: Apr 2005
Location: 2630m closer to the stars
My beans are hidden!
Re: HOW-TO: Packet Writing without tears

Quote:
Originally Posted by dcstar
I have my UDF set up in a similar manner to what has been described, I also have my UDF disk auto-mounted at boot up
When you create your mount points under /media, the gnome volume manager will automatically mount them unless you use the noauto option in fstab. I find it more practical to use the options noauto,user and mount the disk by hand, because that sets the euid and egid to my account's not root's.
dradul is offline   Reply With Quote
Old September 1st, 2006   #6
Cariboo1938
Dipped in Ubuntu
 
Cariboo1938's Avatar
 
Join Date: May 2006
Location: BC , Canada
My beans are hidden!
Ubuntu 8.04 Hardy Heron
Re: HOW-TO: Packet Writing without tears

Quote:
Originally Posted by dradul View Post
Packet Writing Without Tears: How to use Rewritable Optical Media in Ubuntu
Pedro A. López-Valencia
In my particular case I'm using a CD writer in /dev/hdd, thus I edited the file to contain this line:
Code:
DEVICES="/dev/hdd"
I have a DVD-R/W and a seperate CD-R/W drive installed. How do I know where I use them? hda, hdb, hdc, etc? Please help! I'm trying to get packet writing running since I first used Linux 2 years ago. Now I found Pedro's HowTo and it seems I'm very close, but still don't know how to continue?
Cariboo1938 is offline   Reply With Quote
Old September 2nd, 2006   #7
dradul
Ubuntu Extra Shot
 
dradul's Avatar
 
Join Date: Apr 2005
Location: 2630m closer to the stars
My beans are hidden!
Re: HOW-TO: Packet Writing without tears

Quote:
Originally Posted by Cariboo1938 View Post
I have a DVD-R/W and a seperate CD-R/W drive installed. How do I know where I use them? hda, hdb, hdc, etc? Please help! I'm trying to get packet writing running since I first used Linux 2 years ago. Now I found Pedro's HowTo and it seems I'm very close, but still don't know how to continue?
You can enable several devices in /etc/default/udftools (see the file for exact syntax). Now, on where are your burners, that depends on where you have them installed. Most older mainboards have 2 IDE interfaces, a primary and a secondary each capable of managing two PATA (Parallel ATA) disks, a master (disk0) and a slave (disk1). The custom has been to install the CD/DVD devices in the secondary bus, while leaving the primary for installing hard-drives (most BIOS would only boot from IDE0/disk0). IDE devices are seen by the Linux kernel as /dev/hd*, where "hda" is IDE0:disk0, "hdb" is IDE0:disk1, "hdc" is IDE1:disk0 and so on.

Newer mainboards come with only one IDE interface (for CD/DVD devices), and use SATA (Serial ATA) interfaces for hard-drives. Linux uses a SCSI emulation for the interface of such devices and therefore they are seen as /dev/sd*. In this case, the Cd/DVD devices would be in the primary IDE interface (IDE0) and will be seen as "hda" and "hdb".
dradul is offline   Reply With Quote
Old September 2nd, 2006   #8
Cariboo1938
Dipped in Ubuntu
 
Cariboo1938's Avatar
 
Join Date: May 2006
Location: BC , Canada
My beans are hidden!
Ubuntu 8.04 Hardy Heron
Re: HOW-TO: Packet Writing without tears

Quote:
Originally Posted by dradul View Post
You can enable several devices in /etc/default/udftools (see the file for exact syntax). Now, on where are your burners, that depends on where you have them installed. Most older mainboards have 2 IDE interfaces, a primary and a secondary each capable of managing two PATA (Parallel ATA) disks, a master (disk0) and a slave (disk1). The custom has been to install the CD/DVD devices in the secondary bus, while leaving the primary for installing hard-drives (most BIOS would only boot from IDE0/disk0). IDE devices are seen by the Linux kernel as /dev/hd*, where "hda" is IDE0:disk0, "hdb" is IDE0:disk1, "hdc" is IDE1:disk0 and so on.
Newer mainboards come with only one IDE interface (for CD/DVD devices), and use SATA (Serial ATA) interfaces for hard-drives. Linux uses a SCSI emulation for the interface of such devices and therefore they are seen as /dev/sd*. In this case, the Cd/DVD devices would be in the primary IDE interface (IDE0) and will be seen as "hda" and "hdb".
Hi dradul, and many thanks for this excellent explanation! Remains only one quick question to this naming issue:
The Device Manager tells me that the Parallel ATA controller has 2 IDE devices connected--Master device DVDRAM GSA-4160B and Slave device CDRAM GCE-8526B. So, during the Ubuntu installation the hardware was detected correctly. Now the question: Into which file is the information and the name of the two drives written? Is it in /etc/fstab?
Cariboo1938 is offline   Reply With Quote
Old September 2nd, 2006   #9
Cariboo1938
Dipped in Ubuntu
 
Cariboo1938's Avatar
 
Join Date: May 2006
Location: BC , Canada
My beans are hidden!
Ubuntu 8.04 Hardy Heron
Re: HOW-TO: Packet Writing without tears

Quote:
Originally Posted by dradul View Post
You can enable several devices in /etc/default/udftools (see the file for exact syntax).
Hello dradul, and once again thank you for your reply. I'm a little mixed up how to enable both of my optical drives. The line in /etc/default/udftools responsible for the enabling is DEVICES="/dev/cdrom", where I replace <cdrom> with hda (for the master device).
To enable the other drive, would I have to repeat this line? So my file would look like this?
DEVICES="/dev/hda"
DEVICES="/dev/hdb"

or is the entry rather:
DEVICES="/dev/hda /dev/hdb"???

Last edited by Cariboo1938; September 2nd, 2006 at 07:59 PM..
Cariboo1938 is offline   Reply With Quote
Old September 3rd, 2006   #10
dradul
Ubuntu Extra Shot
 
dradul's Avatar
 
Join Date: Apr 2005
Location: 2630m closer to the stars
My beans are hidden!
Re: HOW-TO: Packet Writing without tears

Quote:
Originally Posted by Cariboo1938 View Post
Code:
DEVICES="/dev/hda /dev/hdb"

That's the ticket.
dradul is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:11 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. lingonberry