Mounting a File System


A Linux system doesn't really care what is attached to it at any given moment. Do you want to connect to a printer down the hall, a co-worker's laptop in Australia, a backup mirror on the corporate server in Shanghai, or a floppy disk in your own machine? No problem with the mount command and the right permissions, all these devices and file systems will appear on your system as if they were all just another part of your computer.

If you are the system administrator, you have near-absolute power over what file systems appear on your system, to whom, and when. In practice, this power is exercised through the use of the mount and umount commands, and through the /etc/fstab file governing file systems. In this section, you will learn about each of these tools.

The mount Command

The mount command loads a file system onto your computer and makes it visible. To mount a floppy disk, for example, insert the disk and then type the following (as SuperUser) at the shell prompt:

mount -t vfat /dev/fd0 /media/floppy 

This is how the syntax breaks down (and you need all this to make it work):

  • Type (-t) This flag and the next item identify the file system type for the platform to be mounted (in this case, the floppy is formatted for FAT32).

  • File system Point to the device partition you are mounting. Floppy disks are, by default, /dev/fd0. This information is set by and retrievable from /etc/fstab (see the section on /fstab later in the chapter).

  • Mount Point Where fstab actually looks for the files. In this case, /media/floppy.

It is a good idea to have all your peripheral file systems (floppy drives, hard drives, USB and serial-port file storage devices, CD-ROM, DVD, and CD-RW drives) connected when you install SUSE Linux. Why? YaST can then identify all these devices and build your /etc/fstab file automatically.

The umount Command

Most of the time after you have mounted a hard drive or partition, you'll keep it mounted. You're always accessing it. Removable storage media are different; you'll often pop one in, work on files (or copy/move them to your hard drive) and pop it out again. In Linux this is a little more complicated process.

After you have mounted a floppy as described in the last section, before you can put another floppy in the drive, you must unmount the drive. To do this, you must use the umount command (without an N):

umount /media/floppy 

or

umount /dev/fd0 

Before unmounting any file system, make sure that no processes are using files on that file system. You will get an error message if that's the case.

Using /etc/fstab to Automatically Mount File Systems

The default file system mount behavior is set by the FileSystem TABle, or fstab. YaST sets this up during the initial installation. You can modify it directly in a text editor (as Root) or use Expert Partitioner's partition editing tool. After you understand the structure of the file, it will be much easier to hand-edit etc/fstab, but EP's fstab options page offers a friendlier interface if you are reluctant to hand-edit critical files.

Tip

You can view, but not edit, your fstab file in KdiskFree. This tool lets you see your current disk usage, device type, and mount point. You can mount unmounted file systems as well.


Here is a busy etc/fstab file, containing several drives and partitions, along with a CD-RW.

/dev/hda2  /            reiserfs  acl,user_xattr      1 1 /dev/sda1 /windows/C    ntfs       ro,users,gid=users,umask=0002,nls=utf8 0 0 /dev/hda1 swap          swap       pri=42             0 0 devpts   /dev/pts       devpts     mode=0620,gid=5    0 0 proc     /proc          proc       defaults           0 0 usbfs    /proc/bus/usb  usbfs      noauto             0 0 sysfs    /sys           sysfs      noauto             0 0 /dev/cdrecorder      /media/cdrecorder    subfs fs=cdfss,ro,procuid,nosuid,nodev,exec,iocharset=utf8 0 0 /dev/fd0             /media/floppy        subfs fs=floppyfss,procuid,nodev,nosuid,sync 0 0 

Each line in the fstab file represents another device, file system, or hard drive. The order of items in each line are identical, with six fields altogether. You would guess (correctly) that all the items included in the mount syntax discussed earlier appear here. In order, they would be File system, Mount Point, and Type. The other items are various options that you did not set in the earlier simple example of the mount command.

The fourth field indicates the mount options for that file system, separated by commas. For example, the Windows drive, /dev/sda1, mounts as read-only (ro) and all users can mount the drive. If the user flag is not set, only Root can mount the file system. /dev/cdrecorder includes the exec option, which allows you to run binaries from the CD drive. The / (Root) partition uses an Access Control List (ACL) to determine whether binaries can be executed. This means permissions are set at a lower, more fine-grained level than just allowing anyone with access to the partition to execute programs.

The other options listed here are generally specific to that file system. To see all the options that can be used here, see the mount and fstab man pages.

The last two fields (in the example, all are marked 0 0 except for /, which is 1 1) are digits that other programs use. The fifth field tells dump, a venerable Unix backup program, whether to back up the file system when it is run: 1=Yes, 0=No.

The last field tells the file system repair tool fsck how to interact with each file system: 0=Never, 1=Run at a designated time, 2=Run periodically, but less often than the 1s.

You should not have to edit /etc/fstab more than once, but if you have problems with the OS not seeing a file system (CD won't run, can't copy files from a floppy or Zip disk, for example), this is usually the place to start troubleshooting.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

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