LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Linux Answers > Hardware
User Name
Password

Notices

By tylerburns at 2006-03-24 22:59
The /etc/fstab file is used by some programs to determine file system types and mount points. If you are new to linux, configuration files can seem cryptic and intimidating. This tutorial contains an example /etc/fstab file broken down and thoroughly explained. Keep in mind that the sample that is broken down and explained is larger than your typical /etc/fstab so that this tutorial can be applicable to a wider audience. I also included the /etc/fstab from my personal computer.

EXAMPLE:

1 #device mount point file system options dump check
2
3 /dev/hda1 / reiserfs defaults 0 1
4 /dev/hdb1 /home ext2 auto,notail 1 1
5 /dev/hdc /mnt/cdrom iso9660 defaults 0 0
6 /dev/hdd /mnt/dvdrw iso9660 ro,users,noauto 0 0
7 /dev/sda1 /usr reiserfs ro, owner 0 1
8 /dev/fd0 /mnt/floppy auto user 0 0
9 /dev/hda5 swap swap defaults 0 0
10 host:/var /root/var nfs uid=0,gid=0 1 0
11 proc /proc proc proc defaults 0 0

The numbers at the beginning of each line of the example file are for reference use of this tutorial. If line numbers were added to an actual configuration files the result would be not being able to boot after the next shutdown and the common “mount: can't find /dev/hde in /etc/fstab or /etc/mtab” error message when you try to mount a file system.

The first line of the example file is a comment, which is ignored by the process reading the file. Commenting lines out in linux configuration files is done by using the # character. Comments are very useful for people reading or editing the file. In fact, this whole tutorial could be contained inside a working, fully functional, /etc/fstab file if the lines containing text explaining things were commented out with #. The # character is universally used in linux configuration files to identify comments. Many distributions include a commented line at the beginning of the file to show what each column defines.

As you have more than likely noticed, the /etc/fstab file is divided into columns. The first column defines the device file pointing to the device with the file system to be mounted. The second column is the mount point, or the directory where the file system can be accessed. Column number three defines the file system type used on file system being mounted. An important thing to remember about file system types is that in order for you to be able to mount and use a volume, you must have support for the file system type compiled into the kernel itself or have a kernel module for it. Kernel issues are beyond the scope of this tutorial. The fourth column is used for mount options. Some mount options are file system specific. A chart has been included to explain common mounting options. The fifth column is the dump column. It is used by the dump utility to determine whether or not it should back up the file system being defined. A 0 means it won't be backed up, and a 1 tells dump to back it up. This document will not go into the details of the dump utility. The sixth column is the order fsck checks a file system when the system is booted. A 0 in this column indicates fsck will never check a file system. This value should be used for removable media such as CD and floppy drives. Any value greater than one tells fsck to check the file system at boot. The order they are checked is the numerical order of values assigned in this column.

The second line serves no purpose other than making it easier to read by someone editing the file.

Line number three in this example is technically the only line you absolutely must have, although you should never configure your system this way if you want it to be stable. You should also define a swap partition, which will be explained later. The reason this line is necessary is because it defines the root directory to be mounted when the system boots. Since other file systems are mounted in locations within the root directory, logically you won't be able to mount any file systems without a root directory defined. Mounting another file system before mounting the file system designated to have the root partition is like giving driving directions to use a road that hasn't been built yet.

Line number four defines a separate partition to be used as users home directories. It is often wise to use a separate partition for home directories. It preserves user preferences and files in the case of a new installation or re-installation.

Line number five defines an IDE CDROM drive, and line six defines another optical drive. Typical mount options for optical drives are user, users, noauto, ro, auto, and defaults. Defaults shouldn't be used on workstations or personal computer systems because only root will be able to mount a file system on a CD or DVD.

Line seven is an example of defining a SCSI partition.

Line eight defines a floppy drive. As you probably notice the file system type is auto. This means the system will attempt to automatically detect the file system type the defined device uses.

The ninth of the example file defines a swap partition. While not mandatory, it is highly recommended to define a swap partition in /etc/fstab. You should ALWAYS define a swap partition. Swap partitions are nothing more than dedicated partitions used for virtual memory. It is also possible to use a file dedicated to virtual memory but it is beyond this tutorial. Virtual memory is used when the kernel or applications use up all of your systems RAM or move data there to clear space in the immensely faster system RAM for other data.

The second to last line of the example file shows an NFS mount. As you probably noticed a device file isn't specified. In the column where the device file is normally defined, the NFS server hostname and export directory are specified. The uid=0, and gid=0 tells the computer to make the group and user with the specified ids. In this example both the group and user id are 0, which is the user root and group root. Mounting file systems with specific user and group ids can be a useful security or accessibility tool.

Last but not least, is the proc file system. The proc file system is a virtual file system used by the kernel to store hardware information. Some processes use it to retrieve information about hardware. If left undefined the system will use space on whatever device is mounted as the root partition.

If this tutorial doesn't cover what you are looking for doesn't include what you are looking for, I am going to point you in the right direction on finding help. For file system specific mount options try looking through the mount man and info pages. To access them type man mount or info mount at any shell prompt. Another good source is the Internet. Try searching for a web page using your favorite search engine. Forums such as the one at linuxquestions.org are great places to seek help. Your local bookstore might have some good linux books.

QUICK REFERENCES

column breakdown:

column description

1 device file
2 mount point
3 file system type
4 mount option
5 fsck order
6 dump (1= backup, 0=don't backup)

common mount options:

option definition

auto automatically mounts at boot
noauto doesn't automatically mount at boot
owner only root or the owner of the device file can mount this file system
user allows any user to mount a file system, only root or the user who mounted
the file system can unmount it
users same as user except any user can unmount it
ro mounts the file system as read only
defaults mounts the file system with the default options
uid=x mounts the file system as user with id x (ownership)
gid=x mounts the file system as group with id x (ownership)
noexec prevents the execution of files on specified device

the /etc/fstab from my personal computer:

# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaultes 0 0
/dev/hda8 / reiserfs notail 0 1
/dev/hda7 none swap sw 0 0
/dev/hdc /media/combo iso9660 defaults 0 0
/dev/hdd /media/cdrw iso9660 ro,user,noauto 0 0
/dev/fd0 /media/floppy auto rw,user,noauto 0 0
/dev/hda1 /media/windows ntfs user,ro,auto 0 0
/dev/hda6 /media/media ntfs user,ro,auto 0 0
/dev/hda5 /media/games ntfs user,ro,auto 0 0
/dev/hdb1 /media/storage ntfs user,ro,auto 0 0

Any feedback regarding this document would be appreciated as I plan to write more articles breaking down common configuration files.

The following copyright notice is to keep this document free as in freedom, and price. It is also added to give credit where credit is due.

COPYRIGHT MARCH 2006 by Tyler M. Burns. This document may be distributed electronically. This document may be used as a technical reference for writing other documents. Printing is authorized as long as it isn't published. This documents defines publishing as distribution of this document in exchange for money or goods. This includes but is not limited to books, magazines, and newspapers. Publishing is prohibited unless hard copy, written permission is given by the author to the person or organization wanting to publish this tutorial. Modifications are allowed as long as they are released with this copyright, which must remain unmodified. Modifications require the name and email address of the author of the original document and author(s) of modified version(s) if the modification is made to an already modified version of this document. Modified versions must note the modifications made. Publishing of modified versions require the written permission of both the original author and the author of the modification. Modifications must contain at minimum the email addresses of the author of the original documents and author(s) of modifications in the contact information section below. Failure to provide contact information for modifications will forfeit all rights to the author of the original document. In the event the author and if applicable author(s) of modification(s) do not respond to a request to publish this document, this document may not be published. Appropriate legal actions will be taken for any violation of this copyright.

Author:

Name Tyler M. Burns
Email tyler.m.burns@gmail.com

by michaelk on Wed, 2006-04-05 22:14
A good start.

Quote:
column description
.
.
5 fsck order
6 dump (1= backup, 0=don't backup)
You reversed fsck and dump columns.

Your option chart mentions defaults but what does defaults really mean?
No mention of umask option. How to write to a vfat partition is one of the most asked questions on the site.
No mention of samba mount points.

Quote:
While not mandatory, it is highly recommended to define a swap partition in /etc/fstab. You should ALWAYS define a swap partition.
Your statements will be somewhat confusing to the newbie. Using swap and its size would be beyond the scope of your document. However, it depends on the amount of RAM and what applications are being used on the PC.

USB, Firewire, SATA and SCSI devices use /dev/sda type device ID.

by michaelk on Thu, 2006-04-06 06:13
In addition you might want to mention that fstab file is slightly different between the different distributions.

by markmlinux on Mon, 2007-07-09 19:06
Since /sys is so important now what about the fstab entries for that as well?

Also mention of the tmpfs as applied to /tmp - would be helpful to all.

by kamikaze_al on Wed, 2008-04-30 02:10
Hi , As i can understand, the etc/fstab file is the blueprint for the basic components in the pc,?? right, well, i tried to check it out using MC and the terminal but to no avail, it just shows the HDD I've installed SuSE 10 on, the root the swap and the etc etc partitions..... but the other three stata 500gb disks are missing, there is no mention of them anywhere??
If i do have to manipulate the disks thru this file , how do i name them so that the 10th chameleon recognizes them? and how do I add it there if it ain't detected?
Since there is a detection problem, I can't mount them (Obviously) and cos of that I can't make use of em at all....
A hint would be of gr8 Help
Thanx

by michaelk on Wed, 2008-04-30 07:59
Kamikaze al, Welcome to LinuxQuestions.

It would be better to create a new thread for your questions instead of replying to one that is almost a year old. fstab is a static file that describes filesystems. It is not a blueprint of the components in your PC and may not contain an entry for every hard drive or partition connected to your computer. Some linux distributions will add an entry for all filesystems found and some do not. I believe that SuSE does not. You will need to manually add an entry for the partitions on the other disk drives. Use any text editor but you must be root to edit files in the /etc directory. It is still possible for root to mount any filesystem on any drive even though there might not be an entry in fstab.

What do you mean by 10th chameleon?

Are the other SATA drives partitioned and formatted? Are you using them for a RAID?

by jay73 on Wed, 2008-04-30 08:04
Quote:
What do you mean by 10th chameleon?
What is the Suse logo?

by michaelk on Wed, 2008-04-30 08:09
Quote:
Originally Posted by jay73 View Post
What is the Suse logo?
I did not get much sleep last night and I have not had my coffee yet

by kamikaze_al on Fri, 2008-05-02 00:06
Quote:
Originally Posted by jay73 View Post
What is the Suse logo?
http://bp1.blogger.com/_tM-TaPrUAaM/.../suse-logo.jpg
Is the suse logo
Of Now a part of the Novell Group and so the changes are pretty evident

by kamikaze_al on Fri, 2008-05-02 00:16
What do you mean by 10th chameleon?

Well??? The 10th Chameleon....... is the SuSE 10.1 Obviously...

Are the other SATA drives partitioned and formatted? Are you using them for a RAID?[/QUOTE]

The other drives are all SATA, formatted and being used to store data in a VISTA Environment. Work fine in the Win-Lows environment(Which is absolutely of no use to me) But they are Single Partion Drives with a lotta data that I can't get onto my SuSE Environment.
No, I'm not using them in a RAID Array

by michaelk on Fri, 2008-05-02 01:36
To read/write to a NTFS file system you need to install ntfs-3g. Install the driver and add an entry to the fstab file like:

/dev/sds1 /mnt/windows ntfs-3g users 0 0

The output of the following comand will display the partition information for all of the drives in your computer.
fdisk -l (that is a small L and you must be root)


  



All times are GMT -5. The time now is 08:53 PM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration