HOWTO Packet Writing on CD-RW
From Gentoo Linux Wiki
| Installation • Kernel & Hardware • Networks • Portage • Software • System • X Server • Gaming • Non-x86 • Emulators • Misc |
Please format this article according to the guidelines and Wikification suggestions, then remove this notice {{Wikify}} from the article
Contents |
[edit] Goals
After this, you will be able to write CD-RW as a big floppy disc.
DVD-RW packet writing is functional as well with this configuration.
[edit] Building the kernel
[edit] Downloading and installing the patch
0. The following steps are not required since kernel version 2.6.10. If you are having trouble getting packet writing to work under 2.6.10 or later, make sure the modules for packet writing are loaded or buit in, and pass hdc=ide-cdrom in place of hdc=ide-scsi to your kernel at boot. This will make the kernel treat your drive as a standard block device when (re)writeable media is inserted.
1. Download the appropriate patch for your kernel version (if you don't know what kernel version you have installed, try uname -r in a terminal):
# cd ~ # wget http://w1.894.telia.com/~u89404340/patches/packet/2.6/packet-your_kernel_version.patch.bz2 # bunzip2 packet-your_kernel_version.bz2
Kernel patches can be found in http://w1.894.telia.com/~u89404340/patches/packet/
2. Change directory to your kernel version and install the patch
# cd /usr/src/linux # patch -p1 -i ~/packet-your_kernel_version.patch
[edit] Building the Kernel
3. Enter kernel configuration
# make menuconfig
4. Enable these options
Device Drivers ---->
Block Drivers ---->
<*> Packet writing on CD/DVD Media (EXPERIMENTAL)
(8) Freebuffers for data gathering
[ ] Enable write caching
File Systems ---->
CD-ROM/DVD Filesystems ---->
<*> UDF Filesystem Support
On 2.4 kernel series, UDF reading and writing are different options; enable both;
5. Build the kernel and copy it over (make sure you backup your kernel before doing it)
# make && make modules_install # mount /boot # cp arch/i386/boot/bzImage /boot/
[edit] Configure the system
6. Install udftools
# emerge sys-fs/udftools
and run the init script:
# rc-update add pktcdvd default # /etc/init.d/pktcdvd start
after that you might not need to do steps 7 and 8.
7. If you compiled it as a module, edit /etc/modules.d/aliases and add the following lines
# vim /etc/modules.d/aliases alias block-major-97 pktcdvd
8. Create a device node (only for older kernels and older udftools )
# mknod /dev/pktcdvd0 b 97 0
For newer kernels and udftools (1.0.0b-r4)
# mkdir /dev/pktcdvd
if there are any /dev/pktcdvd* charater- or blockdevices, just delete them!
Note: In kernel 2.6.8 you need to patch udftools with this: [1]
- tar zxvf udftools-1.0.0b2.tar.gz
- cd udftools-1.0.0b2
- bunzip -c ../udftools-1.0.0b3.patch.bz2 | patch -p1
Then re-create the tarball of udftools and put it in /usr/portage/distfiles.
- tar cvvf udftools-1.0.0b.tar ../udftools-1.0.0b2/
- gzip udftools1.0.0b.tar > /usr/portage/distfiles/udftools1.0.0b.tar.gz
And rebuild the digest.
# ebuild /usr/portage/sys-fs/udftools/udftools-1.0.0b.ebuild digest
9. Edit /etc/fstab
# vim /etc/fstab /dev/pktcdvd0 /mnt/cdrw udf noauto,noatime,rw,users 0 0 %If you have a 2.6.8 or newer kernel, the line above should be: /dev/pktcdvd/0 /mnt/cdrw udf noauto,noatime,rw,users 0 0
# mkdir /mnt/cdrw # chmod 0777 /mnt/cdrw
10. Reboot to the new kernel
[edit] Other Things
[edit] Formatting Disks
For CD-RWs do
$ cdrwtool -d /dev/scd0 -q
For DVD+RW (and probably DVD-RW) do
$ mkudffs /dev/pktcdvd/0
where "0" is the name you assigned during pktsetup, e.g.
$ pktsetup 0 /dev/hdc
If you get the error message
trying to change type of multiple extents
after trying to format a virgin dvd+rw, use dvd+rw-format e.g
$ dvd+rw-format /dev/hdc
this will "pre-format" the blank medium. After that, try mkudffs again.
If it's the first time you're mounting this cd, run (as root)
$ chmod 0777 /mnt/cdrw
[edit] Mounting CD-RW
$ mount /mnt/cdrw
[edit] Preparing the System for Writing
Edit this as needed and save as /etc/conf.d/cdrw
| File: /etc/conf.d/cdrw |
# List the CD-Rom drives you wish to enable packet writing on here. # Some examples follow: #cdrw_list="/dev/hdd" #cdrw_list="/dev/sr0 /dev/sr1 /dev/sr2" #cdrw_list="/dev/cdroms/cdrom0 /dev/cdroms/cdrom1" cdrw_list="/dev/cdroms/cdrom0" |
Save this file as /etc/init.d/cdrw
| File: /etc/init.d/cdrw |
#!/sbin/runscript
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: $
depend() {
need localmount
}
start() {
# Starting with kernel 2.6.8 there is a different syntax
# for the pktsetup program.
kernel_major=$(( `uname -r | cut -d'-' -f1 | cut -d'.' -f2` ))
kernel_minor=$(( `uname -r | cut -d'-' -f1 | cut -d'.' -f3` ))
local i
local minor=0
local retval=0
local last_result=0
if [ ! -e "/dev/pktcdvd" ]
then
/sbin/modprobe -a pktcdvd
fi
for i in ${cdrw_list}
do
ebegin "Enabling CD-RW packet writing on ${i}"
if [ ${kernel_major} -ge 6 ] && [ ${kernel_minor} -ge 8 ]
#then /usr/bin/pktsetup /dev/pktcdvd/${minor} ${i} >/dev/null 2>&1
then /usr/bin/pktsetup ${minor} ${i} >/dev/null 2>&1
#else /usr/bin/pktsetup /dev/pktcdvd${minor} ${i} >/dev/null 2>&1
else /usr/bin/pktsetup pktcdvd${minor} ${i} >/dev/null 2>&1
fi
if [ -b /dev/pktcdvd/${minor} ]
then last_result=0
else last_result=1
fi
retval=$(( ${retval} + ${last_result} ))
minor=$(( ${minor} + 1 ))
if [ ${last_result} -gt 0 ]
then
ewend ${last_result} "Failed to enable packet writing on ${i}"
fi
done
eend ${retval}
}
stop() {
# Starting with kernel 2.6.8 there is a different syntax
# for the pktsetup program.
kernel_major=$(( `uname -r | cut -d'-' -f1 | cut -d'.' -f2` ))
kernel_minor=$(( `uname -r | cut -d'-' -f1 | cut -d'.' -f3` ))
local i
local minor=0
local retval=0
local last_result=0
for i in ${cdrw_list}
do
ebegin "Disabling CD-RW packet writing on ${i}"
umount /dev/pktcdvd/${minor} >/dev/null 2>&1 || true
if [ ${kernel_major} -ge 6 ] && [ ${kernel_minor} -ge 8 ]
#then /usr/bin/pktsetup -d /dev/pktcdvd/${minor} >/dev/null 2>&1
then /usr/bin/pktsetup -d ${minor} >/dev/null 2>&1
#else /usr/bin/pktsetup -d /dev/pktcdvd${minor} >/dev/null 2>&1
else /usr/bin/pktsetup -d pktcdvd${minor} >/dev/null 2>&1
fi
if [ -b /dev/pktcdvd/${minor} ]
then last_result=1
else last_result=0
fi
retval=$(( ${retval} + ${last_result} ))
minor=$(( ${minor} + 1 ))
if [ ${last_result} -gt 0 ]
then
ewend ${last_result} "Failed to disable packet writing on ${i}"
fi
done
eend ${retval}
}
|
Make it executable
# chown root:daemon /etc/init.d/cdrw # chmod 0770 /etc/init.d/cdrw
Add it to the inittab
# rc-update add cdrw default
[edit] HAL configuration
If you want to let HAL handle the mounting operation the udf filesystem, use the following policy file:
| File: /etc/hal/fdi/policy/01-packet-writing.fdi |
<?xml version="1.0" encoding="UTF-8"?> <!-- -*- SGML -*- -->
<deviceinfo version="0.2">
<device>
<match key="block.is_volume" bool="true">
<match key="volume.is_disc" bool="true">
<match key="volume.fsusage" string="filesystem">
<match key="volume.fstype" string="udf">
<match key="block.device" string="/dev/dvd">
<merge key="volume.policy.desired_mount_point" type="string">packet</merge>
</match>
</match>
</match>
</match>
</match>
</device>
</deviceinfo>
|
Warning: Use this file with caution! You have to edit it so that it works on your system. Make sure you provide enough <matches> so nothing else gets crippled. Obviously, you have to add more <device> sections and desired mount points if you have more than one drive. Use the `hal-devices' command.
Do /etc/init.d/hald restart after you've made the changes.
Create one entry for iso9660 and one for udf in your fstab (/dev/dvd being your dvd drive):
/dev/dvd /media/dvd iso9660 noauto,ro,user,users,gid=users 0 0 /dev/dvd /media/packet udf noauto,noatime,rw,user,gid=users 0 0
This way, the correct filesystem will be mounted when a udf disc is in the drive.
[edit] Problems
`eject' doesn't seem to work anymore after an udf disc has been inserted. If I try it in thunar, it will unmount the volume, but not eject it (the device is still in the list). I can manually eject the disc now by pressing the drive's eject button. Instead, if I try it again, thunar will hang until I press the drive's eject button. It's not a problem with thunar, though. `eject' from the commandline shows the same behaviour. The command works if there's no media in the drive.
[edit] Resources
OpenSuse packet-writing mailing list
Original Forum Thread
HOWTO Supermount
HOWTO Install a Kernel Patch
HOWTO Submount
HOWTO Compile a Kernel Manually
Automounting in userspace with ivman
