Tải bản đầy đủ (.pdf) (8 trang)

Chapter-13-Writing CD-Rs

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (84.19 KB, 8 trang )

2Apr il 2003, 17:00:47 The Complete FreeBSD (bur ncd.mm), page 243
13
Writing CD-Rs
In this chapter:
• Creating an
ISO-9660 image
• Bur ning the CD-R
• Copying CD-ROMs
In this chapter:
• Creating an
ISO-9660 image
• Bur ning the CD-R
• Copying CD-ROMs
Under FreeBSD, data on conventional hard disks is stored in the UNIX File System or
UFS format. CD-ROMs and CD-Rs use a different file system, the ISO 9660 format,
which is compatible with other systems. This is not a problem when you mount a CD-
ROM: FreeBSD includes a read-only ISO 9660 file system. When you want to write a
CD-R, however, things are a little more complicated: the medium requires you to write
the entire file system at once, and since the file system is stored in a different format, you
can’tjust copythe UFS file system. Instead, you must first create an image of the file
system that you want to put on the CD-R, and then you copyit. We’ll look at these steps
in more detail below.
Creating an ISO-9660 image
The first step is to create the ISO 9660 file system image, frequently simply called an ISO
image.There are a number of ports available in the Ports Collection; here we’ll look at
mkisofs,which is part of the cdrtools port. Installation isn’tquite as straightforward as
you might expect: you need a special flag to install mkisofs:
# cd /usr/ports/sysutils/cdrtools
# make install -DMKISOFS
mkisofs has a bewildering number of parameters. Here are the important ones:
• The -A option specifies the application ID,atextstring written to the header of the


file system to describe the ‘‘application’’onthe image. It can be up to 128 characters
long.
burncd.mm,v v4.13 (2003/04/02 06:46:59) 243
Creating an ISO-9660 image 244
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 244
• Use -b if you want to be able to boot from the CD, such as a FreeBSD bootable CD.
In the case of FreeBSD, use the 2.88 MB image floppies/boot.flp which is built as
part of the release process. Note that this file must be in one of the directories
included in the image, and the name is relative tothe root directory of the CD.
• The -f option tells mkisofs to followsymbolic links. If you don’tspecify this option
and you have symbolic links in the directory from which you create the image, the
resultant CD-ROM image will contain only a symbolic link instead of the file itself.
If the file to which the symbolic link points is belowthe top-level(root) directory,this
is the preferred way to do things, because it savesspace, but if it points outside the
CD-ROM, the file will not appear on the CD-ROM at all. Use this option if you have
symbolic links to files outside the directory that you’re using for the root of the CD-
ROMfile system.
• The -J option makes the CD compatible with Microsoft’s Joliet format. You don’t
need it for FreeBSD, but it doesn’tcost much, so it’sagood idea to include it if
there’sachance the CD will be used in a Microsoft environment.
• Use the -o option to specify the name of the resultant ISO image. This image is the
size of the resultant CD, so it could be up to 700 MB.
• The -p option specifies the preparer ID,another ISO 9660 header field to specify
who made the CD-ROM.
• The -r option specifies the RockRidgeExtensions that are used to store UNIX file
names. It makes a number of assumptions about permissions and owners; see the
man page for details. It takes no parameters.
• The -T option tells mkisofs to include a translation file TRANS.TBL in each directory
for use by systems that don’tsupport the Rock Ridge extensions. For each file name
in the directory, TRANS.TBL contains a Microsoft-compatible name (up to eight

characters, a period (.)and up to three more characters). The names bear a slight
resemblance to the original names.
• If you don’tlikethe name TRANS.TBL,you can specify a different name with the
-table-name option, which implies -T.For example, if you write -table-name
.MAP you will generate names that won’tshowupwith a normal ls command.
• The -V option specifies the volume ID for the file system. This will normally be
more specific than the application ID; for example, each CD in a set of CDs might
have the same application ID and a different volume ID.
• The final parameters are the names of the directories that will be included in the
image. You can specify multiple directories. In each case, the entire directory
hierarchywill be included.
burncd.mm,v v4.13 (2003/04/02 06:46:59)
245 Chapter 13: Writing CD-Rs
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 245
This is a lot of stufftotype in every time. It’seasier to write a Makefile and use make:
APPLID = "Dummy application"
BOOT =
#Tomake it bootable, put in something like this:
#Note that the -b option is there as well
#BOOT = "-b floppies/boot.flp"
ISO = /var/tmp/isoimage
PREPARER = "me"
VOLID = "Volume 0000"
DIR = .
cdrom:
mkisofs -A ${APPLID} ${BOOT} -J -o ${ISO} -f \
-p ${PREPARER} -r -T -V ${VOLID} ${DIR}
Forexample, to makea bootable CD-R of the FreeBSD release, you would first perform
the makeworld and makerelease.Assuming that the release directory is /home/release,
you will find the directory trees for the first twoCD-ROMs in /home/re-

lease/R/cdrom/disc1 and /home/release/R/cdrom/disc2.You could do this:
# make cdrom DIR=/home/release/R/cdrom/disc1
mkisofs -A "Dummy application" -J -o ../iso -table-name .MAP -p "Greg Lehey" -r -T
-V "Volume 0000" .
6.40% done, estimate finish Sun Aug 27 13:34:54 2000
12.79% done, estimate finish Sun Aug 27 13:35:02 2000
19.19% done, estimate finish Sun Aug 27 13:35:05 2000
25.57% done, estimate finish Sun Aug 27 13:35:10 2000
31.97% done, estimate finish Sun Aug 27 13:35:10 2000
38.36% done, estimate finish Sun Aug 27 13:35:10 2000
44.75% done, estimate finish Sun Aug 27 13:35:10 2000
51.15% done, estimate finish Sun Aug 27 13:35:12 2000
57.54% done, estimate finish Sun Aug 27 13:35:12 2000
63.94% done, estimate finish Sun Aug 27 13:35:12 2000
70.34% done, estimate finish Sun Aug 27 13:35:11 2000
76.72% done, estimate finish Sun Aug 27 13:35:13 2000
83.12% done, estimate finish Sun Aug 27 13:35:12 2000
89.52% done, estimate finish Sun Aug 27 13:35:13 2000
95.90% done, estimate finish Sun Aug 27 13:35:13 2000
Total translation table size: 35119
Total rockridge attributes bytes: 59724
Total directory bytes: 104448
Path table size(bytes): 256
Max brk space used 86224
78211 extents written (152 Mb)
The progress reports are rather boring nowadays, considering that the whole process only
takes a couple of minutes, but the summary information at the bottom can be of interest.
Testing the CD-R
So nowyou have anISO image. Howdoyou knowit’scorrect? It’sjust a single file, and
it could have just about anything on it. Youcan burn a CD, of course, but if it’sjunk, you

have another coaster.Ifyou’re not sure, it’sbetter to look inside first. Youcan do that by
using it as the basis for an md vnode device.
The md drivercreates a number of different kinds of pseudo-device. See the man page
md(4) for more details. We use the vnode device, a special file that refers to file system
files. Support for md is included in the GENERIC kernel, but if you’ve built a kernel
burncd.mm,v v4.13 (2003/04/02 06:46:59)
Creating an ISO-9660 image 246
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 246
without the md driver, you can load it as a kld.Ifyou’re not sure, try loading the kld
anyway.Then you associate a vnode device with the ISO image iso-image using the
program mdconfig:
# kldload md load the kld module if necessary
kldload: can’t load md: File exists already loaded or in the kernel
# mdconfig -a -t vnode -f iso-image configurethe device
md0 this is the name assigned
# mount -t cd9660 /dev/md0 /mnt mount it
After this, you will be able to access the image at /mnt as a normal file system. Don’t
forget to unmount and unconfigure the file when you’re finished:
# umount /mnt
# mdconfig -d -u 0
Older releases of FreeBSD used the vn driver, which used different syntax.
Burning the CD-R
Once you have created and tested an ISO image, you can copyittoCD-R. For SCSI
burners, you use cdrecord;ATA (IDE) CD-R burners you use burncd.Inthe following
sections we’ll look at both programs.
Burning a CD-R on an ATA burner
To burn a CD-R in an ATA (or IDE) burner,use burncd,which is part of the base system.
Typically you’ll only have one CD-R burner on the system, so it will be called /dev/acd0.
You’ll have something likethis in your dmesg output:
acd0: CD-RW <RWD RW4224> at ata1-slave BIOSPIO

burncd has both flags and commands. Forour purposes, the most important flags are:
• The -f device option specifies the device to use for the burning process.
• The -m option tells burncd to close the disk in multisession mode.
• The -q option tells burncd to be quiet and not to print progress messages. In fact,
it’snot very verbose anyway.
• The -s speed option specifies the speed of the burner device. It defaults to 1, so
you’ll save a lot of time using this.
• The -t option specifies a test write: burncd does not actually write on the medium.
• The -v (verbose) option prints a fewextra progress messages.
burncd.mm,v v4.13 (2003/04/02 06:46:59)
247 Chapter 13: Writing CD-Rs
2April 2003, 17:00:47 The Complete FreeBSD (../tools/tmac.Mn), page 247
The most important commands for writing ISO 9660 CD-ROMs are:
• data or mode1 write data tracks, also known as mode1 tracks, for the image files
named on the command line.
• fixate fixates the medium by generating the table of contents. This should be the
last command to burncd.
If burncd doesn’trecognize a command, it assumes it’safile name. If it does, it assumes
it isn’tafile name. This can be confusing: there are other commands not mentioned in
the list above,for example raw.Ifyou have anISO file called raw,you’ll have torename
it before you can burn it with burncd.
Before you start, you should decide on the recording speed. If your machine is fast
enough, use the rated recording speed. In the case of the example machine, that’san8x
speed (i.e. it records at eight times the speed at which a normal audio CD is played).
Before you do this, though, you should makesure that your system can keep a sufficient
data rate so that there is always data available to transfer to the CD-R. If it can’tkeep up,
you’ll get an underrun,agap in the data, and your CD-R is worthless (a coaster).
To makesure you don’tmakecoasters, you should do a test run. The system goes
through all the motions, but it doesn’tactually write anything to the CD-R blank.
Nevertheless, it tests all aspects of the burn, so you must have a valid CD-R blank in the

drive,otherwise the attempt will fail. Totest burn an image called iso,enter:
# burncd -f /dev/acd0c -t -v -s 8 data iso fixate
adding type 0x08 file iso size 184576 KB 92288 blocks
next writeable LBA 0
addr = 0 size = 189005824 blocks = 92288
writing from file iso size 184576 KB
written this track 6880 KB (3%) total 6880 KB
At this point, burncd overwrites the line with progress indications until it is finished.
Finally,you see:
written this track 184576 KB (100%) total 184576 KB
fixating CD, please wait..
burncd: ioctl(CDRIOCFIXATE): Input/output error
This last line appears a little alarming. It’snot really serious, though: the CD has not
really been written, so it’snot possible to read from it. Anumber of CD-R drivesreturn
error conditions under these circumstances.
If everything was OK in the test run, you can repeat the command without the -t flag:
# burncd -f /dev/acd0c -v -s 8 data iso fixate
The output is identical, but this time you should not get the error message.
burncd.mm,v v4.13 (2003/04/02 06:46:59)

Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Tải bản đầy đủ ngay
×