etcfstab, e2label, and mount

 < Day Day Up > 

/etc/fstab, e2label, and mount

/etc/fstab

The /etc/fstab file mentioned earlier is used by e2fsck to determine the sequence of the file system check if it is required at the time of boot. The sequence of entries in /etc/fstab is important if a "pass number" for any of the entries does not exist. Here is an example of the /etc/fstab file from the Integrity server with SCSI:


      LABEL=/          /                ext3      defaults          1        1
      /dev/sda1        /boot/efi        vfat      defaults          0        0
      none             /dtev/pts        devpts    gid=5,mode=620    0        0
      none             /proc            proc      defaults          0        0
      none             /dev/shm         tmpfs     defaults          0        0
      /dev/sda2        swap             swap      defaults          0        0
      /dev/cdrom       /mnt/cdrom       iso9660   noauto,owner,     0        0
                                                    kudzu, ro
           |                  |            |          |             |        |

           v                  v            v          v             v        v

__________________________________________________________________________________
        /dev/device         directory       fstype   options     dump       pass
          or label                                             frequency     #
__________________________________________________________________________________

Table 4-1. Description /etc/fstab fields

Field

Description

/dev/device or label the device special file (if any)

The partition to be mounted, such as /dev/sda1. The device does not have to be given explicitly. You can use LABEL instead of the device by mapping the device to a label with the following:

 # /sbin/e2label /dev/sdbx /mountpoint # /sbin/e2label /dev/sdb1 /backup 

The entry for /backup can then be added to the /etc/fstab file with the LABEL as described shortly.

You have to be careful using the LABEL because in some cases, it is not supported.

directory

The name of the directory under which the device special file is mounted such as /backup.

fstype

Can be one of several types, including ext2 local file system version 2, ext3 local file system version 3, msdos local MS-DOS partition, nfs remotely mounted NFS, swap partition used for swapping, or iso9660 local CD-ROM file system

options

Options associated with the file system type. These are -o options.

dump frequency

Used by dump command to determine which file systems need to be dumped.

pass #

Specifies the order in which file systems are to be checked by e2fsck at reboot time.

Comments

Anything you want, as long as it's preceded by a # (pound sign or cross-hatch).


As you can see, in the /etc/fstab example, the cdrom has several options, including ro for read only. Swap, or virtual memory, is on /dev/sda2. /proc has a none associated with it because it is an interface to kernel parameters and not a file system like the others. /dev/pts also has a none associated with it because it is a way for remote system access with programs, such as telnet and rlogin, to get access to your system.

You could easily add entries to /etc/fstab so that the system will mount /backup when it boots. Because you want to mount /dev/sdb1 using its label (/backupB), first use the command e2label to create a label. After you do that, run the e2label command again to display the results:

 [root@localhost root]# /sbin/e2label /dev/sdb1 /backup [root@localhost root]# /sbin/e2label /dev/sdb1 /backup [root@localhost root]# 

As you can see, we performed the desired labeling. Now, in order to automatically mount the new partition at boot time, add the following line to the /etc/fstab file:

 LABEL=/backup    /backup   ext3    defaults  1 2 

Then, save the file. If you want to check if the partition will be mounted in the correct place at boot time, reboot and log on again, or issue the following commands.

 [root@localhost root]# mount -a [root@localhost root]# df Filesystem           1k-blocks      Used Available Use% Mounted on /dev/sda3             68450624   1419368 63554124    3% / /dev/sda1               104184      6120    98064    6% /boot/efi none                   1024560         0  1024560    0% /dev/shm /dev/sdb1             35001508     32828 33190688    1% /backup [root@localhost root]# 

mount -a reads /etc/fstab and mounts all unmounted file systems listed in the file. df asks the system to report on all the free disk on the system. It reports that /dev/sbd1 is mounted on /backup, and that it is only 1% full.

The mount command has been used a lot in this chapter and hasn't really been covered yet. That's because most of the work you do with mount is basic. Still, there are a lot of options to the command that you can see on the man page. However, the basic form of the mount command is as follows:

 mount   [options]   device   dir 

You've already used some of the mount options in the examples. The following lists of some of the more commonly used options:

-a

Mounts all filesystems in /etc/fstab. This was used in the earlier example.

-t fstype

Specifies the type of file system being mounted, but mount usually senses this on its own, so you don't normally need this option.

-o options

When using -o, you can specify many options, such as ro for read only, rw for read write, noauto for disabling automatic mount when -a is specified.


Now that you can mount a file system, you should know how to unmount it. Linux uses the umount (note that its umount, not unmount) command to unmount a file system:

 umount [-f] directory 

Provided that the file system is not in use, it will be unmounted immediately. Being in use includes simply being in the directory or a process of having a file open that resides on the mounted file system. Consequently, you may have to change directories if you are in a directory on the file system to be unmounted, or you may have to use kill to stop the process attached to the file system. Similarly, if you have a file open on the file system you want to unmount, you'll have to close it. You may have to use umount -f to force the filesystem to be unmounted, or go into what Linux calls "single user mode."

     < Day Day Up > 


    Linux on HP Integrity Servers. A System Administrator's Guide
    Linux on HP Integrity Servers: A System Administrators Guide
    ISBN: 0131400002
    EAN: 2147483647
    Year: 2004
    Pages: 100

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