Jump to content

Fstab: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
Sikku (talk | contribs)
Line 59: Line 59:
The options common to all filesystems are:
The options common to all filesystems are:


; <code>atime / noatime / relatime (Linux-specific)</code>
; <code>atime / noatime / relatime / strictatime (Linux-specific)</code>
:The Unix [[stat (Unix)|stat]] structure records when files are last accessed (atime), modified (mtime), and created (ctime). One result is that [[atime (Unix)|atime]] is written every time a file is ''read,'' which has been heavily criticized for causing performance degradation and increased wear. However, atime is used by some applications and desired by some users, and thus is configurable as atime (update on access), noatime (do not update), or (in Linux) relatime (update atime if older than mtime). Through Linux 2.6.29, atime was the default; as of 2.6.30 (9 June 2009), relatime is the default.<ref>[http://kernelnewbies.org/Linux_2_6_30 Linux 2 6 30] at Linux Kernel Newbies</ref>
:The Unix [[stat (Unix)|stat]] structure records when files are last accessed (atime), modified (mtime), and created (ctime). One result is that [[atime (Unix)|atime]] is written every time a file is ''read,'' which has been heavily criticized for causing performance degradation and increased wear. However, atime is used by some applications and desired by some users, and thus is configurable as atime (update on access), noatime (do not update), or (in Linux) relatime (update atime if older than mtime). Through Linux 2.6.29, atime was the default; as of 2.6.30 (9 June 2009), relatime is the default.<ref>[http://kernelnewbies.org/Linux_2_6_30 Linux 2 6 30] at Linux Kernel Newbies</ref>
; <code>auto / noauto</code>
; <code>auto / noauto</code>

Revision as of 03:50, 3 December 2010

The fstab (/etc/fstab) (or file systems table) file is a system configuration file commonly found on Unix systems. The fstab file typically lists all available disks and disk partitions, and indicates how they are to be initialized or otherwise integrated into the overall system's file system. fstab is still used for basic system configuration, notably of a system's main hard drive and startup file system, but for other uses has been superseded in recent years by automatic mounting.

The fstab file is most commonly used by the mount command, which reads the fstab file to determine which options should be used when mounting the specified device. It is the duty of the system administrator to properly create and maintain this file.

The file may have other names on a given Unix variant; for example, it is /etc/vfstab on Solaris.

Modern use

Traditionally, the fstab was only read by programs, and not automatically written (it is instead manually written by the sysadmin). However, some administration tools can automatically build and edit fstab, or act as graphical editors for it, such as the Kfstab graphical configuration utility available for KDE.

Modern systems use udev as an automounter to handle hot swapping devices instead of rewriting fstab file on the fly, and thus fstab is less important than in the past. Programs such as pmount allow users to mount and unmount filesystems without a corresponding fstab entry.

Example

The following is an example of an fstab file on a typical Linux system:

# device name   mount point     fs-type      options                 dump-freq pass-num
LABEL=/         /               ext3         defaults                1 1
/dev/hda6       swap            swap         defaults                0 0
none            /dev/pts        devpts       gid=5,mode=620          0 0
none            /proc           proc         defaults                0 0
none            /dev/shm        tmpfs        defaults                0 0

# Removable media
/dev/cdrom      /mount/cdrom    udf,iso9660  noauto,owner,kudzu,ro   0 0
/dev/fd0        /mount/floppy   auto         noauto,owner,kudzu      0 0

# NTFS Windows XP partition
/dev/hda1       /mnt/WinXP      ntfs-3g      quiet,defaults,locale=en_US.utf8,umask=0	0 0

# Partition shared by Windows and Linux
/dev/hda7       /mnt/shared     vfat         umask=000              0 0

# mounting tmpfs
tmpfs           /mnt/tmpfschk   tmpfs        size=100m              0 0

# mounting cifs
//pingu/ashare  /store/pingu    cifs         credentials=/root/smbpass.txt 0 0

#mounting NFS
pingu:/store    /store          nfs          rw                     0 0

The columns are as follows:

  1. The device name or other means of locating the partition or data source.
  2. The mount point, where the data is to be attached to the filesystem.
  3. The filesystem type, or the algorithm used to interpret the filesystem.
  4. Options, including if the filesystem should be mounted at boot. (kudzu is an option specific to Red Hat and Fedora Core.)
  5. dump-freq adjusts the archiving schedule for the partition (used by dump).
  6. pass-num Controls the order in which fsck checks the device/partition for errors at boot time. The root device should be 1. Other partitions should be either 2 (to check after root) or 0 (to disable checking for that partition altogether).

A value of zero in either of the last 2 columns disables the corresponding feature. For the whitespace character in paths the character code "\040" is used.

Options common to all filesystems

As the filesystems in /etc/fstab will eventually be mounted using mount(8) it isn't surprising that the options field simply contains a comma-separated list of options which will be passed directly to mount when it tries to mount the filesystem.

The options common to all filesystems are:

atime / noatime / relatime / strictatime (Linux-specific)
The Unix stat structure records when files are last accessed (atime), modified (mtime), and created (ctime). One result is that atime is written every time a file is read, which has been heavily criticized for causing performance degradation and increased wear. However, atime is used by some applications and desired by some users, and thus is configurable as atime (update on access), noatime (do not update), or (in Linux) relatime (update atime if older than mtime). Through Linux 2.6.29, atime was the default; as of 2.6.30 (9 June 2009), relatime is the default.[1]
auto / noauto
With the auto option, the device will be mounted automatically at bootup or when the mount -a command is issued. auto is the default option. If you don't want the device to be mounted automatically, use the noauto option in /etc/fstab. With noauto, the device can be only mounted explicitly.
dev / nodev
Interpret/do not interpret block special devices on the filesystem.
exec / noexec
exec lets you execute binaries that are on that partition, whereas noexec doesn't let you do that. noexec might be useful for a partition that contains no binaries, like /var, or contains binaries you don't want to execute on your system, or that can't even be executed on your system. Last might be the case of a Windows partition.
ro
Mount read-only.
rw
Mount the filesystem read-write. Again, using this option might alleviate confusion on the part of new Linux users who are frustrated because they can't write to their floppies, Windows partitions, or other media.
sync / async
How the input and output to the filesystem should be done. sync means it's done synchronously. If you look at the example fstab, you'll notice that this is the option used with the floppy. In plain English, this means that when you, for example, copy a file to the floppy, the changes are physically written to the floppy at the same time you issue the copy command.
suid / nosuid
Permit/Block the operation of suid, and sgid bits.
user / users / nouser
user permits any user to mount the filesystem. This automatically implies noexec, nosuid, nodev unless overridden. If nouser is specified, only root can mount the filesystem. If users is specified, every user in group users will be able to unmount the volume.
owner (This is Linux-specific)
Permit the owner of device to mount.
defaults
Use default settings. Default settings are defined per file system at the file system level. For ext3 file systems these can be set with the tune2fs command. The normal default for Ext3 file systems is equivalent to rw,suid,dev,exec,auto,nouser,async(no acl support). Modern Red Hat based systems set acl support as default on the root file system but not on user created Ext3 file systems. Some file systems such as XFS enable acls by default. Default file system mount attributes can be over ridden in /etc/fstab.

Filesystem specific options

There are many options for the specific filesystems supported by mount. Listed below are some of the more commonly used. The full list may be found in the documentation for mount.

ext2

check={none, normal, strict}
Sets the fsck checking level.
debug
Print debugging info on each remount .
sb=n
n is the block which should be used as the superblock for the fs.

fat

check={r[elaxed], n[ormal], s[trict]}
Not the same as ext2, but rather deals with allowed filenames. See mount(8).
conv={b[inary], t[ext], a[uto]}
Performs DOS <---> UNIX text file conversions automatically. See mount(8).
uid=n, gid=n
Sets the user identifier, uid, and group identifier, gid, for all files on the filesystem.
umask=nnn, dmask=nnn, fmask=nnn
Sets the user file creation mode mask, umask, the same for directories only, dmask and for files only, fmask.

iso9660

norock
Disables Rock Ridge extensions.

More detailed information about the fstab file can be found in the man page about it.[1]

Mounting all filesystems

mount -a

This command will mount all (not-yet-mounted) filesystems mentioned in fstab and is used in system script startup during booting. Note that this command will ignore all those entries containing "noauto" in the options section.

See also

References

  1. ^ Linux 2 6 30 at Linux Kernel Newbies