Accessing Media Filesystem Manipulation Tools

One common requirement when using a Linux workstation is the need to access removable media—floppy disks, Zip disks, CD-ROMs, and so on. If you're familiar with DOS or Windows, you're probably used to accessing these media using drive letters, such as A: for the floppy disk. This approach doesn't normally work in Linux, although the mtools package enables limited access in this way, as described in Chapter 2, "Improving Disk Performance." Instead, you must mount a removable disk to a mount point—that is, make it available at a specific directory set aside for this purpose. Chapter 2 describes editing /etc/fstab to create mount points for your removable media disks. If you include the user option, ordinary users can mount and unmount the filesystem, but only the user who mounted it can unmount it. The users option works in the same way, but anybody can unmount the filesystem once it's mounted.

To mount a filesystem, you use the mount command, followed by the mount point or device filename, as shown here:

$ mount /mnt/floppy

This command mounts the device with a defined mount point of/mnt/floppy in

/etc/fstab—presumably the floppy drive. Assuming permissions allow, you can then read, write, and otherwise manipulate files on the floppy disk. When you're done, you should unmount the disk using the umount command:

$ umount /mnt/floppy

Note The umount command really does have just onen; if you typeunmount, it won't work.

These commands work as shown only if you've defined a mount point in /etc/fstab; if you haven't, you must also specify the device file used to access the partition or disk, as in mount /dev/fdO /mnt/floppy. Only root can mount a filesystem for which no /etc/fstab entry exists.

Sometimes you need to prepare a disk to hold files. You use one or both of two commands to do this job:

fdformat This command performs a low-level format of the floppy disk. This format defines the low-level data structures, such as sectors and tracks. This tool can only be used on floppy disks; hard disks are low-level formatted at the factory.

mkfs This tool writes a filesystem to a disk or partition, an operation that's sometimes called high-level formatting. In reality, mkfs calls other programs, such as mkfs.ext2 and mkdosfs, to do the real work.

Suppose you have a new unformatted floppy disk you want to use to exchange data with a Windows user. You could use the following commands to prepare the disk:

Note These commands only work if you have write access to the device file—/dev/fdO in this example. Some distributions give the user logged into the console ownership of/dev/fdO and some other device files. Others have a group called floppy or disk and grant read/write access to these files to that group, so you can add any authorized user to the appropriate group.

After creating a filesystem, you can mount the floppy and copy files to it. If you prefer to use a filesystem other than FAT, you can do so—substitute the other filesystem's name, such as ext2 or minix, for msdos. Because fdformat is used only for floppy disks, you won't type that command when using Zip disks or other non-floppy removable media. You also don't need to use fdformat on floppies that have already been used.

Chapter 12, "Filesystems and Files," describes filesystems and more advanced filesystem tools in more detail. Check there if you need to decide what filesystem to use on a hard disk, recover a corrupted filesystem, or perform other advanced tasks.

0 0

Post a comment