Typo
[linux_from_scratch_hints.git] / OLD / cdrw-hint.txt
blobbe468a23726a5426bb7e08257725a04971e00139
1 TITLE:          CD-RW UDF (Packet-CD) filesystem
2 LFS VERSION:    3.3 and beyond
3 AUTHOR:         Richard Downing <richard.downing@bcs.org.uk>
5 SYNOPSIS:
6         How to set up LFS to be able to Mount CD-RW drives READ-WRITE.
8 HINT:
10 **** WARNING ****
11 This hint is obsolete and stored here only for archival purposes.
12 Following this hint may damage your hardware in some cases.
13 This hint is superseded by the instructions in the BLFS book.
15 Background.
16 -----------
17 Recent 2.4.x kernels, as used in LFS from Version 3.3, support the UDF
18 filesystem for read only access.  The UDF filesystem is a standard used for
19 CD-RW drives (and CD-R and DVD-RAM etc.)  To find out more about the UDF
20 filesystem you should check out the Standards Body's websites at
21 http://www.osta.org and http://www.ecma.org - I shan't elaborate further here.
23 The problem is that WRITE access isn't supported, so if you have a CD-RW drive
24 you can't use Linux to write to it with a UDF filesystem, all you can do is
25 write Disk-at-a-time or Track-at-a-time with CDrecord and friends (see the BLFS
26 book for how-to on that).
28 If, on the other hand, you were using, God forbid, Microsoft Windows (TM), then
29 you could 'buy' Adaptec CDDirect, or HP DLA to give you Drive-Letter-Access
30 to the drive, just as if it were a (rather slow) fixed disk.  These utilities 
31 are often bundled with the drives, which doesn't help if you want to use Linux!
33 But, fear not, for the courageous help is at hand in the form of a Kernel Patch
34 to provide Packet-CD access.  This, combined with some simple tools, allows you
35 to provide a full read-write capability as a mounted UDF filestore.  Hopefully, 
36 this facility will be incorporated in 2.6 kernels when they arrive.
38 This hint is how I did it, and only applies to CD-RW drives, I understand that 
39 the same approach can be used by those lucky enough to be able to afford DVD-RAM
40 drives!  The following websites were my primary sources of information, so start
41 there:
43 for the kernel patches:   http://w1.894.telia.com/~u89404340/patches/packet/
44 for the usenet archive:   http://lists.suse.com/archive/packet-writing/
45 for the UDF tools:        http://sourceforge.net/projects/linux-udf
47 Obtain the right patch and apply it to your Kernel.
48 ---------------------------------------------------
50 >From the kernel patch site above download the patch for the version of the
51 kernel you are using. If you are using  2.4.20, get the packet-2.4.20.patch.  If 
52 you are using linux 2.4.19, then get patch-2.4.19-2.patch.Check that the patch 
53 you get is the latest dated for your kernel, they seem tobe updated quite often 
54 (see the Usenet Archives for why, when etc..)
56 If you are using a '-pre' or '-ac' kernel you may have to try the nearest patch 
57 and then apply any missed chunks manually.  This has been known to work, but you 
58 are on your own.  You will know if this applies to you.
60 Become superuser and move to your linux source directory, then 
61 apply the patch with:
63     patch -Np1 -i packet-2.4.20.patch
65 Now run 'make xconfig', or whatever version of kernel config you use (the LFS 
66 book uses  'make menuconfig', which is fine)
68 Go to the section on 'Block Devices' and select:
69     Packet writing on CD/DVD media
71 If you are into modules you can do it that way as I now do.
73 Now go to the section on 'File systems' and select the following:
74     UDF files systems support (read only)
75     UDF write support (DANGEROUS)
77 Despite the note on this latter option saying it only applies to fixed disks and
78 DVD-RAM, the patch will make it work with CD-RW too!
80 Select 'Save and Exit', then build your new kernel exactly as in the LFS book
81 with:
83     make bzImage
85 then copy the resulting kernel to /boot as, say, vmlinuz-2.4.19-UDF.
87 If you are using modules, you now need to
89    make modules
90    make modules_install
91    
92 The packet writing module is called pktcdvd.o.
94 I use GRUB as a bootloader, so you will need to read the book and hints on lilo
95 if you use that, but set up your boot loader to be able to boot either your old
96 kernel or this new one. (Always keep the old kernel bootable, just in case...)
98 Now reboot with the new kernel, it should be almost identical to your old one.
100 Note: I think that if you built the packet driver as a module, you need to add:
101     alias block-major-97 pktcdvd
102 to your /etc/modules.conf file.
104 Make the Packet Driver device file.
105 -----------------------------------
107 As superuser, make the file(s) in /dev with:
109   mknod /dev/pktcdvd0 b 97 0
110   mknod /dev/pktcdvd1 b 97 1
111   etc...
113 If you want ordinary users to be able to use CD-RW too, then:
114   chmod 666 /dev/pktcdvd*
115   
116 Obtain and Unpack the UDFtools package.
117 ---------------------------------------
119 Download the latest package from: http://sourceforge.net/projects/linux-udf,
120 the version I used was 1.0.0b2.
122 Unpack this is the usual way and build it with:
124 ./configure --prefix=/usr &&
125 make &&
126 make install
128 You now have three new programs in /usr/bin, complete with man pages which I 
129 suggest you read about now.:
131    cdrwtool - a tool to do various jobs on your CD-RW drive and disks.
132    mkudffs  - to create an UDF filesystem (on your hard disk if you want)
133    pktsetup - a tool to setup and tear down packet drive associations.
134    
135 Using the tools.
136 ----------------
138 Lets suppose you have a CD-RW disk straight out of the box, and want to prepare
139 it for use.  Like me, your CD-RW drive is on /dev/scd0.
141     cdrwtool -d /dev/scd0 -q
143 will format the new disk.  (By the way, unlike CDRecord, UDFtools don't need
144 ide-atapi devices to be made fake scsi devices)
146     pktsetup /dev/pktcdvd0 /dev/scd0
148 associates a packet-driver with your CD-RW drive (this doesn't survive a 
149 reboot).
150     mount /dev/pktcdvd0 /mnt/cdrom -t udf -o rw,noatime
152 will mount your new disk as a read-write filesystem, all ready to use, just like
153 any other hard disk.  ('noatime' just speeds things up by not updating the 
154 access times, CD-RW can be a little slow)
156 Then you can 'umount /dev/pktcdvd0' in the usual way, when you're done.
158 Tighter Integration.
159 ----------------------
161 I have gone a little further and added the following bootscripts to my 
162 system, so that the packet writing elements are set up every time I boot :
164 cat /etc/rc.d/init.d/packetwrite << "EOF"
165 #!/bin/bash
166 # Begin $rc_base/init.d/packetwrite
168 # Based on sysklogd script from LFS-3.1 and earlier.
169 # Rewritten by the blessed Gerard Beekmans
170 # gerard@linuxfromscratch.org
172 # Trivial usage for packet writing added by
173 # Richard Downing - richard.downing@bcs.org.uk
175 source /etc/sysconfig/rc
176 source $rc_functions
178 case "$1" in
179         start)
180                 echo "Prepare CDRW drive for Packet Writing..."
181                 pktsetup /dev/pktcdvd0 /dev/scd0
182                 evaluate_retval
183                 ;;
185         stop)
186                 echo "Tearing down CDRW for Packet Writing..."
187                 pktsetup -d /dev/pktcdvd0
188                 evaluate_retval
189                 ;;
191         *)
192                 echo "Usage: $0 {start|stop}"
193                 exit 1
194                 ;;
195 esac
197 # End $rc_base/init.d/packetwrite
200 chmod +x /etc/rc.d/init.d/packetwrite
201 cd /etc/rc.d/rc3.d
202 ln -s ../init.d/packetwrite S85packetwrite
203 cd ../rc0.d
204 ln -s ../init.d/packetwrite K10packetwrite
206 I then create a mount point:
208 mkdir /mnt/cdrw
210 and add the following line to /etc/fstab:
212 /dev/pktcdvd0 /mnt/cdrw udf rw,noauto,noatime,user 0 0
214 which allows any user to mount the CDRW with:
216 mount /mnt/cdrw
218 NOTE the noauto switch is needed as the packerwriter may not be initialised
219 when mountfs runs during boot.
221 End of Hint.
222 ---------------
224 That's all I did, and it works for me.  I'd appreciate any feedback you have 
225 about this hint.  Good luck.
226 Richard.Downing@bcs.org.uk