xref: /OK3568_Linux_fs/kernel/Documentation/cdrom/packet-writing.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun==============
2*4882a593SmuzhiyunPacket writing
3*4882a593Smuzhiyun==============
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunGetting started quick
6*4882a593Smuzhiyun---------------------
7*4882a593Smuzhiyun
8*4882a593Smuzhiyun- Select packet support in the block device section and UDF support in
9*4882a593Smuzhiyun  the file system section.
10*4882a593Smuzhiyun
11*4882a593Smuzhiyun- Compile and install kernel and modules, reboot.
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun- You need the udftools package (pktsetup, mkudffs, cdrwtool).
14*4882a593Smuzhiyun  Download from http://sourceforge.net/projects/linux-udf/
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun- Grab a new CD-RW disc and format it (assuming CD-RW is hdc, substitute
17*4882a593Smuzhiyun  as appropriate)::
18*4882a593Smuzhiyun
19*4882a593Smuzhiyun	# cdrwtool -d /dev/hdc -q
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun- Setup your writer::
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun	# pktsetup dev_name /dev/hdc
24*4882a593Smuzhiyun
25*4882a593Smuzhiyun- Now you can mount /dev/pktcdvd/dev_name and copy files to it. Enjoy::
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun	# mount /dev/pktcdvd/dev_name /cdrom -t udf -o rw,noatime
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun
30*4882a593SmuzhiyunPacket writing for DVD-RW media
31*4882a593Smuzhiyun-------------------------------
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunDVD-RW discs can be written to much like CD-RW discs if they are in
34*4882a593Smuzhiyunthe so called "restricted overwrite" mode. To put a disc in restricted
35*4882a593Smuzhiyunoverwrite mode, run::
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun	# dvd+rw-format /dev/hdc
38*4882a593Smuzhiyun
39*4882a593SmuzhiyunYou can then use the disc the same way you would use a CD-RW disc::
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun	# pktsetup dev_name /dev/hdc
42*4882a593Smuzhiyun	# mount /dev/pktcdvd/dev_name /cdrom -t udf -o rw,noatime
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun
45*4882a593SmuzhiyunPacket writing for DVD+RW media
46*4882a593Smuzhiyun-------------------------------
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunAccording to the DVD+RW specification, a drive supporting DVD+RW discs
49*4882a593Smuzhiyunshall implement "true random writes with 2KB granularity", which means
50*4882a593Smuzhiyunthat it should be possible to put any filesystem with a block size >=
51*4882a593Smuzhiyun2KB on such a disc. For example, it should be possible to do::
52*4882a593Smuzhiyun
53*4882a593Smuzhiyun	# dvd+rw-format /dev/hdc   (only needed if the disc has never
54*4882a593Smuzhiyun	                            been formatted)
55*4882a593Smuzhiyun	# mkudffs /dev/hdc
56*4882a593Smuzhiyun	# mount /dev/hdc /cdrom -t udf -o rw,noatime
57*4882a593Smuzhiyun
58*4882a593SmuzhiyunHowever, some drives don't follow the specification and expect the
59*4882a593Smuzhiyunhost to perform aligned writes at 32KB boundaries. Other drives do
60*4882a593Smuzhiyunfollow the specification, but suffer bad performance problems if the
61*4882a593Smuzhiyunwrites are not 32KB aligned.
62*4882a593Smuzhiyun
63*4882a593SmuzhiyunBoth problems can be solved by using the pktcdvd driver, which always
64*4882a593Smuzhiyungenerates aligned writes::
65*4882a593Smuzhiyun
66*4882a593Smuzhiyun	# dvd+rw-format /dev/hdc
67*4882a593Smuzhiyun	# pktsetup dev_name /dev/hdc
68*4882a593Smuzhiyun	# mkudffs /dev/pktcdvd/dev_name
69*4882a593Smuzhiyun	# mount /dev/pktcdvd/dev_name /cdrom -t udf -o rw,noatime
70*4882a593Smuzhiyun
71*4882a593Smuzhiyun
72*4882a593SmuzhiyunPacket writing for DVD-RAM media
73*4882a593Smuzhiyun--------------------------------
74*4882a593Smuzhiyun
75*4882a593SmuzhiyunDVD-RAM discs are random writable, so using the pktcdvd driver is not
76*4882a593Smuzhiyunnecessary. However, using the pktcdvd driver can improve performance
77*4882a593Smuzhiyunin the same way it does for DVD+RW media.
78*4882a593Smuzhiyun
79*4882a593Smuzhiyun
80*4882a593SmuzhiyunNotes
81*4882a593Smuzhiyun-----
82*4882a593Smuzhiyun
83*4882a593Smuzhiyun- CD-RW media can usually not be overwritten more than about 1000
84*4882a593Smuzhiyun  times, so to avoid unnecessary wear on the media, you should always
85*4882a593Smuzhiyun  use the noatime mount option.
86*4882a593Smuzhiyun
87*4882a593Smuzhiyun- Defect management (ie automatic remapping of bad sectors) has not
88*4882a593Smuzhiyun  been implemented yet, so you are likely to get at least some
89*4882a593Smuzhiyun  filesystem corruption if the disc wears out.
90*4882a593Smuzhiyun
91*4882a593Smuzhiyun- Since the pktcdvd driver makes the disc appear as a regular block
92*4882a593Smuzhiyun  device with a 2KB block size, you can put any filesystem you like on
93*4882a593Smuzhiyun  the disc. For example, run::
94*4882a593Smuzhiyun
95*4882a593Smuzhiyun	# /sbin/mke2fs /dev/pktcdvd/dev_name
96*4882a593Smuzhiyun
97*4882a593Smuzhiyun  to create an ext2 filesystem on the disc.
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun
100*4882a593SmuzhiyunUsing the pktcdvd sysfs interface
101*4882a593Smuzhiyun---------------------------------
102*4882a593Smuzhiyun
103*4882a593SmuzhiyunSince Linux 2.6.20, the pktcdvd module has a sysfs interface
104*4882a593Smuzhiyunand can be controlled by it. For example the "pktcdvd" tool uses
105*4882a593Smuzhiyunthis interface. (see http://tom.ist-im-web.de/download/pktcdvd )
106*4882a593Smuzhiyun
107*4882a593Smuzhiyun"pktcdvd" works similar to "pktsetup", e.g.::
108*4882a593Smuzhiyun
109*4882a593Smuzhiyun	# pktcdvd -a dev_name /dev/hdc
110*4882a593Smuzhiyun	# mkudffs /dev/pktcdvd/dev_name
111*4882a593Smuzhiyun	# mount -t udf -o rw,noatime /dev/pktcdvd/dev_name /dvdram
112*4882a593Smuzhiyun	# cp files /dvdram
113*4882a593Smuzhiyun	# umount /dvdram
114*4882a593Smuzhiyun	# pktcdvd -r dev_name
115*4882a593Smuzhiyun
116*4882a593Smuzhiyun
117*4882a593SmuzhiyunFor a description of the sysfs interface look into the file:
118*4882a593Smuzhiyun
119*4882a593Smuzhiyun  Documentation/ABI/testing/sysfs-class-pktcdvd
120*4882a593Smuzhiyun
121*4882a593Smuzhiyun
122*4882a593SmuzhiyunUsing the pktcdvd debugfs interface
123*4882a593Smuzhiyun-----------------------------------
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunTo read pktcdvd device infos in human readable form, do::
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun	# cat /sys/kernel/debug/pktcdvd/pktcdvd[0-7]/info
128*4882a593Smuzhiyun
129*4882a593SmuzhiyunFor a description of the debugfs interface look into the file:
130*4882a593Smuzhiyun
131*4882a593Smuzhiyun  Documentation/ABI/testing/debugfs-pktcdvd
132*4882a593Smuzhiyun
133*4882a593Smuzhiyun
134*4882a593Smuzhiyun
135*4882a593SmuzhiyunLinks
136*4882a593Smuzhiyun-----
137*4882a593Smuzhiyun
138*4882a593SmuzhiyunSee http://fy.chalmers.se/~appro/linux/DVD+RW/ for more information
139*4882a593Smuzhiyunabout DVD writing.
140