Fstab: Difference between revisions

From Helpful
Jump to navigation Jump to search
 
Line 1: Line 1:
{{notes}}
#redirect [[Linux admin notes - disk and filesystem]]
 
<tt>fstab</tt> specifies mount points and options. 'Mounting' can be read as "pretend contents are available here, at this mount point" {{comment|(in fact masking whatever was there, but mount points are conventially empty directories)}}. This allows there to be a single directory tree in which many filesystems can be positioned.
 
 
The <tt>/etc/fstab</tt> entries imitate the options on <tt>mount</tt>. Each entry pivots around the filesystem type: a specific mounter is chosen based on it, which is a program (<tt>mount.''something''</tt>), which gets the the device, mount point and options handed to it. {{comment|(I wouldn't be surprised if there is a very simple rewrite)}}
 
<code lang="bash">
#device              mountpoint      fstype      options                      dump check
/dev/sda1            /              ext3        defaults,errors=remount-ro      0 1
none                  /dev/shm        tmpfs        defaults                        0 0
/dev/sda2            none            swap        sw                              0 0
/dev/hda              /media/cdrom0  udf,iso9660  user,noauto                    0 0
//192.168.6.7/ddrive  /mnt/music      smbfs        username=Administrator,noauto  0 0
</code>
 
As you can deduce from the notes commonly present, the columns are:
* Device: '''what''' to mount
* Mount point: '''where''' to put it
* filesystem type: '''how''' to interpret it
* options: additional arguments to the mounter. Sometimes central to functionality, sometimes tweaks.
And the two numbers:
* "dump": you can ignore this. Historically used by (tape) backup programs.
* "check": determines whether (0 means don't) and the order in which (&gt;1, increasing order) to do filesystem checks (fsck) at bootup time{{verify}}.
 
 
 
===Device===
...is sort of an outdatated name, coming from a time when the most common case was a device file for a hard or floppy drive, almost always something in <tt>/dev</tt>
 
These days it's "anything that the specified mounter understands", which is regularly still a device file in /dev, but can be many things besides. Options now include:
* device files, e.g.:
** <tt>/dev/hd[''letter'']''[number]''</tt>, for example <tt>hda1</tt> or <tt>hdc3</tt> {{comment|(letters refer to drives, numbers to partitions. hd''something'' indicates a classical parallel ATA device)}}
** <tt>/dev/sd[''letter'']''[number]''</tt>, for example <tt>sda1</tt> {{comment|(partition reference on SCSI or SATA, or PATA when accessed via <tt>libata</tt>)}}
* symlinks like like <tt>/dev/cdrom</tt> -- usually just convenience links to a device file, such as <tt>/dev/hdc</tt>.
* a special case like <tt>none</tt> (e.g. for shm, which always just takes some RAM to create a RAM drive) or <tt>proc</tt> (which is a special case)
* some sort of network reference, for example for SMB, NFS shares and such
* <tt>UUID=</tt>''[long hexadecimal string]'', compared to UUIDs in partitions. Means that partitions can be mounted in the same place even when they're not always in the same place in terms of hardware {{comment|(cables/ports/interfaces, but more importantly, robust to varying device enumeration)}} or <tt>/dev</tt>ices. Can be handy for external drives, but also for resistance to plugging extra drives in and such.
* <tt>LABEL=</tt>''[string]'', compared to labels in partitions. Similar function and upsides to UUID, but more readable names, and human-caused collision is more likely.
 
Note that the last two are not so useful when you want to refer to a physical device rather than a partition. This applies to CD/DVD drives, floppies and such.
 
 
 
See also:
* [[UUID]]
 
===Mount point===
The place in your filesystem tree that this filesystem should become visible.
 
You always have one things as the root (<tt>/</tt>) (the system wouldn't have booted if you didn't).
 
Additional mounts are placed somewhere inside that root filesystem, usually in recognizable places like /mnt/something, /media/something, sometimes /cdrom and/or /floppy, and such. You don't have to.
Sometimes it can be handy to keep the same filesystem layout by, say, mounting a new data drive where an old data directory used to be.
 
Mounting at a specific directory masks the contents of directory that is there. Mountpoint directories are usually empty for this reason.
 
 
===Filesystem type===
 
<!--
VFS has to understand this, and support for specific filesystems varies depending on the underlying kernel.
 
Filesystem may be a physical storage type, or be something that works via networking.
 
My mount man page mentions supporting adfs, affs, autofs, cifs, coda, coherent, cramfs, debugfs, devpts, efs, ext, ext2, ext3, hfs, hfsplus, hpfs, iso9660, jfs, minix, msdos, ncpfs, nfs, nfs4, ntfs, proc, qnx4, ramfs, reiserfs, romfs, smbfs, sysv, tmpfs, udf, ufs, umsdos, usbfs, vfat, xenix, xfs, xiafs.
 
 
You can use <tt>auto</tt> here to have <tt>mount</tt> guess using some heuristics. This can be handy for floppies and CDs, but note the heuristics are not strong enough for all filesystem types, so you should specify what a drive/partition is whenever you can.
 
 
Kernel drivers and [http://fuse.sourceforge.net/ FUSE] may be used to support additional filesystem types.
 
 
 
For local storage filesystems there is usually an according fsck.''type'', e.g. fsck.ext2, fsck.ext3, fsck.minix, fsck.reiserfs, fsck.vfat, etc.
 
vfat, ntfs
 
swap
-->
 
 
===mount options===
<!--
These are specific to the filesystem type.
 
defaults is usually roughly equivalent to auto,nouser,rw,async,exec,suid,dev
 
 
Common to most storage filesystems are:
* auto, noauto: whether or not to try mounting this at bootup and when you run <tt>mount -a</tt>. Default is auto, i.e. to try so. It often makes sense to use noauto for CD and floppy drives and such.
 
* nouser, user, users: controls whether to allow non-root users to mount this, and if so, which users (specific user(s), all users). Default is nouser, which means only root can mount (or users via a sudo setup). On workstations, user/users is handy on CD drives, floppies and such.
 
* ro, rw: Mount read-only or read-write. Default seems to differ per filesystem{{verify}}.
 
* sync, async: Whether to use a writeback cache{{verify}}. Async is default, and can lengthen drive lifetime (if there are a limited number of write cycles). Sync means operations are blocking and done immediately, which you may want for floppies (as operations may delay until umount if you do not).
 
* suid, nosuid: allow/disallow SUID/GUID bits to apply.
 
* exec, noexec: allow binaries to run from this partition. Since binaries can be copied, this is often not really a security solution, but it can be convenient for a few things. Default is exec.
 
 
 
 
 
-->
 
==See also==
<!--
http://www.tuxfiles.org/linuxhelp/fstab.html
http://en.wikipedia.org/wiki/Fstab
http://wiki.linuxquestions.org/wiki/Fstab
http://www.netadmintools.com/html/5fstab.man.html
http://www.macosxhints.com/article.php?story=20030227194830916
http://www.ubuntuforums.org/showthread.php?t=223182&highlight=uuid
http://csciwww.etsu.edu/nielsen/4417/grub-partitions-labels.txt
-->
 
 
 
[[Category:Unices]]
[[Category:Configuration]]

Revision as of 13:15, 18 June 2011