Sunday, December 13, 2009

Editing Mount Points

fstab
/etc/fstab contains a listing of all of the potential mounted drives on the system both local and remote. The file /etc/rc.sysinit reads the /etc/fstab to mount the drives on startup.

This text file is the file you edit if you wanted to mount a partition permanently once the system boots.  One point to note, this file lists potential partitions that can be mounted, it does not however guarantee that they are actually mounted.

If you wanted to see the mounted partitions you could either use the df command or you can view /etc/mstab, see below.

Need more information about Linux Administration, check out the CentOS Server Course or the Ubuntu Server Course.

# This file is edited by fstab-sync – see ‘man fstab-sync’ for details
LABEL=/1                /                       ext3    defaults        1 1
LABEL=/bk               /bk                     ext3    defaults        1 2
LABEL=/boot1            /boot                   ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /dev/shm                tmpfs   defaults        0 0
LABEL=/home             /home                   ext3    defaults        1 2
LABEL=/opt              /opt                    ext3    defaults        1 2
none                    /proc                   proc    defaults        0 0
none                    /sys                    sysfs   defaults        0 0
LABEL=/tmp              /tmp                    ext3    defaults        1 2
LABEL=/usr              /usr                    ext3    defaults        1 2
LABEL=/var1             /var                    ext3    defaults        1 2
LABEL=SWAP-sda3         swap                    swap    defaults        0 0
LABEL=SWAP-sdc2         swap                    swap    defaults        0 0
/dev/hda                /media/cdrecorder       auto
pamconsole,fscontext=system_u:object_r:removable_t,exec,noauto,managed 0 0


Understanding /etc/fstab
The file /etc/fstab is divided into label, mount point, file system, options, dump order and fsck order.


Label
The local devices are labeled by e2label so that each local mount point will have a Label. The example below shows the label as LABEL=/home.


LABEL=/home             /home                   ext3    defaults        1 2


Mounts that are not local will not be labeled in this way.


Mount Point
The Mount Point is where a directory is mounted in the file system structure. In the example /home is the mount point.


LABEL=/home             /home                   ext3    defaults        1 2


File System
The file system is the formatted file system on the drive. In the example the file system is ext3 which has the journaling included. LABEL=/home /home ext3 defaults 1 2


Options
There are a number of Options that are available when mounting a drive.


Mount Option         Description
async             read and write data asynchronously
atime             update inodes when file is accessed
auto             normal formats for floppy or removable drive
defaults        rw,suid,dev,exec,auto,nouser,async
dev             allows accesses to devices (consoles or drives)
exec            permit binaries to execute
noatime            inode is not updated when accessed
noauto             must mount manually
nodev             devices not read
noexec            binaries cannot be run
nosuid             disallows setuid and segid
nouser             only root can mount filesystem
remount            filesystem can be remunted
ro             read only
rw             read and write
suid            allows setuid and setgid
sync            read and write done at same time
user             allows noroot users to mount filesystem


Dump Order
The Dump Order is important for backups. Place a 1 for local devices so dump can backup. The example shows a 1.


LABEL=/home             /home                   ext3    defaults        1 2


fsck Order
This allows you to set priorities for which device gets checked by fsck first in case of a system crash. Usually a 0 is placed for devices that do not need to be checked like swap and a 1 is placed for the / directory to be checked first and a 2 on all other devices. The example is a 2.


LABEL=/home             /home                   ext3    defaults        1 2


Add an Additional Device
You cannot use a Label unless it has been explicitly created so you will need to use the block device as in the example.

Typically a drive that is local and not removable will be 1 and 2 while a removable device like a ZIP drive will be 0 and 0.


/dev/hdc1     /bac    ext3     defaults    1 2


Add this line for the device and mount point that you created and save. When you restart each time it will be available.


# cat /etc/fstab


LABEL=/                 /                       ext3    defaults        1 1
LABEL=/var              /var                    ext3    defaults        1 2
LABEL=/home             /home                   ext3    usrquota        1 2
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
LABEL=SWAP-hda3         swap                    swap    defaults        0 0

The /etc/mtab is used to list actual mounts that exist.  This is the difference with /etc/fstab which lists potential mount points.


# cat /etc/mtab


/dev/hda2 / ext3 rw 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw 0 0
devpts /dev/pts devpts rw,gid=5,mode=620 0 0
/dev/hda6 /var ext3 rw 0 0
/dev/hda5 /home ext3 rw,usrquota 0 0
/dev/hda1 /boot ext3 rw 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0

When you look at the /proc directory mounts you will see that there are two mounts referring to the / directory which is used by initrd scripts to mount the filesystem.


# cat /proc/mounts


rootfs / rootfs rw 0 0
/dev/root / ext3 rw,data=ordered 0 0
/dev /dev tmpfs rw 0 0
/proc /proc proc rw 0 0
/sys /sys sysfs rw 0 0
none /selinux selinuxfs rw 0 0
/proc/bus/usb /proc/bus/usb usbfs rw 0 0
devpts /dev/pts devpts rw 0 0
/dev/hda6 /var ext3 rw,data=ordered 0 0
/dev/hda5 /home ext3 rw,data=ordered,usrquota 0 0
/dev/hda1 /boot ext3 rw,data=ordered 0 0
tmpfs /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
/etc/auto.misc /misc autofs rw,fd=6,pgrp=1949,timeout=300,minproto=5,maxproto=5,indirect 0 0
-hosts /net autofs rw,fd=12,pgrp=1949,timeout=300,minproto=5,maxproto=5,indirect 0 0

No comments:

Post a Comment