The two most common tasks with removable media are mounting CD-ROMs and floppies, and formatting floppy disks. We'll discuss how to simplify both of them.
Typing long commands for mounting common media can be tedious and annoying. I usually edit /etc/fstab to make life a little easier. If a removable filesystem has an entry in /etc/fstab, you can drop the device name when mounting it and you can just use mount(8) instead of the file system-specific command.
# mount /mnt
That's far easier than typing "mount_msdos /dev/fd0c /mnt" every time, isn't it?
Here are some sample entries for /etc/fstab to mount MS-DOS floppies on /mnt and CD-ROMs on /cdrom. (OpenBSD does not create a /cdrom directory during the install, so you must create that directory before this will work.)
/dev/cd0c /cdrom cd9660 ro,noauto /dev/fd0c /mnt msdos rw,noauto
What most Windows users think of as "formatting a floppy" is actually a multi-stage process that includes performing a low-level format, giving it a disklabel, and creating a file system. You must do all of these tasks to make a usable floppy in OpenBSD.
Start by doing a low-level format of the floppy disk with fdformat(8). This program only requires one argument, the floppy's device name.
# fdformat /dev/fd0c Format 1440K floppy `/dev/fd0c'? (y/n): y
When you type y, fdformat(8) will start running a low-level format to prepare the disk to receive a file system. Low-level formatting is the slowest part of making a floppy usable.
Once you have formatted the disk, you can decide to put either a FFS or MS-DOS filesystem on the floppy.
To swap data between a Windows machine and your OpenBSD box, format your floppy with the MS-DOS file system. The OpenBSD program newfs_msdos(8) provides this functionality.
# newfs_msdos /dev/rfd0c /dev/rfd0c: 2840 sectors in 355 FAT12 clusters (4096 bytes/cluster) bps=512 spc=8 res=1 nft=2 rde=512 sec=2880 mid=0xf0 spf=2 spt=18 hds=2 hid=0 #
That's it!
FFS file systems need a valid disklabel on every disk, even something as simple as a floppy. disklabel(8) can grab predefined disklabels from /etc/disktab and copy them to a disk, which simplifies the process considerably. While disklabel(8) can also create partition information or mark a disk as bootable, this is all overkill for a floppy disk. You can do all the required labeling by just running:
# disklabel 1 -w 2 /dev/rfd0c 3 floppy
The 1 "-w" option tells disklabel(8) to write to the raw disk device 2 /dev/rfd0c, using the "floppy" label from 3 /etc/disktab.
Now that you have a label, you can create a file system with newfs(8).
# newfs /dev/rfd0c /dev/rfd0c: 2880 sectors in 80 cylinders of 2 tracks, 18 sectors 1.4MB in 5 cyl groups (16 c/g, 0.28MB/g, 64 i/g) super-block backups (for fsck -b #) at: 32, 640, 1184, 1792, 2336, #
That looks much more interesting than the MS-DOS file system-creation output, doesn't it? FFS is a more complex file system than any variant of FAT. The various MS-DOS file systems are more interchangeable between machines, however, being something of a lowest common denominator these days. You need to decide what best suits your needs.