13.1. Initializing and using floppy disks

PC-style floppy disks work mostly like other disk devices like
hard disks, except that you need to low-level format them first.
To use an common 1440 KB floppy in the first floppy drive,
first (as root) format it:

Now the floppy disk can be mounted like any other disk.
Or if you already have a floppy disk with an MS-DOS filesystem
on it that you just want to access from NetBSD, you can just
do something like this:

# mount -t msdos /dev/fd0a /mnt

However, rather than using floppies like normal (bigger) disks, it
is often more convenient to bypass the filesystem altogether and
just splat an archive of files directly to the raw device. E.g.:

# tar cvfz /dev/rfd0a file1 file2 ...

A variation of this can also be done with MS-DOS floppies using
the sysutils/mtools package which
has the benefit of not going through the kernel buffer cache
and thus not being exposed to the danger of the floppy being
removed while a filesystem is mounted on it.

13.2. How to use a ZIP disk

Seems it has one, and it's recognized as sd0,
just like any SCSI disk.
The fact that the ZIP here is an ATAPI one doesn't
matter - a SCSI ZIP
will show up here, too. The ZIP is marked as "removable",
which means
you can eject it with:

13.3. Reading data CDs with NetBSD

Data CDs can contain anything from programs, sound files (MP3, wav),
movies (MP3, QuickTime) to source code, text files, etc. Before
accessing these files, a CD must be mounted on a directory, much like
hard disks are. Just as hard disks can use different filesystems (ffs,
lfs, ext2fs, ...), CDs have their own filesystem, "cd9660". The
NetBSD cd9660 filesystem can handle filesystems without and with
Rockridge and Joliet extensions.

If the CD is still accessed
(e.g. some other shell's still "cd"'d
into it), this will not work. If you shut down the system, the CD
will be unmounted automatically for you, there's nothing to worry
about there.

Making an entry in /etc/fstab:

If you don't want to type the full "mount" command
each time, you
can put most of the values into a line in /etc/fstab:

The CD is not mounted at boot time due to the "noauto" mount
option - this is useful as you'll probably not have a CD in the
drive all the time. See mount(8) and
mount_cd9660(8) for some
other useful options.

Eject the CD:

#eject cd0#

If the CD is still mounted, it will be unmounted if possible,
before being ejected.

13.4. Reading multi-session CDs with NetBSD

Use mscdlabel(8) to add all sessions to the CDs
disklabel, and
then use the appropriate device node to mount the session you want.
You might have to create the corresponding device nodes in
/dev manually.
For example:

Note

The mount options nodev and
nosuid are mandatory from NetBSD 4.0 on. They are
not necessary on NetBSD 3.x systems.

Please also see mount(8) and as an alternative the
auto mount daemonamd(8), for which
example config files can be found in
/usr/share/examples/amd.

13.6. Mounting an ISO image

Sometimes, it is interesting to mount an ISO9660 image
file before you burn the CD; this way, you can examine its
contents or even copy files
to the outside. If you are a Linux user, you should know that this is
done with the special loop filesystem.
NetBSD does it another
way, using the vnode pseudo-disk.

We will illustrate how to do this with an example.
Suppose you have an
ISO image in your home directory, called "mycd.iso":

Start by setting up a new vnode, "pointing" to
the ISO file:

#vnconfig -c vnd0 ~/mycd.iso

Now, mount the vnode:

#mount -t cd9660 /dev/vnd0a /mnt

Yeah, image contents appear under /mnt!
Go to that
directory and explore the image.

When you are happy, you have to umount the image:

#umount /mnt

And at last, deconfigure the vnode:

#vnconfig -u vnd0

Note that these steps can also be used for any kind of file that
contains a filesystem, not just ISO images.

This usually works well on both SCSI and IDE (ATAPI)
CDROMs, CDRW and DVD drives.

To read ("rip") audio tracks in binary form
without going through digital->analog conversion and back.
There are several programs available to do this:

For most ATAPI, SCSI and several proprietary
CDROM drives, the
audio/cdparanoia package can be
used. With cdparanoia the data can be saved to a file or
directed to standard output in WAV, AIFF, AIFF-C or raw
format. Currently the -g option is required by the NetBSD
version of cdparanoia. A hypothetical example of how to save
track 2 as a WAV file is as follows:

$cdparanoia -g /dev/rcd0d 2 track-02.wav

If you want to grab all files from a CD,
cdparanoia's batch mode
is useful:

$cdparanoia -g /dev/rcd0d -B

For ATAPI or SCSI CD-ROMs the
audio/cdd package can be
used. To extract track 2 with cdd, type:

#cdd -t 2 `pwd`

This will put a file called
track-02.cda
in the current directory.

For SCSI CD-ROMS the
audio/tosha package can be used.
To extract track 2 with tosha, you should be able to type:

13.10. Using a CD-R writer with data CDs

The process of writing a CD consists of two steps: First,
a "image" of
the data must be generated, which can then be written to CD-R in a
second step.

Reading an pre-existing ISO image

#dd if=/dev/rcd0a of=filename.iso bs=2k#

Alternatively, you can create a new ISO image yourself:

Generating the ISO image

Put all the data you want to put on CD into one directory. Next
you need to generate a disk-like ISO image of your data. The
image stores the data in the same form as they're later put on
CD, using the ISO 9660 format. The basic ISO9660 format only
understands 8+3 filenames (max. eight letters for filename, plus
three more for an extension). As this is not practical for Unix
filenames, a so-called "Rockridge Extension" needs to be employed
to get longer filenames. (A different set of such extension
exists in the Microsoft world, to get their long filenames right;
that's what's known as Joliet filesystem).

The ISO image is created using the mkisofs command,
which is part
of the sysutils/cdrtools
package.

Example: if you have your data in /usr/tmp/data, you can generate
a ISO image file in /usr/tmp/data.iso with the following
command:

Please see the mkisofs(8) man page for other options like noting
publisher and preparer. The
Bootable CD ROM How-To
explains how to
generate a bootable CD.

Writing the ISO image to CD-R

When you have the ISO image file,
you just need to write it on a
CD. This is done with the "cdrecord" command from the
sysutils/cdrtools package.
Insert a blank CD-R, and off we go:

#cdrecord -v dev=/dev/rcd0d data.iso
...
#

After starting the command, 'cdrecord' shows you a lot of
information about your drive, the disk and the image you're about
to write. It then does a 10 seconds countdown, which is your last
chance to stop things - type ^C if you want to abort.
If you don't abort, the process will write the whole image to the
CD and return with a shell prompt.

13.11. Using a CD-R writer to create audio CDs

If you want to make a backup copy of one of your audio CDs,
you can do
so by extracting ("ripping") the audio tracks from the CD, and then
writing them back to a blank CD. Of course this also works fine if you
only extract single tracks from various CDs,
creating your very own mix CD!

13.12. Creating an audio CD from MP3s

If you have converted all your audio CDs to MP3 and now want to make
a mixed CD for your (e.g.) your car, you can do so by first converting
the .mp3 files back to .wav format, then write them as a normal audio
CD.

The steps involved here are:

Create .wav files from your .mp3 files:

$mpg123 -w foo.wav foo.mp3

Do this for all of the MP3 files that you want to have on your
audio CD. The .wav filenames you use don't matter.

13.14. Copying a data CD with two drives

If you have both a CD-R and a CD-ROM drive in your machine,
you can copy a data CD with the following command:

#cdrecord dev=/dev/rcd1d /dev/rcd0d

Here the CD-ROM (cd0) contains the CD you want to copy, and the CD-R
(cd1) contains the blank disk. Note that this only works with computer
disks that contain some sort of data, it does
not work with
audio CDs! In practice you'll also want to add something like
"speed=8" to make things a bit
faster.

13.15. Using CD-RW rewritables

If you want to blank a CD-RW, you can do this with cdrecord's
"blank" option:

#cdrecord dev=/dev/rcd0d blank=fast

There are several other ways to blank the CD-RW,
call cdrecord(8) with
"blank=help" for a list. See the cdrecord(8)
man page for more information.

13.16. DVD support

Currently, NetBSD supports DVD media through the ISO 9660
also used for CD-ROMs. The new UDF filesystem also present on DVDs
has been supported since NetBSD 4.0. Information about mounting ISO 9660
and UDF filesystems can be found in the mount_cd9660(8) and
mount_udf(8) manual pages respectively.
DVDs, DivX and many avi files be played with multimedia/ogle
or multimedia/gmplayer.