Softpanorama

May the source be with you, but remember the KISS principle ;-)
Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

/etc/fstab

News Mounting Linux filesystems Recommended Links Ext2-Ext3-Ext4 Attributes Filesystem mount options
Troubleshooting Errors in /etc/fstab Linux Logical Volume Snapshots tmpfs Humor Etc

fstab  is a configuration file that contains information of all the partitions and storage devices in your computer. The file is located under /etc, so the full path to this file is /etc/fstab.

Here's an example of the contents of /etc/fstab  on Suse 10 SP3

root@usrklxbck01:~ # cat /etc/fstab
/dev/disk/by-id/cciss-3600508b1001037383941424344450400-part3 /                    reiserfs   acl,user_xattr        1 1
/dev/disk/by-id/cciss-3600508b1001037383941424344450400-part1 /boot                ext3       acl,user_xattr        1 2
/dev/disk/by-id/cciss-3600508b1001037383941424344450400-part6 /home                ext3       acl,user_xattr        1 2
/dev/disk/by-id/cciss-3600508b1001037383941424344450400-part7 /tmp                 ext3       acl,user_xattr        1 2
/dev/disk/by-id/cciss-3600508b1001037383941424344450400-part5 /var                 ext3       acl,user_xattr        1 2
/dev/disk/by-id/cciss-3600508b1001037383941424344450400-part2 swap                 swap       defaults              0 0
usandd660a-dd:/backup  /backup                  nfs     rw,hard,intr,nfsvers=3,tcp,rsize=32768,wsize=32768,bg   0 0
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
usbfs                /proc/bus/usb        usbfs      noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       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.
  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 2, or 0 to disable checking.

A value of zero in either of the last 2 columns disables the corresponding feature.

If I type the following command:

mount /dev/sr0
then Cd will be  mounted in /media/cdrom, If I type mount /backup them NFS filesystem will be mounted because that's the mount point specified for it in /etc/fstab

All partitions and devices in fstab are automatically mounted when your Linux system boots up unless noauto is specified.

The third column in /etc/fstab  specifies the filesystem type of the device or partition. Many different filesystems are supported but we'll take a look at the most common ones only.

The fourth column in fstab  lists all the mount options for the device or partition. This is also the most confusing column in the fstab  file, but knowing what some of the most common options mean, saves you from a big headache. For more information, check out the man page of mount.

5th and 6th columns: Dump and fsck options

 Example /etc/fstab entries

As an example, we'll take a look at a couple of fstab  entries that have been a source of endless frustration for new Linux users: floppy and CD-ROM (although these days floppies aren't that important anymore).

/dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0

This line means that the floppy is mounted to /media/floppy  by default and that its filesystem type is detected automatically. This is useful because the type of the floppy may wary. Note especially the rw and user options: they must be there if you want to be able to mount and write to the floppy as a normal user. If you have trouble with this, check your fstab  file to see if these options are there. Also note the sync option. It can be async just as well, but it's sync because of reasons discussed a bit earlier.

/dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0

Note, again, the user option that enables you to mount the CD as a normal user. The CD-ROM has the ro option because it's no use mounting a CD-ROM read-write because you wouldn't be able to write to it anyway. Also note the exec option. It's especially useful if you'd like to be able to execute something from your CD.

Also note that the noauto option is used with the floppy and CD-ROM. This means that they won't be automatically mounted when your Linux system boots up. This is useful for removable media, because sometimes there won't be any floppy or CD-ROM when you boot up your system, so there isn't any reason to try to mount something that doesn't even exist.


Top Visited
Switchboard
Latest
Past week
Past month

NEWS CONTENTS

Old News ;-)

[Aug 10, 2011] fstab - ArchWiki

atime options

The use of noatime, nodiratime or relatime can help disk performance for ext2, ext3, and ext4 filesystems. Linux by default keeps a record (writes to the disk) every times it reads from the disk atime. This was more purposeful when Linux was being used for servers; it doesn't have much value for desktop use. The worst thing about the default atime option is that even reading a file from the page cache (reading from memory instead of the disk) will still result in a disk write! Using the noatime option fully disables writing file access times to the disk every time you read a file. This works well for almost all applications, except for a rare few like Mutt that need the such information. For mutt, you should only use the relatime option. Using the relatime option enables the writing of file access times only when the file is being modified (unlike noatime where the file access time will never be changed and will be older than the modification time). The nodiratime option disables the writing of file access times only for directories while other files still get access times written. The best compromise might be the use of relatime in which case programs like Mutt will continue to work, but you'll still have a performance boost because files will not get access times updated unless they are modified.

Note: noatime already includes nodiratime. You don't need to specify both options.

tmpfs

tmpfs is a temporary filesystem that resides in memory and/or your swap partition(s), depending on how much you fill it up. Mounting directories as tmpfs can be an effective way of speeding up accesses to their files, or to ensure that their contents are automatically cleared upon reboot.

Some directories where tmpfs is commonly used are /tmp, /var/lock and /var/run. Do NOT use it on /var/tmp, because that folder is meant for temporary files that are preserved across reboots.

By default, a tmpfs partition has its maximum size set to half your total RAM, but this can be customized. Note that the actual memory/swap consumption depends on how much you fill it up, as tmpfs partitions don't consume any memory until it is actually needed.

To use tmpfs for /tmp, add this line to /etc/fstab:

File: /etc/fstab
.....
tmpfs /tmp      tmpfs nodev,nosuid,noexec                 0 0
.....

You may or may not want to specify the size here, but you should leave the mode option alone in these cases to ensure that they have the correct permissions (1777). In the example above, /tmp will be set to use up to half of your total RAM. To explicitly set a maximum size, use the size mount option:

File: /etc/fstab
.....
tmpfs /tmp      tmpfs nodev,nosuid,noexec,size=2G          0 0
.....

See the mount command man page for more information.

Reboot for the changes to take effect. Note that although it may be tempting to simply run mount -a to make the changes effective immediately, this will make any files currently residing in these directories inaccessible (this is especially problematic for running programs with lockfiles, for example). However, if all of them are empty, it should be safe to run mount -a instead of rebooting (or mount them individually).

After applying changes, you may want to verify that they took effect with findmnt:

$ findmnt --target /tmp
TARGET SOURCE FSTYPE OPTIONS
/tmp   tmpfs  tmpfs  rw,nosuid,nodev,noexec,relatime

To use tmpfs for /var/lock and /var/run, you can simply symlink them to /run. Make sure to close anything important before doing this, because you will have to reboot, and daemons may not stop cleanly.

# ln -sf /run/lock /var/lock # ln -sf /run /var/run # reboot

Note: Arch will likely do this by default in the future. See https://bugs.archlinux

[Apr 22, 2010] Controlling Your Linux System With fstab - Understanding fstab by Akkana Peck

April 21, 2010 | LinuxPlanet

The /etc/fstab file gives you control over what filesystems are mounted at startup on your Linux system, including Windows partitions and network shares. You can also use it to control the mount points of removable storage devices like USB sticks and external hard disks. Akkana Peck shows us how.

/etc/fstab -- it's there on every Linux computer, controlling which filesystems get mounted where.

Its manual page, man fstab, begins with this snippet:

fstab is only read by programs, and not written; it is the duty of the system administrator to properly create and maintain this file.

Fortunately, they're fibbing. These days fstab is usually created for you by an installer or other program. So don't get too worried about your "duty".

However, if you want to delve into fstab, it's easy to understand and modify.

A typical fstab

The fstab file installed by most modern Linux distros looks a bit intimidating. Here's one from an Ubuntu system:

# /etc/fstab: static filesystem information.
#
# Use 'blkid -o value -s UUID' to print the universally unique identifier
# for a device; this may be used with UUID= as a more robust way to name
# devices that works even if disks are added and removed. See fstab(5).
#
#                
proc            /proc           proc    defaults        0       0
# / was on /dev/sda6 during installation
UUID=2ad9188b-9d1c-4102-bf24-4b5ad456a701 /               ext3    errors=remount-ro 0       1
# /boot was on /dev/sda1 during installation
UUID=3943c247-16e9-405b-9fda-87684b02cc4e /boot           ext2    defaults        0       2
# swap was on /dev/sda7 during installation
UUID=15825096-aef7-41d6-b53a-c86aec2ebde8 none            swap    sw              0       0
/dev/scd0       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0

Bummer about none of those columns being lined up! Figure 1 shows the meanings of the columns.

Devices and UUIDs

Let's start with the device: UUID=2ad9188b-9d1c-4102-bf24-4b5ad456a701. What does that mean?

In the old days, the device field of fstab was much simpler, typically something like /dev/hda3 for the third partition on the first IDE disk.

But systems got more complicated. USB and SATA disks both use the sd disk driver, originally written for SCSI. But you can't always predict their order. If you have several SATA and USB disks, or if you frequently add and remove drives, you might find that your root filesystem appears on sda2 one day and sdc2 the next.

To get around this confusion, fstab can use a "Universally Unique IDentifier" that identifies each filesystem.

How do you find out which disk partition maps to which UUID? You might have noticed some comments in fstab:

# / was on /dev/sda6 during installation
UUID=2ad9188b-9d1c-4102-bf24-4b5ad456a701 /               ext3    errors=remount-ro 0       1

Don't trust those comments. Your / may have been on sda6 once, but that doesn't mean it's there now.

It's safer to check the current value with the blkid command:

$ blkid
/dev/sda1: UUID="702be669-1Aee-4128-8c57-60b58bc91f59" TYPE="ext2" 
/dev/sda3: UUID="615aaed5-0dba-4204-9717-c9a00ff411ea" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda5: UUID="0c5121ff-331a-4ae2-b8be-e0b10bcae62f" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda6: UUID="d2a1e4aa-6589-4846-ba58-107d32a25375" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda7: UUID="1533cdc3-635f-4552-818b-1fadce9ea7f8" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda8: UUID="b24fd645-7c28-431b-883d-0a6cf03340ed" SEC_TYPE="ext2" TYPE="ext3" 
/dev/sda9: TYPE="swap"

$ blkid -o value -s UUID /dev/sda8
b24fd645-7c28-431b-883d-0a6cf03340ed

You can also use /dev/disk/by-uuid:

$ ls -l /dev/disk/by-uuid
lrwxrwxrwx 1 root root 10 2010-04-18 09:06 0c5121ff-331a-4ae2-b8be-e0b10bcae62f -> ../../sda5
lrwxrwxrwx 1 root root 10 2010-04-18 09:06 615aaed5-0dba-4204-9717-c9a00ff411ea -> ../../sda3
lrwxrwxrwx 1 root root 10 2010-04-18 09:06 1533cdc3-635f-4552-818b-1fadce9ea7f8 -> ../../sda7
lrwxrwxrwx 1 root root 10 2010-04-18 09:06 b24fd645-7c28-431b-883d-0a6cf03340ed -> ../../sda8
lrwxrwxrwx 1 root root 10 2010-04-18 09:06 ca8ec122-33c7-4765-bd65-78a15c58def3 -> ../../sda2
lrwxrwxrwx 1 root root 10 2010-04-18 09:06 d2a1e4aa-6589-4846-ba58-107d32a25375 -> ../../sda6
lrwxrwxrwx 1 root root 10 2010-04-18 09:06 702be669-1Aee-4128-8c57-60b58bc91f59 -> ../../sda1

Some distros, instead of using UUIDs, attach a label to each filesystem:

LABEL=/         /       ext3         defaults           1    1

This is much easier to read, but can get confusing. If you install several Linux releases on different partitions, you could end up with several partitions that have the same label. Then how do you tell which one gets mounted?

Confused by all these UUIDs and labels? You don't have to use them. If you have a simple setup with just one disk, the simple syntax still works:

/dev/sda6     /       ext3    errors=remount-ro      0       1
The next two fields are straightforward. The mount point is wherever you want to mount that filesystem: /, /home, /boot or wherever. It should be an empty directory that already exists. If it's not empty, whatever is inside will be hidden when you mount something on top of it.

The type is the filesystem type, like ext2, ext3, Windows filesystems vfat and ntfs, or iso9660 for CDs. You can also use auto, and Linux will try to guess the filesystem type. man filesystems has a list of supported filesystems.

Options

The options field is the most complex. This is where you specify "everything else" -- anything that doesn't fit in the other fields. If you don't have any specific options, just use defaults.

You can list as many options as you want, separated by commas. For instance, a CDROM might use ro,user,noauto,exec, starting with ro for read-only.

user means it doesn't need root privileges to mount it: any user can type mount /media/cdrom0, if you don't have a service already mounting it for you.

noauto means the system won't try to mount it when the system boots -- a good idea for removable devices. It doesn't say anything about whether a process like hal may try to automount it later if you insert a CD -- that's controlled elsewhere.

exec tells the system to let you run programs from that file system. That's otherwise disabled on CDROMs and Windows filesystems.

On Windows FAT filesystems, if you use exec you may also want fmask=111: Windows filesystems don't have permissions, so you need to make sure the execute bit is set if you want to run programs.

Put these all together, and you can make an entry that's useful on systems that don't automatically mount USB devices:

/dev/sdb1       /stuff        vfat      user,noauto,exec,fmask=111 0 0

If your device shows up somewhere besides /dev/sdb1, adjust as needed. Then sudo mkdir /stuff, and whenever you plug in your camera, mp3 player or USB stick you'll be able to mount it by typing mount /stuff.

For a full list of options, see man mount and scroll down to FILESYSTEM INDEPENDENT MOUNT OPTIONS and FILESYSTEM SPECIFIC MOUNT OPTIONS.

dump and pass

Dump specifies how often you want the filesystem backed up. Most people don't use this field, but if you're running automated backup software you might want it

Pass indicates when and whether the device should be checked with fsck before being mounted. Generally you should use 1 for the root filesystem, 2 for all your other normally mounted filesystems, and 0 for filesystems that aren't mounted by default.

Akkana Peck is a freelance programmer and writer and author of the book Beginning GIMP: From Novice to Professional. She also spends way too much time fiddling with reconfiguring her Linux distros.

Recommended Links

fstab - Wikipedia, the free encyclopedia

How to edit and understand -etc-fstab

fstab(5) static info about filesystems - Linux man page

Fstab - Community Ubuntu Documentation

fstab - ArchWiki



Etc

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes.   If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner. 

ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.  

Society

Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy

Quotes

War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes

Bulletin:

Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law

History:

Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Haterís Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least


Copyright © 1996-2016 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case softpanorama.org is down you can use the at softpanorama.info

Disclaimer:

The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: May 10, 2015