File:  [NetBSD Developer Wiki] / wikisrc / guide / rmmedia.mdwn
Revision 1.5: download - view: text, annotated - select for diffs
Fri Jun 19 19:18:31 2015 UTC (5 years, 4 months ago) by plunky
Branches: MAIN
CVS tags: HEAD
replace direct links to manpages on netbsd.gw.com with templates

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

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