Mounting File Systems


File systems in UNIX are very flexible in that they need not be physically present on your computer; you can have network access to other file systems on other machines. The Linux file system structure (the Virtual File System we spoke of at the beginning of the chapter) makes it appear as if all the file systems, regardless of type and location, are local and mounted somewhere on the root file system. As the system administrator, you decide what file systems are to be made available and where they will be attached, or mounted, to the root file system. The standard arrangement of the file system tree is that installed by default by Fedora. The source of that standard arrangement is found in the file system hierarchy standards. Although a detailed discussion of those standards is beyond the scope of this section, they can be examined at http://www.pathname.com/fhs/. In this section, you learn how to mount file systems to the root file system and add file systems to the system, and you learn the traditional mount points of commonly used file systems as well.

In Linux (and its UNIX cousins), all file systemswhether local, remote, images on a disk, or in memoryare mounted on a single point known as root (which is not the same as the root operator, also known as the super-user). This mount point is written as a forward slash, /, which is read and pronounced "root." The resulting file directory hierarchy all starts from /. After they are mounted, the physical location of the files is unimportant because they all appear to be local.

Even if the file systems are different (FAT, ext2, HPFS, NTFS, and so on), the Linux kernel modules and the VFS make them all appear as part of the directory tree as native files. Listing the file systems as native files obviates the need for any applications to be aware of the physical location of the file or the true nature of the native file system. As a result, programming these applications is simplified because the applications have to work only with what they think are local, native files.

Any file system can be mounted anywhere, but some places are more traditional than others. Removable media devices are traditionally mounted under the /mnt directory (for example, floppy drives on /mnt/floppy and CD-ROM drives on /mnt/cdrom). The /mnt directory is the traditional place to mount removable or remote file systems that are unrelated to the local system directories that branch from the root mount point.

The mount Command

File systems are mounted with the mount command and unmounted, curiously enough, with the umount command.

During the installation, you have the opportunity to decide where and how your partitions will be mounted. You indicate your choices, and Fedora Core automatically stores them in /etc/fstab, the file system table, for you. The mount command looks at /etc/fstab and mounts the file system according to those set preferences. You learn more about the file system table later in this section.

The syntax for mount is

mount -t type file system_to_be mounted mount_point


Here are the components of the mount command, and a brief explanation of each:

type Always preceded by the -t argument and followed by a space, and then the type of file system you are mounting. Typical file system types are ext2, ext3, vfat, iso9660, hpfs, hfs, ntfs, and others. For many file systems, mount can detect what type they are automatically, and the -t argument is superfluous (and is replaced with auto).

file system_to_be mounted (as represented by the partition on which it resides) This is the device name of the file system you want to mount, typically in the form of /dev/hdx, /dev/scx, or /dev/fdx.

mount_point The place in the directory tree where you want to mount the file system. Curiously, you can mount a file system over part of an existing file system. For example, if you have an existing directory at /foo with a single file named bar, and you mount a file system at /foo that includes a file named snafu, a listing of the directory /foo will not show the file bar, but only the file snafu. To show both files is a feature called TRansparency, which unfortunately is not in the current Linux repertoire.

The only real restriction to "mount anything anywhere" is that the critical system files in /bin, /etc, /lib, /dev, /proc, and /tmp need to be accessed at bootup, which typically means that they need to be on the same physical disk. If they cannot be accessed at bootup, Linux will not load and run.

Here are a few examples of using the mount command:

Mounting a floppy:

# mount -t vfat /dev/fd0 /mnt/floppy


Mounting a CD-ROM:

# mount -t iso9660 /dev/scd0 /mnt/cdrom


Mounting a Network File System (NFS) volume:

# mount -t nfs remote_host:/dir [options] mount_point


Numerous mount options exist. These options are used primarily in the /etc/fstab file. You can invoke a mount option by preceding it (or a comma-delimited string of options) with the -o switch. The mount options are listed in the fstab section of this chapter.

The umount Command

To unmount a file system, use the umount command with the following syntax:

umount mount_point


You can also unmount by device name:

umount device_name


Caution

Do not use umount -a to unmount everything that the system does not require to run (or is not currently using). Unmounting everything is a particularly bad idea on a multiuser, networked system because your users will undoubtedly lose access to some or all their files. So, as any good sysadmin will tell you, do not do that.


Mounting Automatically with /etc/fstab

A special file, /etc/fstab, exists to provide the system with predetermined options and mount points so that the file systems can be automatically or manually mounted with minimal typing and without having to recall arcane Linux syntax.

The /etc/fstab file can only be written to by the super-user. The commands fsck, mount, and umount all read information from /etc/fstab. Each file system gets its own line with the information separated by tabs.

On each line of fstab, the first field indicates the block device or remote file system that will be mounted. The second field identifies the mount point on the local system where the file system will be mounted. The third field is the file system type, and the fourth field is a comma-delimited list of mount options. Options include

exec If this option is specified, binaries can be executed from this file system.

noauto This means that the -a option will not cause the file system to be mounted and it will not be mounted at bootup.

noexec If this option is specified, binaries cannot be executed from this file system.

nosuid This option does not permit set-user-identifier or set-group-identifier bits to take effect.

ro This option mounts the file system as read-only.

rw This option mounts the file system as read/write.

sync Reading from and writing to the files are done synchronously.

user This option allows a regular (not just root) user to mount the file system, but it includes the options noexec, nosuid, and nodev by default unless they are overridden by exec, dev, and suid.

For iso9660 file systems, the interesting option is unhide, which shows hidden and associated files.

The fstab man pages contain an in-depth description of fstab and its options.

The fifth field of /etc/fstab is used by dump (a traditional UNIX backup program) to determine whether the file system should be dumped (backed up); 1 is yes, and 0 is no. Default values are set for you during the initial installation. They are of concern only if you actually use dump; then you would set the value to 1 for the file systems you wanted to back up.

The sixth field is used by fsck to determine how fsck needs to interact the file system0 means that fsck is never run on the file system (a FAT32 file system, for example); 1 means that fsck will be run on the drive at a predetermined time. 2 is recommended for nonroot file systems so that fsck is not run on them as frequently.

Here is a simple /etc/fstab file from a system with a RAID0 ext3 root partition and dual-booted with MS Windows:

LABEL=/12    /             ext3    defaults               1 1 none         /dev/pts      devpts  gid=5,mode=620         0 0 none         /proc         proc    defaults               0 0 none         /dev/shm      tmpfs   defaults               0 0 /dev/hda11   swap          swap    defaults               0 0 /dev/cdrom   /mnt/cdrom    iso9660 noauto,owner,kudzu,ro  0 0 /dev/fd0     /mnt/floppy   auto    noauto,owner,kudzu     0 0 /dev/hda1    /mnt/win_c    vfat    auto,quiet,exec        0 0


Notice the two entries marked with the kudzu option. This is the result of the actions of updfstab, which keeps fstab synchronized with the state of any removable devices on the system such as CD-ROMs, floppy drives, Zip and Jaz drives, LS-120 drives, and some digital cameras. The quiet option shown for the Windows partition will suppress error messages and is recommended if you use the Wine application.

Note

Device labels can be very useful. You can use the label in /etc/fstab, and if you have many devices, their labels might be easier for you to remember and track than would their device names. You can also shuffle around partitions without editing fstab, just by changing their labels. The e2label command is easier to remember than the analogous tune2fs command.

The command e2label can display or change the label of a device. (You also can change a device label with tune2fs -L.) For example, to change the label of /dev/hda4 to archives, use

# e2label /dev/hda4 archives



As mentioned earlier, you record mounting preferences in /etc/fstab during installation. You need to modify /etc/fstab only if you make changes to your mounts or desire to change the default settings to address the specific needs of your system.

As long as the super-user understands the syntax and options of the fstab file, she can edit the file with any text editor.

GUI Tools to Mount File Systems

The usermount graphical file system management client is available for use with Fedora Core Linux. Although Fedora Core provides usermount as the default file system-mounting tool, it is not as feature-rich as KDiskFree, which is installed when you select the KDE desktop during installation.

The K Desktop Environment (KDE) provides several disk- and file system-related utilities. You might find one or more available on your Fedora Core system if you select KDE for installation. Found in the Extras menu under System Tools, the KDiskFree menu item (it is kdf from a command line) displays all the file systems noted in the /etc/fstab file, presents information about them, and allows you to easily mount and unmount them (see Figure 38.1). KWikDisk enables mounts and unmounts from a panel applet.

Figure 38.1. KDiskFree provides a graphical interface to tools used to configure custom mount options, as well as mount, or unmount disks.


The User Mount Tool, accessed from the System Tools menu as the Disk Management menu item, is a convenient way to mount and unmount file systems (see Figure 38.2). It also allows you to format floppy disks.

Figure 38.2. The User Mount Tool is the default Fedora Core disk management GUI tool. It can mount and unmount file systems, as well as the cdrom device.


Floppy Formatter is a KDE tool used to easily format a floppy in ext2 or FAT format. You can start it by choosing System Tools, Floppy Formatter. Floppy Formatter can format floppy disks in 3.5" and 5.25" high- and low-density formats (see Figure 38.3).

Figure 38.3. Point and click for floppy formatting makes it easy. A larger choice of formatting options (like a 1.7MB 3.5" floppy) would be nicer. The Floppy Formatter is found under the System Tools menu.


Automounting with the Automount Daemon (amd) and autofs

The automount daemon watches specified devices and mounts the devices when they are accessed and unmounts them when there has been no activity. The configuration files are /etc/auto.master and /etc/auto.misc. The former file contains only comments; the latter contains examples and the sole entry used by Fedora Core to automount the CD-ROM drive. If you insert a CD, after a long pause, a file browser will appear on your desktop. Many people find this behavior annoying and prefer to disable automount.

Because autofs is started at boot time and controls the automount daemon, simply do not run autofs. Use the checkconfig, ntsysv, or GUI clients to edit the startup scripts for your runlevel (refer to Chapter 15, "Automating Tasks," for details).




Red Hat Fedora 5 Unleashed
Red Hat Fedora 5 Unleashed
ISBN: 067232847X
EAN: 2147483647
Year: 2004
Pages: 362

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net