UDF on CD-RW HowTo
I wanted easy drag-and-drop file operations similar to those I was accustomed to using in MSWindows with floppy disks, but I also wanted more file space on the media because floppy disks are too limited in file space. I didn't want to have to use K3B each time I needed to copy something to a CD-RW disk, so I began searching for a Linux solution to the problem.
I stumbled across "kdvd-ram-tools" and, after much fooling around and lots of help from the forum, I got it working with DVD-RAM disks, but the cost per disk was more than I wanted to pay and I had to order them because no one locally had them in stock. I didn't want to use USB sticks (I call them thumb drives) because I've known them to lose data and I find them expensive too.
While I was doing all of that fooling around trying to get "kdvd-ram-tools" working I learned about "cdrwtool", thanks to a tip from JohnBoy. I found "cdrwtool" in "udftools" in the repositories. I spent more time fiddling around trying to get that working and I came up with a solution, finally, that I posted here "
http://www.pclinuxos.com/forum/index.php/topic,65358.msg534964.html#msg534964" but after awhile I noticed that my script files sometimes didn't work (I'm not much of a bash programmer). I also discovered that "kdvd-ram-tools" was no longer available in PCLinuxOS-2010 so I could only use it in my PCLinuxOS-2009.x installations which I keep for some work I do. I decided to put some more effort into my script files because I also wanted to automate the UDF creation process for the CD-RW disks. Now, after too much explaining, here's what I finally came up with.
Make the following directory as root
/mnt/UdfCDThe UDF creation script:
#! /bin/bash
# script name: formatUdfCD
mntPath="/mnt/udfCD"
cdpktdvc="/dev/pktcdvd/pktcdvd0"
ismounted=`mount | grep $mntPath`
device="/dev/sr0"
speed=4
blocks=295264
if [[ -n $ismounted ]]; then
guiMessageDlg "$mntPath cannot be mounted. Exiting..."
exit 1
fi
zenity --question --title "Alert" --text "All data on the CDRW will be erased! OK to continue?"
err="$?"
if [[ $err -ne "0" ]]; then
guiMessageDlg "cdrwtool user cancelled. Exiting..." "5"
exit 1
fi
#: <<"COMMENTBLOCK"
#Do a fast blank of the disk
guiMessageDlg "Blanking the CDRW" "5"
cdrwtool -d$device -bfast -t$speed
err="$?"
if [[ $err -ne "0" ]]; then
guiMessageDlg "cdrwtool blank error. Exiting..."
exit 1
fi
#Do a format of the disk
guiMessageDlg "Formatting the CDRW" "5"
cdrwtool -d$device -m$blocks -t$speed
err="$?"
if [[ $err -ne "0" ]]; then
guiMessageDlg "cdrwtool format error. Exiting..."
exit 1
fi
#Build the udf file system on the disk
guiMessageDlg "Building the UDF file system on the CDRW" "5"
cdrwtool -d$device -u$blocks -t$speed
err="$?"
if [[ $err -ne "0" ]]; then
guiMessageDlg "cdrwtool udf build error. Exiting..."
exit 1
fi
#COMMENTBLOCK
if [[ ! -b $cdpktdvc ]]; then
err="999"
count=0
until [[ -b $cdpktdvc ]]; do
# Associate pktcdvd0 with hardware
pktsetup pktcdvd0 $device
err="$?"
[[ $count -gt 9 ]] && break
usleep 3333333
(( count++ ))
done
[[ $err -ne "0" ]] && ( guiMessageDlg "$cdpktdvc not mounted"; exit 1 )
fi
if [[ -z $ismounted && -b $cdpktdvc ]]; then
err="999"
count=0
until [[ -n $ismounted ]]; do
mount -t udf -o noatime,rw,user $cdpktdvc $mntPath
err="$?"
[[ $count -gt 9 ]] && break
usleep 3333333
ismounted=`mount | grep $mntPath`
(( count++ ))
done
if [[ $err -ne "0" ]]; then
guiMessageDlg "mount unsuccessful"
exit 1
else
chown -R root:cdwriter $mntPath/.
chmod g+w $mntPath/.
guiMessageDlg "UfdCD permissions set for read/write"
fi
if [ -n "$ismounted" ]; then
# Unmount /mnt/udfCD
umount $mntPath
# add error check
if [ $? -eq 0 ]; then
# Dis-associate pktcdvd0 from hardware
pktsetup -d pktcdvd0
if [ $? -eq 0 ]; then
cdrecord -dev=$device -dummy -eject >/dev/null
fi
else
guiMessageDlg "unmount $mntPath unsucessful"
fi
fi
else
guiMessageDlg "There was an error"
fi
The mount script
#! /bin/bash
# script name: mountUdfCD
mntPath="/mnt/udfCD"
cdpktdvc="/dev/pktcdvd/pktcdvd0"
ismounted=`mount | grep $mntPath`
device="/dev/sr0"
if [[ ! -b $cdpktdvc ]]; then
err="999"
count=0
until [[ -b $cdpktdvc ]]; do
# Associate pktcdvd0 with hardware
pktsetup pktcdvd0 $device
err="$?"
[[ $count -gt 9 ]] && break
usleep 3333333
(( count++ ))
done
if [[ $err -ne "0" ]]; then
guiMessageDlg "$cdpktdvc not mounted"
exit 1
fi
fi
if [[ -z $ismounted && -b $cdpktdvc ]]; then
err="999"
count=0
until [[ -n $ismounted ]]; do
mount -t udf -o noatime,rw,user $cdpktdvc $mntPath
err="$?"
[[ $count -gt 9 ]] && break
usleep 3333333
ismounted=`mount | grep $mntPath`
(( count++ ))
done
if [[ $err -ne "0" ]]; then
guiMessageDlg "mount unsuccessful"
exit 1
else
guiMessageDlg "mount successful"
fi
else
guiMessageDlg "There was an error"
fi
The unmount script
#! /bin/bash
# script name: unmountUdfCD
mntPath="/mnt/udfCD"
ismounted=`mount | grep $mntPath`
device="/dev/sr0"
if [ -n "$ismounted" ]; then
umount $mntPath
# add error check
if [ $? -eq 0 ]; then
# Dis-associate pktcdvd0 from hardware
pktsetup -d pktcdvd0
if [ $? -eq 0 ]; then
cdrecord -dev=$device -dummy -eject >/dev/null
fi
else
guiMessageDlg "unmount $mntPath unsucessful"
fi
fi
The message dialog script
#! /bin/bash
# script name: guiMessageDlg
if [ -n "$1" ]; then
DIALOG=${DIALOG=zenity --info --title="Note " }
if [ -n "$2" ]; then
$DIALOG --text="$1" --timeout="$2"
else
$DIALOG --text="$1"
fi
fi
In the above scripts the line
device="/dev/sr0" should be modified to fit the requirements of your system. In my PCLinuxOS-2009.x installations the line would read
device="/dev/hdc" and I placed the scripts in
/usr/local/binThe entry in /etc/fstab
# ufdCD (Needed for KwikDisk to recognise mount point)
/dev/pktcdvd/pktcdvd0 /mnt/udfCD none noatime,rw,user,noauto 0 0
I would have preferred to use kdesudo in PCLinuxOS-2010 but it wasn't available so I used kdesu instead. It requires you to enter your root password.
The KwikDisk mount command for PCLinuxOS-2010
kdesu -c mountUdfCDThe KwikDisk unmount command for PCLinuxOS-2010
kdesu -c unmountUdfCDIn the following, I used kdesudo which is available for PCLinuxOS-2009.x in the repositories. I like it because I can use my user password to run privileged commands after editing /etc/sudoers with visudo (vim-minimal required) as root to setup sudo.
The KwikDisk mount command for PCLinuxOS-2009.x
kdesudo mountUdfCDThe KwikDisk unmount command for PCLinuxOS-2009.x
kdesudo unmountUdfCDIn PCLinuxOS-2010, after a CD-RW is setup for UDF file use, the device notifier recognizes it as "LinuxUDF" and you can open it for file use by clicking on the entry in the device notifier but even though you can copy files to the disk this way, they don't seem to actually be written to the CD-RW disk. After the disk is ejected by using the eject button in the device notifier and then re-inserting the disk the data just written is not visible. I found it necessary to just ignore the device notifier in PCLinuxOS-2010 and use KwikDisk to mount/unmount the CD-RW using the scripts listed above.
In PCLinuxOS-2009.x, just select "Do Nothing" when the dialog pops up asking what should be done with the CD-RW just inserted and use KwikDisk to do the mount/unmount.
After the CD-RW is mounted, drag-and-drop file access is available in Konqueror as a non-root user. I've been using this method for awhile in PCLinusOS and I haven't had any difficulties with CD-RW disks. I've been using some Memorex 4X disks that I've had around for awhile. NOTE: it may be necessary after mounting to do a reload in Konqueror before the data on the CD-RW can be seen, but after that it works as expected.
I understand that "cdrwtool" will create a UDF file system on a DVD-RW, but not with these scripts. I tried it one time by setting a DVD-RW up manually that I used for a short while but then it came up with errors that I didn't know how to clear so I destroyed the DVD-RW and I haven't tried it since.