Annotation of wikisrc/guide/rmmedia.mdwn, revision 1.2

1.1       jdf         1: # Using removable media
                      2: 
                      3: ## Reading data CDs with NetBSD
                      4: 
1.2     ! jdf         5: Data CDs can contain anything from programs, sound files (MP3, wav), movies
        !             6: (MP3, QuickTime) to source code, text files, etc. Before accessing these files,
        !             7: a CD must be mounted on a directory, much like hard disks are. Just as hard
        !             8: disks can use different filesystems (ffs, lfs, ext2fs, ...), CDs have their own
        !             9: filesystem, *cd9660*. The NetBSD cd9660 filesystem can handle filesystems
1.1       jdf        10: without and with Rockridge and Joliet extensions.
                     11: 
                     12: CD devices are named /dev/cd0a for both SCSI and IDE (ATAPI).
                     13: 
                     14: With this information, we can start:
                     15: 
                     16:  1. See if your system has some CD drive:
                     17: 
                     18:         # dmesg | grep ^cd
                     19:              cd0 at atapibus0 drive 0: <CD-R/RW RW8040A, , 1.12> type 5 cdrom removable
                     20:              cd0: 32-bit data port
                     21:              cd0: drive supports PIO mode 4, DMA mode 0
                     22:              cd0(pciide0:1:0): using PIO mode 0, DMA mode 0 (using DMA data transfers)
                     23: 
1.2     ! jdf        24:        We have one drive here, `cd0`. It is an IDE/ATAPI drive, as it is found on
        !            25:        atapibus0. Of course the drive (rather, its medium) is removable, i.e., you
1.1       jdf        26:        can eject it. See below.
                     27: 
                     28:  2. Insert a CD
                     29: 
                     30:  3. Mount the CD manually:
                     31: 
                     32:         # mount -t cd9660 /dev/cd0a /mnt
                     33: 
1.2     ! jdf        34:        This command shouldn't print anything. It instructs the system to mount the
        !            35:        CD found on /dev/cd0a on /mnt, using the `cd9660` filesystem. The mountpoint
        !            36:        `/mnt` must be an existing directory.
1.1       jdf        37: 
                     38:  4. Check the contents of the CD:
                     39: 
                     40:         # ls /mnt
                     41:         INSTALL.html INSTALL.ps   TRANS.TBL    boot.catalog
                     42:         INSTALL.more INSTALL.txt  binary       installation
                     43: 
                     44:     Everything looks fine! This is a NetBSD CD, of course. :)
                     45: 
                     46:  5. Unmount the CD:
                     47: 
                     48:         # umount /mnt
                     49: 
1.2     ! jdf        50:        If the CD is still accessed (e.g. some other shell's still "cd"'d into it),
        !            51:        this will not work. If you shut down the system, the CD will be unmounted
1.1       jdf        52:        automatically for you, there's nothing to worry about there.
                     53: 
                     54:  6. Making an entry in /etc/fstab:
                     55: 
1.2     ! jdf        56:        If you don't want to type the full "mount" command each time, you can put
1.1       jdf        57:        most of the values into a line in /etc/fstab:
                     58: 
                     59:         # Device        mountpoint      filesystem  mount options
                     60:         /dev/cd0a       /cdrom          cd9660      ro,noauto    
                     61: 
                     62:        Make sure that the mountpoint, `/cdrom` in our example, exists:
                     63: 
                     64:         # mkdir /cdrom
                     65: 
                     66:        Now you can mount the cd with the following command:
                     67: 
                     68:         # mount /cdrom
                     69: 
                     70:     Access and unmount as before.
                     71: 
1.2     ! jdf        72:        The CD is not mounted at boot time due to the "noauto" mount option - this
        !            73:        is useful as you'll probably not have a CD in the drive all the time. See
        !            74:        [mount(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount+8+NetBSD-5.0.1+i386)
        !            75:        and
        !            76:        [mount\_cd9660(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount_cd9660+8+NetBSD-5.0.1+i386)
1.1       jdf        77:        for some other useful options.
                     78: 
                     79: 7.  Eject the CD:
                     80: 
                     81:         # eject cd0
                     82: 
1.2     ! jdf        83:        If the CD is still mounted, it will be unmounted if possible, before being
1.1       jdf        84:        ejected.
                     85: 
                     86: ## Reading multi-session CDs with NetBSD
                     87: 
1.2     ! jdf        88: Use
        !            89: [mscdlabel(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mscdlabel+8+NetBSD-5.0.1+i386)
        !            90: to add all sessions to the CDs disklabel, and then use the appropriate device
        !            91: node to mount the session you want. You might have to create the corresponding
1.1       jdf        92: device nodes in `/dev` manually. For example:
                     93: 
                     94:     # mscdlabel cd1
                     95:     track (ctl=4) at sector 142312
                     96:      adding as 'a'
                     97:     track (ctl=4) at sector 0
                     98:      adding as 'b'
                     99:     # ls -l /dev/cd1b
                    100:     ls: /dev/cd1b: No such file or directory
                    101:     # cd /dev
                    102:     # ls -l cd1*
                    103:     brw-r-----  1 root  operator       6,  8 Mar 18 21:55 cd1a
                    104:     brw-r-----  1 root  operator       6, 11 Mar 18 21:55 cd1d
                    105:     # mknod cd1b b 6 9
                    106: 
1.2     ! jdf       107: to create `/dev/cd1b`. Make sure you fix the permissions of any new device nodes
1.1       jdf       108: you create:
                    109: 
                    110:     # ls -l cd1*
                    111:     brw-r-----  1 root  operator       6,  8 Mar 18 21:55 cd1a
                    112:     brw-r--r--  1 root  wheel          6,  9 Mar 18 22:23 cd1b
                    113:     brw-r-----  1 root  operator       6, 11 Mar 18 21:55 cd1d
                    114:     # chgrp operator cd1b
                    115:     # chmod 640 cd1b
1.2     ! jdf       116:     # ls -l cd1*
1.1       jdf       117:     brw-r-----  1 root  operator       6,  8 Mar 18 21:55 cd1a
                    118:     brw-r-----  1 root  operator       6,  9 Mar 18 22:24 cd1b
                    119:     brw-r-----  1 root  operator       6, 11 Mar 18 21:55 cd1d
                    120: 
                    121: Now you should be able to mount it.
                    122: 
                    123:     # mount /dev/cd1b /mnt
                    124: 
                    125: ## Allowing normal users to access CDs
                    126: 
1.2     ! jdf       127: By default, NetBSD only allows "root" to mount a filesystem. If you want any
1.1       jdf       128: user to be able to do this, perform the following steps:
                    129: 
                    130:  * Give groups and other the access rights to the device.
                    131: 
                    132:         # chmod go+rw /dev/cd0a
                    133: 
                    134:  * Ask NetBSD to let users mounting filesystems.
                    135: 
                    136:         # sysctl -w vfs.generic.usermount=1
                    137: 
1.2     ! jdf       138:        Note that this works for any filesystem and device, not only for CDs with a
1.1       jdf       139:        ISO 9660 filesystem.
                    140: 
1.2     ! jdf       141: To perform the mount operation after these commands, the user must own the mount
1.1       jdf       142: point. So, for example:
                    143: 
                    144:     $ cd $HOME
                    145:     $ mkdir cdrom
                    146:     $ mount -t cd9660 -o nodev,nosuid /dev/cd0a `pwd`/cdrom
                    147: 
1.2     ! jdf       148: *Note*: The mount options `nodev` and `nosuid` are mandatory from NetBSD 4.0 on.
1.1       jdf       149: They are not necessary on NetBSD 3.x systems.
                    150: 
1.2     ! jdf       151: Please also see
        !           152: [mount(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount+8+NetBSD-5.0.1+i386) and
        !           153: as an alternative the *auto mount daemon*
        !           154: [amd(8)](http://netbsd.gw.com/cgi-bin/man-cgi?amd+8+NetBSD-5.0.1+i386), for
1.1       jdf       155: which example config files can be found in `/usr/share/examples/amd`.
                    156: 
                    157: ## Mounting an ISO image
                    158: 
1.2     ! jdf       159: Sometimes, it is interesting to mount an ISO9660 image file before you burn the
        !           160: CD; this way, you can examine its contents or even copy files to the outside. If
        !           161: you are a Linux user, you should know that this is done with the special *loop*
1.1       jdf       162: filesystem. NetBSD does it another way, using the *vnode* pseudo-disk.
                    163: 
1.2     ! jdf       164: We will illustrate how to do this with an example. Suppose you have an ISO image
1.1       jdf       165: in your home directory, called `mycd.iso`:
                    166: 
                    167:  1. Start by setting up a new vnode, "pointing" to the ISO file:
                    168: 
                    169:         # vnconfig -c vnd0 ~/mycd.iso
                    170: 
                    171:  2. Now, mount the vnode:
                    172: 
                    173:         # mount -t cd9660 /dev/vnd0a /mnt
                    174: 
1.2     ! jdf       175:  3. Yeah, image contents appear under `/mnt`! Go to that directory and explore
1.1       jdf       176:     the image.
                    177: 
                    178:  4. When you are happy, you have to umount the image:
                    179: 
                    180:         # umount /mnt
                    181: 
                    182:  5. And at last, deconfigure the vnode:
                    183: 
                    184:         # vnconfig -u vnd0
                    185: 
1.2     ! jdf       186: Note that these steps can also be used for any kind of file that contains a
1.1       jdf       187: filesystem, not just ISO images.
                    188: 
1.2     ! jdf       189: See the [vnd(4)](http://netbsd.gw.com/cgi-bin/man-cgi?vnd+4+NetBSD-5.0.1+i386)
        !           190: and
        !           191: [vnconfig(8)](http://netbsd.gw.com/cgi-bin/man-cgi?vnconfig+8+NetBSD-5.0.1+i386)
1.1       jdf       192: man pages for more information.
                    193: 
                    194: ## Using video CDs with NetBSD
                    195: 
1.2     ! jdf       196: To play MPEG Video streams as many DVD players can play them under NetBSD, mount
        !           197: the CD as you would do with any normal (data) CD (see [[Reading data CDs with
        !           198: NetBSD|guide/rmmedia#cdrom]]), then use the
        !           199: [`multimedia/xine-ui`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/multimedia/xine-ui/README.html),
        !           200: [`multimedia/mplayer`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/multimedia/mplayer/README.html)
        !           201: or
        !           202: [`multimedia/gmplayer`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/multimedia/gmplayer/README.html)
1.1       jdf       203: package to play the mpeg files stored on the CD.
                    204: 
                    205: ## Using audio CDs with NetBSD
                    206: 
                    207: There are two ways to handle audio CDs:
                    208: 
1.2     ! jdf       209:  1. Tell the CD drive to play to the headphone or to a soundcard, to which
        !           210:        CDROMs are usually connected internally. Use programs like
        !           211:        [cdplay(1)](http://netbsd.gw.com/cgi-bin/man-cgi?cdplay+1+NetBSD-5.0.1+i386),
        !           212:        [`audio/xmcd`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/xmcd/README.html),
        !           213:        "kscd" from the
        !           214:        [`multimedia/kdemultimedia3`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/multimedia/kdemultimedia3/README.html)
        !           215:        package, mixer programs like
        !           216:        [mixerctl(1)](http://netbsd.gw.com/cgi-bin/man-cgi?mixerctl+1+NetBSD-5.0.1+i386),
        !           217:        [`audio/xmix`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/xmix/README.html),
        !           218:        [`audio/xmmix`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/xmmix/README.html),
        !           219:        the Curses based
        !           220:        [`audio/cam`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/cam/README.html),
        !           221:        or kmix, which is part of
1.1       jdf       222:        [`multimedia/kdemultimedia3`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/multimedia/kdemultimedia3/README.html).
                    223: 
1.2     ! jdf       224:        This usually works well on both SCSI and IDE (ATAPI) CDROMs, CDRW and DVD
1.1       jdf       225:        drives.
                    226: 
1.2     ! jdf       227:  2. To read ("rip") audio tracks in binary form without going through
        !           228:        digital-\>analog conversion and back. There are several programs available
1.1       jdf       229:        to do this:
                    230: 
1.2     ! jdf       231:         * For most ATAPI, SCSI and several proprietary CDROM drives, the
        !           232:           [`audio/cdparanoia`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/cdparanoia/README.html)
        !           233:           package can be used. With cdparanoia the data can be saved to a file or
        !           234:           directed to standard output in WAV, AIFF, AIFF-C or raw format. Currently
        !           235:           the -g option is required by the NetBSD version of cdparanoia. A
1.1       jdf       236:           hypothetical example of how to save track 2 as a WAV file is as follows:
                    237: 
                    238:            $ cdparanoia -g /dev/rcd0d 2 track-02.wav
                    239: 
                    240:        If you want to grab all files from a CD, cdparanoia's batch mode is useful:
                    241: 
                    242:            $ cdparanoia -g /dev/rcd0d -B
                    243: 
1.2     ! jdf       244:         * For ATAPI or SCSI CD-ROMs the
        !           245:           [`audio/cdd`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/cdd/README.html)
1.1       jdf       246:           package can be used. To extract track 2 with cdd, type:
                    247: 
                    248:            # cdd -t 2 `pwd`
                    249: 
                    250:        This will put a file called `track-02.cda` in the current directory.
                    251: 
1.2     ! jdf       252:         * For SCSI CD-ROMS the
        !           253:           [`audio/tosha`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/tosha/README.html)
        !           254:           package can be used. To extract track 2 with tosha, you should be able to
1.1       jdf       255:           type:
                    256: 
                    257:            # tosha -d CD-ROM-device -t 2 -o track-02.cda
                    258: 
1.2     ! jdf       259:        The data can then be post-processed e.g. by encoding it into MP3 streams
        !           260:        (see [[Creating an MP3 (MPEG layer 3) file from an audio
        !           261:        CD|guide/rmmedia#create-mpeg3]]) or by writing them to CD-Rs (see [[Using a
1.1       jdf       262:        CD-R writer to create audio CDs|guide/rmmedia#cdr-audio]]).
                    263: 
                    264: ## Creating an MP3 (MPEG layer 3) file from an audio CD
                    265: 
1.2     ! jdf       266: The basic steps in creating an MPEG layer 3 (MP3) file from an audio CD (using
        !           267: software from the [NetBSD packages
1.1       jdf       268: collection](http://www.NetBSD.org/docs/pkgsrc/)) are:
                    269: 
                    270:  1. Extract (*rip*) the audio data of the CD as shown in
                    271:     [[Using audio CDs with NetBSD|guide/rmmedia#cdrom-audio]].
                    272: 
1.2     ! jdf       273:  2. Convert the CD audio format file to WAV format. You only need to perform
        !           274:        this job if your ripping program (e.g. tosha, cdd) didn't already do the job
1.1       jdf       275:        for you!
                    276: 
                    277:      * Using the [`audio/sox`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/sox/README.html) package, type:
                    278: 
                    279:            $ sox -s -w -c 2 -r 44100 -t cdr track-02.cda track-02.wav
                    280: 
1.2     ! jdf       281:           This will convert `track-02.cda` in raw CD format to `track-02.wav` in
        !           282:           WAV format, using **s**igned 16-bit **w**ords with 2 **c**hannels at a
1.1       jdf       283:           sampling **r**ate of 44100kHz.
                    284: 
                    285:  3. Encode the WAV file into MP3 format.
                    286: 
                    287:      * Using the [`audio/bladeenc`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/bladeenc/README.html) package, type:
                    288: 
                    289:            $ bladeenc -128 -QUIT track-02.wav
                    290: 
1.2     ! jdf       291:           This will encode `track-02.wav` into `track-02.mp3` in MP3 format, using
        !           292:           a bit rate if **128**kBit/sec. The documentation for bladeenc describes
1.1       jdf       293:           bit-rates in more detail.
                    294: 
1.2     ! jdf       295:         * Using the
        !           296:           [`audio/lame`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/lame/README.html)
1.1       jdf       297:           package, type:
                    298: 
                    299:            $ lame -p -o -v -V 5 -h track-02.wav track-02.mp3
                    300: 
1.2     ! jdf       301:           You may wish to use a lower quality, depending on your taste and
1.1       jdf       302:           hardware.
                    303: 
1.2     ! jdf       304: The resultant MP3 file can be played with any of the
        !           305: [`audio/gqmpeg`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/gqmpeg/README.html),
        !           306: [`audio/maplay`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/maplay/README.html),
        !           307: [`audio/mpg123`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/mpg123/README.html)
        !           308: or
        !           309: [`audio/splay`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/audio/splay/README.html)
1.1       jdf       310: packages.
                    311: 
                    312: ## Using a CD-R writer with data CDs
                    313: 
1.2     ! jdf       314: The process of writing a CD consists of two steps: First, a "image" of the data
1.1       jdf       315: must be generated, which can then be written to CD-R in a second step.
                    316: 
                    317:  1. Reading an pre-existing ISO image
                    318: 
                    319:         # dd if=/dev/rcd0a of=filename.iso bs=2k
                    320: 
                    321:     Alternatively, you can create a new ISO image yourself:
                    322: 
                    323:  2. 2. 2.ating the ISO image
                    324: 
1.2     ! jdf       325:        Put all the data you want to put on CD into one directory. Next you need to
        !           326:        generate a disk-like ISO image of your data. The image stores the data in
        !           327:        the same form as they're later put on CD, using the ISO 9660 format. The
        !           328:        basic ISO9660 format only understands 8+3 filenames (max. eight letters for
        !           329:        filename, plus three more for an extension). As this is not practical for
        !           330:        Unix filenames, a so-called "Rockridge Extension" needs to be employed to
        !           331:        get longer filenames. (A different set of such extension exists in the
        !           332:        Microsoft world, to get their long filenames right; that's what's known as
1.1       jdf       333:        Joliet filesystem).
                    334: 
1.2     ! jdf       335:        The ISO image is created using the mkisofs command, which is part of the
        !           336:        [`sysutils/cdrtools`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/cdrtools/README.html)
1.1       jdf       337:        package.
                    338: 
1.2     ! jdf       339:        Example: if you have your data in /usr/tmp/data, you can generate a ISO
1.1       jdf       340:        image file in /usr/tmp/data.iso with the following command:
                    341: 
                    342:         $ cd /usr/tmp
                    343:         $ mkisofs -o data.iso -r data
                    344:         Using NETBS000.GZ;1 for  data/binary/kernel/netbsd.INSTALL.gz (netbsd.INSTALL_TINY.gz)
                    345:         Using NETBS001.GZ;1 for  data/binary/kernel/netbsd.GENERIC.gz (netbsd.GENERIC_TINY.gz)
                    346:           5.92% done, estimate finish Wed Sep 13 21:28:11 2000
                    347:          11.83% done, estimate finish Wed Sep 13 21:28:03 2000
                    348:          17.74% done, estimate finish Wed Sep 13 21:28:00 2000
                    349:          23.64% done, estimate finish Wed Sep 13 21:28:03 2000
                    350:          ...
                    351:          88.64% done, estimate finish Wed Sep 13 21:27:55 2000
                    352:          94.53% done, estimate finish Wed Sep 13 21:27:55 2000
                    353:         Total translation table size: 0
                    354:         Total rockridge attributes bytes: 5395
                    355:         Total directory bytes: 16384
                    356:         Path table size(bytes): 110
                    357:         Max brk space used 153c4
                    358:         84625 extents written (165 Mb)
                    359: 
1.2     ! jdf       360:        Please see the mkisofs(8) man page for other options like noting publisher
        !           361:        and preparer. The [Bootable CD ROM
        !           362:        How-To](http://www.NetBSD.org/docs/bootcd.html) explains how to generate a
1.1       jdf       363:        bootable CD.
                    364: 
                    365:  3. Writing the ISO image to CD-R
                    366: 
1.2     ! jdf       367:        When you have the ISO image file, you just need to write it on a CD. This is
        !           368:        done with the "cdrecord" command from the
        !           369:        [`sysutils/cdrtools`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/cdrtools/README.html)
1.1       jdf       370:        package. Insert a blank CD-R, and off we go:
                    371: 
                    372:         # cdrecord -v dev=/dev/rcd0d data.iso
                    373:         ...
                    374: 
1.2     ! jdf       375:        After starting the command, 'cdrecord' shows you a lot of information about
        !           376:        your drive, the disk and the image you're about to write. It then does a 10
        !           377:        seconds countdown, which is your last chance to stop things - type \^C if
        !           378:        you want to abort. If you don't abort, the process will write the whole
1.1       jdf       379:        image to the CD and return with a shell prompt.
                    380: 
                    381:        Note that cdrecord(8) works on both SCSI and IDE (ATAPI) drives.
                    382: 
                    383:  4. Test
                    384: 
1.2     ! jdf       385:        Mount the just-written CD and test it as you would do with any "normal" CD,
1.1       jdf       386:        see [[Reading data CDs with NetBSD|guide/rmmedia#cdrom]].
                    387: 
                    388: ## Using a CD-R writer to create audio CDs
                    389: 
1.2     ! jdf       390: If you want to make a backup copy of one of your audio CDs, you can do so by
        !           391: extracting ("ripping") the audio tracks from the CD, and then writing them back
        !           392: to a blank CD. Of course this also works fine if you only extract single tracks
1.1       jdf       393: from various CDs, creating your very own mix CD!
                    394: 
                    395: The steps involved are:
                    396: 
                    397:  1. Extract ("rip") the audio tracks as described as in
                    398:     [[Using audio CDs with NetBSD|guide/rmmedia#cdrom-audio]]
                    399:        to get a couple of .wav files.
                    400: 
1.2     ! jdf       401:  2. Write the .wav files using cdrecord command from the
        !           402:     [`sysutils/cdrtools`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/cdrtools/README.html)
1.1       jdf       403:     package:
                    404: 
                    405:         # cdrecord -v dev=/dev/rcd0d -audio -pad *.wav
                    406: 
                    407: ## Creating an audio CD from MP3s
                    408: 
1.2     ! jdf       409: If you have converted all your audio CDs to MP3 and now want to make a mixed CD
        !           410: for your (e.g.) your car, you can do so by first converting the .mp3 files back
1.1       jdf       411: to .wav format, then write them as a normal audio CD.
                    412: 
                    413: The steps involved here are:
                    414: 
                    415:  1. Create .wav files from your .mp3 files:
                    416: 
                    417:         $ mpg123 -w foo.wav foo.mp3
                    418: 
1.2     ! jdf       419:        Do this for all of the MP3 files that you want to have on your audio CD. The
1.1       jdf       420:        .wav filenames you use don't matter.
                    421: 
1.2     ! jdf       422:  2. Write the .wav files to CD as described under [[Using a CD-R writer to
1.1       jdf       423:     create audio CDs|guide/rmmedia#cdr-audio]].
                    424: 
                    425: ## Copying an audio CD
                    426: 
1.2     ! jdf       427: To copy an audio CD while not introducing any pauses as mandated by the CDDA
1.1       jdf       428: standard, you can use cdrdao for that:
                    429: 
                    430:     # cdrdao read-cd --device /dev/rcd0d data.toc
                    431:     # cdrdao write   --device /dev/rcd1d data.toc
                    432: 
                    433: ## Copying a data CD with two drives
                    434: 
1.2     ! jdf       435: If you have both a CD-R and a CD-ROM drive in your machine, you can copy a data
1.1       jdf       436: CD with the following command:
                    437: 
                    438:     # cdrecord dev=/dev/rcd1d /dev/rcd0d
                    439: 
1.2     ! jdf       440: Here the CD-ROM (cd0) contains the CD you want to copy, and the CD-R (cd1)
        !           441: contains the blank disk. Note that this only works with computer disks that
        !           442: contain some sort of data, it does *not* work with audio CDs! In practice you'll
1.1       jdf       443: also want to add something like `speed=8` to make things a bit faster.
                    444: 
                    445: ## Using CD-RW rewritables
                    446: 
1.2     ! jdf       447: You can treat a CD-RW drive like a CD-R drive (see [[Using a CD-R writer with
        !           448: data CDs|guide/rmmedia#cdr]]) in NetBSD, creating images with mkisofs(8) and
1.1       jdf       449: writing them on a CD-RW medium with cdrecord(8).
                    450: 
                    451: If you want to blank a CD-RW, you can do this with cdrecord's `blank` option:
                    452: 
                    453:     # cdrecord dev=/dev/rcd0d blank=fast
                    454: 
1.2     ! jdf       455: There are several other ways to blank the CD-RW, call cdrecord(8) with
1.1       jdf       456: `blank=help` for a list. See the cdrecord(8) man page for more information.
                    457: 
                    458: ## DVD support
                    459: 
1.2     ! jdf       460: Currently, NetBSD supports DVD media through the ISO 9660 also used for CD-ROMs.
        !           461: The new UDF filesystem also present on DVDs has been supported since NetBSD 4.0.
        !           462: Information about mounting ISO 9660 and UDF filesystems can be found in the
        !           463: [mount\_cd9660(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount_cd9660+8+NetBSD-5.0.1+i386)
        !           464: and
        !           465: [mount\_udf(8)](http://netbsd.gw.com/cgi-bin/man-cgi?mount_udf+8+NetBSD-5.0.1+i386)
        !           466: manual pages respectively. DVDs, DivX and many avi files be played with
        !           467: [`multimedia/ogle`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/multimedia/ogle/README.html)
        !           468: or
1.1       jdf       469: [`multimedia/gmplayer`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/multimedia/gmplayer/README.html).
                    470: 
1.2     ! jdf       471: For some hints on creating DVDs, see this [postings about
        !           472: growisofs](http://mail-index.NetBSD.org/current-users/2004/01/06/0021.html) and
        !           473: [this article about recording CDs and DVDs with
1.1       jdf       474: NetBSD](http://www.mreriksson.net/blog/archive/15/).
                    475: 
                    476: ## Creating ISO images from a CD
                    477: 
                    478: To create an ISO image and save the checksum do this:
                    479: 
                    480:     # readcd dev=/dev/cd0d f=/tmp/cd.iso
                    481: 
                    482: Here is an alternative using dd(1):
                    483: 
                    484:     # dd if=/dev/cd0d of=/tmp/cd.iso bs=2048
                    485: 
                    486: If the CD has errors you can recover the rest with this:
                    487: 
                    488:     # dd if=/dev/cd0d of=/tmp/cd.iso bs=2048 conv=noerror
                    489: 
                    490: To create an ISO image from a mounted data CD first, mount the CD disk by:
                    491: 
                    492:     # mount -t cd9660 -r /dev/cd0d /mnt/cdrom
                    493: 
                    494: Second, get the image:
                    495: 
                    496:     # mkhybrid -v -l -J -R -o /tmp/my_cd.iso /mnt/cdrom/
                    497: 
                    498: ## Getting volume information from CDs and ISO images
                    499: 
                    500: You can read the volume data from an unmounted CD with this command:
                    501: 
                    502:     # file -s /dev/cd0d
                    503: 
                    504: You can read the volume data from an ISO image with this command:
                    505: 
                    506:     # isoinfo -d -i /tmp/my_cd.iso
                    507: 
                    508: You can get the unique disk number from an unmounted CD with this:
                    509: 
                    510:     # cd-discid /dev/cd0d
                    511: 
                    512: You can read the table of contents of an unmounted CD with this command:
                    513: 
                    514:     # cdrecord -v dev=/dev/cd0d -toc
                    515: 
                    516: ## Initializing and using floppy disks
                    517: 
1.2     ! jdf       518: PC-style floppy disks work mostly like other disk devices like hard disks,
        !           519: except that you need to low-level format them first. To use an common 1440 KB
1.1       jdf       520: floppy in the first floppy drive, first (as root) format it:
                    521: 
                    522:     # fdformat -f /dev/rfd0a
                    523: 
1.2     ! jdf       524: Then create a single partition on the disk using
1.1       jdf       525: [disklabel(8)](http://netbsd.gw.com/cgi-bin/man-cgi?disklabel+8+NetBSD-5.0.1+i386):
                    526: 
                    527:     # disklabel -rw /dev/rfd0a floppy3
                    528: 
                    529: Creating a small filesystem optimized for space:
                    530: 
                    531:     # newfs -m 0 -o space -i 16384 -c 80 /dev/rfd0a
                    532: 
1.2     ! jdf       533: Now the floppy disk can be mounted like any other disk. Or if you already have a
        !           534: floppy disk with an MS-DOS filesystem on it that you just want to access from
1.1       jdf       535: NetBSD, you can just do something like this:
                    536: 
                    537:     # mount -t msdos /dev/fd0a /mnt
                    538: 
1.2     ! jdf       539: However, rather than using floppies like normal (bigger) disks, it is often more
        !           540: convenient to bypass the filesystem altogether and just splat an archive of
1.1       jdf       541: files directly to the raw device. E.g.:
                    542: 
                    543:     # tar cvfz /dev/rfd0a file1 file2 ...
                    544: 
1.2     ! jdf       545: A variation of this can also be done with MS-DOS floppies using the
        !           546: [`sysutils/mtools`](http://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc/sysutils/mtools/README.html)
        !           547: package which has the benefit of not going through the kernel buffer cache and
        !           548: thus not being exposed to the danger of the floppy being removed while a
1.1       jdf       549: filesystem is mounted on it.
                    550: 

CVSweb for NetBSD wikisrc <wikimaster@NetBSD.org> software: FreeBSD-CVSweb