Configuring Removable Media

Before you can begin using external media, you must configure them for use. For traditional disk media (floppies, Zip disks, and so on), this process involves either creating /etc/fstab entries, much as for hard disk filesystems; or using special access programs for some non-Linux filesystems. The upcoming section, "Burning CD-Rs," describes how to create CD-Rs in Linux. Chapter 17, "Protecting Your System with Backups," describes tape backups in more detail.

Prior to creating /etc/fstab entries or using other access methods, you must ensure that your computer can recognize the hardware itself. Some devices, including floppies and ATA drives, may need to be enabled in the computer's BIOS settings, so check there if you have problems seeing the device. For other devices, including SCSI devices if this is your only SCSI device, USB devices, and IEEE-1394 devices, you'll need to compile the appropriate support into the kernel to handle the controller or device. In particular, be sure you enable the support for SCSI disk devices (even for USB and IEEE-1394 devices), as well as for the appropriate SCSI, USB, or IEEE-1394 interface hardware.

Using Access Programs for Quick Access

Two packages enable quick access to FAT and HFS media without actually mounting a drive. These packages are mtoolsfor FAT (http://mtools.linux.lu) and HFS Utilities for HFS (http://www.mars.org/home/rob/proi/hfs/). Both packages enable you to insert a removable disk and copy files to and from the disk without mounting the disk with mount. Table 2.6 summarizes some of the commands offered by these packages.

Table 2.6: FAT and HFS Access Commands

mTools Command

HFS Utilities Command

Action

hmount

Tells HFS Utilities what device to use.

humount

Tells HFS Utilities to stop using a volume.

mformat

hformat

Writes a new filesystem.

mcopy

hcopy

Copies a file to or from the disk.

mdir

hdir

Displays a directory listing.

mdel

hdel

Deletes a file.

mmove

hrename

Moves or renames a file.

mmd

hmkdir

Creates a new directory.

mrd

hrmdir

Removes an empty directory.

The mtools programs use DOS-style drive letters to determine what device to access.

The mtools programs use DOS-style drive letters to determine what device to access.

By default, a: and b: refer to the first and second floppy disks. Therefore, immediately after inserting a floppy disk, you could type mcopy prog.zip a: to copy prog.zip to the floppy. To use additional devices, you can edit the /etc/mtools.conf configuration file. (If you install mtools from source code, this file may be in /usr/local/etc.) If you want to create a custom configuration for a specific user, place it in the user's .mtoolsrcfile, which overrides the global default file. These files link drive letters to specific device files using lines such as the following:

drive n: file=/dev/sda4

This line maps the n: drive to /dev/sda4 (a common identifier for the standard partition used by SCSI Zip disks). The standard file includes several examples, although some are intended for use under non-Linux OSs.

HFS Utilities requires that you first use hmount to tell the tools to access the disk. For instance, you might type hmount /dev/sda to tell the system to use an HFS-formatted SCSI Zip disk. Some commands, such as hcopy, require that you use the name of the disk volume as part of the command, or at least a colon (:) to indicate which filename is a local Linux filename and which applies to the HFS disk. For instance, you might type hcopy prog.sit.hqx xfer: to copy prog.sit.hqx to a volume with the disk label xfer. When you're done, you must use humount to finish all operations and stop using the removable disk. This step may be necessary to eject some removable disks. In addition to the standard text-mode tools, HFS Utilities includes a GUI front-end, xhfs, which enables point-and-click file transfers.

Both mtools and HFS Utilities provide access to their supported filesystems even when the Linux kernel lacks that support. HFS Utilities has the advantage of being a bit less trouble-prone than the Linux kernel's HFS support. Both suffer from one disadvantage, though: They're fundamentally just file-transfer tools. That is, you can't launch a Linux program and directly access files on the removable disk from that program. You must first copy the files to your hard disk, then copy them back to the removable disk when you've finished making changes. These tools also do no good if you want to access other filesystems, such as ext2fs or ISO-9660. In order to enable ordinary users to directly access any filesystem supported by the kernel, you must create /etc/fstab entries.

Creating /etc/fstab Entries for Regular Access

The /etc/fstab file tells Linux where to mount specific filesystems. Entries for removable media are just like those for hard disk partitions. Most Linux distributions set up a few standard removable-media entries in /etc/fstab upon installation, so you may not need to modify these entries. Typical entries resemble the following:

/dev/cdrom /mnt/cdrom iso9660 user,noauto.ro 0 0 /dev/sda4 /mnt/zip auto user,noauto,uid=500 0 0

There are, however, some changes you might want to make:

Mount Points Some distributions, such as Slackware and Debian, place mount points in the root (/) directory, as in /cdrom for the CD-ROM drive. Others, such as Red Hat and Mandrake, place mount points for individual drives within the /mnt directory, as in /mnt/cdrom. SuSE places mount points in subdirectories of/media, as in /media/cdrom. By altering the second column of the /etc/fstab entry for a device, you can change these assignments as you see fit.

Filesystem Type Codes The filesystem type code tells Linux what filesystem to use when mounting a device. Common removable-media filesystem type codes include ext2 (ext2fs), minix (Minix filesystem) msdos (FAT with short filenames), vfat (FAT with long filenames), hfs (HFS), and iso9660 (ISO-9660, with auto-detection of Rock Ridge or Joliet extensions). It's sometimes not possible to specify in advance what filesystem a removable medium will use, so one common practice is to use the auto specification, which tells Linux to auto-detect the filesystem type. This feature usually works correctly, but on occasion it doesn't. You may want to specify different options for different filesystem types. In such cases, you can create separate entries, using different mount points, for each filesystem type.

Filesystem-Neutral Options The mount man page details many filesystem-neutral options, which appear in a comma-separated list in the fourth column of/etc/fstab. Common options for removable media include ro (to force read-only access), noexec (to prevent users from executing program files on removable media), user (to enable ordinary users to mount and unmount the filesystem), and noauto (which tells Linux not to mount the filesystem when it boots). The last two options are particularly common for removable media, which normally aren't mounted until a user wants to access them.

Filesystem-Specific Options Many filesystems include options unique to themselves or to just a few filesystems. The uid=useA"-/D and g\6=group-ID options are common on non-Linux filesystems. These options set the user ID and group ID, respectively, to be assigned to all files on a mounted filesystem. Similarly, the umask=umas/ioption sets the umask. These options are useful in fine-tuning who may access files on a mounted filesystem that doesn't support standard Unix-style ownership and permissions.

Some GUI environments attempt to auto-mount a filesystem when a CD-ROM disk is inserted. This setup is the default in Red Hat's GNOME configuration, for instance. If you prefer to manually mount your volumes, you can disable the automatic setup using tools such as the CD and DVD Properties tool in Red Hat, accessible from the GNOME Menu O Preferences O CD Properties menu option.

Team LiB

0 0

Post a comment