Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora Resources > Guides & Solutions (No Questions)
FedoraForum Search

Forgot Password? Join Us!

Guides & Solutions (No Questions) Post your guides here (No links to Blogs accepted). You can also append your comments/questions to a guide, but don't start a new thread to ask a question. Use another forum for that.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 18th August 2004, 10:18 AM
imdeemvp's Avatar
imdeemvp Offline
Registered User
 
Join Date: Feb 2004
Age: 44
Posts: 8,256
HOW TO edit /etc/fstab

Intended for our new Fedora Core users that are using linux for the first time and they want to undertand and edit the /etc/fstab


< How to edit and understand /etc/fstab - 1.0 >


There's a file called /etc/fstab in your Linux system. Learn what its contents mean and how it's used in conjunction with the mount command. When you learn to understand the fstab file, you'll be able to edit its contents yourself, too.


< What is fstab and why it's useful >

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.

/etc/fstab contains information of where your partitions and storage devices should be mounted and how. If you can't access your Windows partition from Linux, aren't able to mount your CD or write to your floppy as a normal user, or have problems with your CD-RW, you probably have a misconfigured /etc/fstab file. So, you can usually fix your mounting problems by editing your fstab file.

/etc/fstab is just a plain text file, so you can open and edit it with any text editor you're familiar with. However, note that you must have the root privileges before editing fstab. So, in order to edit the file, you must either log in as root or use the su command to become root.


< Overview of the file >

Of course everybody has a bit different /etc/fstab file because the partitions, devices and their properties are different on different systems. But the basic structure of fstab is always the same. Here's an example of the contents of /etc/fstab:
/dev/hda2 / ext2 defaults 1 1
/dev/hdb1 /home ext2 defaults 1 2
/dev/cdrom /media/cdrom auto ro,noauto,user,exec 0 0
/dev/fd0 /media/floppy auto rw,noauto,user,sync 0 0
proc /proc proc defaults 0 0
/dev/hda1 swap swap pri=42 0 0

What does all this gibberish mean? As you see, every line (or row) contains the information of one device or partition. The first column contains the device name, the second one its mount point, third its filesystem type, fourth the mount options, fifth (a number) dump options, and sixth (another number) filesystem check options. Let's take a closer look at this stuff.


< 1st and 2nd columns: Device and default mount point >

The first and second columns should be pretty straightforward. They tell the mount command exactly the same things that you tell mount when you mount stuff manually: what is the device or partition, and what is the mount point. The mount point specified for a device in /etc/fstab is its default mount point. That is the directory where the device will be mounted if you don't specify any other mount point when mounting the device.

Like you already learned from the Mounting tuXfile, most Linux distros create special directories for mount points. Most distros create them under /mnt, but some (at least SuSE) under /media. As you probably noticed when looking at the example fstab, I use SuSE's mount points as an example.

What does all this mean? If I type the following command:
$ mount /dev/fd0
... my floppy will be mounted in /media/floppy, because that's the default mount point specified in /etc/fstab. If there is no entry for /dev/fd0 in my fstab when I issue the command above, mount gets very confused because it doesn't know where to mount the floppy.

You can freely change the default mount points listed in /etc/fstab if you're not satisfied with the defaults your distro has given you. Just make sure the mount point is a directory that already exists on your system. If it doesn't, simply create it.

Some partitions and devices are also automatically mounted when your Linux system boots up. For example, have a look at the example fstab above. There are lines that look like this:

/dev/hda2 / ext2 defaults 1 1
/dev/hdb1 /home ext2 defaults 1 2

As you've learned, these lines mean that /dev/hda2 will be mounted to / and /dev/hdb1 to /home. This is done automatically when your Linux system boots up... if it wouldn't, you'd have a hard time using your cool Linux system because all the programs you use are in / and you wouldn't be able to run them if / wasn't mounted! But how does the system know where you want to mount /dev/hda2 and /dev/hdb1? By looking at the /etc/fstab file of course.



< 3rd column: Filesystem type >


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.

ext2 and ext3 Very likely your Linux partitions are either Ext2 or Ext3. Ext2 is the standard filesystem for Linux. Ext3 is a newer one that differs from Ext2 in that it's journaled, meaning that if you turn the computer off without properly shutting down, you shouldn't lose any data and your system shouldn't spend ages doing filesystem checks the next time you boot up.

reiserfs If you're using a fairly new version of a Linux distro, your Linux partitions may very well be formatted as ReiserFS instead of the good old Ext2. Like Ext3, ReiserFS is a journaled filesystem, but it's much more advanced than Ext3. Many Linux distros (including SuSE) have started using ReiserFS as their default filesystem for Linux partitions.

swap The filesystem name is self-explanatory. The filesystem type "swap" is used in your swap partitions.

vfat and ntfs Your Windoze partitions are probably either Vfat or NTFS. The 9x series (95, 98, ME) all use Vfat (more widely known as FAT32), and the NT series (NT, 2000, XP) use NTFS. In 2000 and XP you can choose the filesystem type, so 2000 and XP partitions may be formatted as Vfat, too. If you want to be able to write to your Windows partitions from Linux, I suggest formatting them as Vfat, because Linux's support for writing to NTFS partitions is a bit shabby at this moment.

auto No, this isn't a filesystem type :-) The option "auto" simply means that the filesystem type is detected automatically. If you take a look at the example fstab above, you'll see that the floppy and CD-ROM both have "auto" as their filesystem type. Why? Their filesystem type may wary. One floppy might be formatted for Windows and the other for Linux's Ext2. That's why it's wise to let the system automatically detect the filesystem type of media such as floppies and cdroms.



< 4th column: Mount options >


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. Yes, there are many options available, but I'll take a look at the most widely used ones only. For more information, check out the man page of mount.

auto and noauto With the auto option, the device will be mounted automatically (at bootup, just like I told you a bit earlier, or when you issue the mount -a command). 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 mounted only explicitly.

user and nouser These are very useful options. The user option allows normal users to mount the device, whereas nouser lets only the root to mount the device. nouser is the default, which is a major cause of headache for new Linux users. If you're not able to mount your cdrom, floppy, Windoze partition, or something else as a normal user, add the user option into /etc/fstab.

exec and 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 conatins binaries you don't want to execute on your system, or that can't even be executed on your system. This might be the case of a Windows partition.

exec is the default option, which is a good thing. Imagine what would happen if you accidentally used the noexec option with your Linux root partition...

ro Mount the filesystem read-only.

rw Mount the filesystem read-write. Again, using this option might cure the headache of many new Linux users who are tearing their hair off because they can't write to their floppies, Windows partitions, or something else.

sync and 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.

However, if you have the async option in /etc/fstab, input and output is done asynchronously. Now when you copy a file to the floppy, the changes may be physically written to it long time after issuing the command. This isn't bad, and may sometimes be favorable, but can cause some nasty accidents: if you just remove the floppy without unmounting it first, the copied file may not physically exist on the floppy yet!

async is the default. However, it may be wise to use sync with the floppy, especially if you're used to the way it's done in Windoze and have a tendency to remove floppies before unmounting them first.

defaults Uses the default options that are rw, suid, dev, exec, auto, nouser, and async.

to finish understanding line 4 and 5 please follow the author's link.

COMPLETE ARTICLE AND CREDITS HERE:
Author: NGene < nhlang at gmail dot com >
__________________
HELP with JAVA, MP3's, Wireless, Repo's, YUM, Partitions, System Monitors, Nvidia, ATI drivers, LIMEWIRE PRO & MORE!.

Easiest and most friendly desktop ever is PCLinuxOS! Includes all this apps. Just try it.

"The greater the struggle THE greater the achievment."

Do you know HIM?

If you are an idiot click here. NThis will test you linux skills :D

Last edited by imdeemvp; 18th August 2004 at 10:41 AM.
Reply With Quote
  #2  
Old 18th August 2004, 10:30 AM
kosmosik's Avatar
kosmosik Offline
Registered User
 
Join Date: Apr 2004
Location: Warsaw, Poland
Age: 32
Posts: 1,085
well what about 4th and 5th column? :P
Reply With Quote
  #3  
Old 18th August 2004, 10:37 AM
imdeemvp's Avatar
imdeemvp Offline
Registered User
 
Join Date: Feb 2004
Age: 44
Posts: 8,256
not enough room that is why i posted the link...but i made a huge mistake i pressed submit when i meant to press PREVIEW.....so i could not finish editing

NOW to a better note, here is a sample of my /etc/stab:

LABEL=/ / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
none /dev/pts devpts gid=5,mode=620 0 0
none /dev/shm tmpfs defaults 0 0
none /proc proc defaults 0 0
none /sys sysfs defaults 0 0
/dev/hda6 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/cdrom1 /mnt/cdrom1 udf,iso9660 noauto,owner,kudzu,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
/dev/hda1 /mnt/winxp -t ntfs -r -o umask=0222
/dev/hda2 /mnt/windows vfat users,rw,owner,umask=000 0 0


i hope this will give you an idea how your windows partitions can me mounted automatically at boot........satisfied?..........eat a snickers bar
__________________
HELP with JAVA, MP3's, Wireless, Repo's, YUM, Partitions, System Monitors, Nvidia, ATI drivers, LIMEWIRE PRO & MORE!.

Easiest and most friendly desktop ever is PCLinuxOS! Includes all this apps. Just try it.

"The greater the struggle THE greater the achievment."

Do you know HIM?

If you are an idiot click here. NThis will test you linux skills :D

Last edited by imdeemvp; 19th September 2004 at 05:58 AM.
Reply With Quote
  #4  
Old 19th August 2004, 07:09 PM
GreyGeek Offline
Registered User
 
Join Date: Aug 2004
Location: Lincoln, NE
Age: 71
Posts: 83
Nice description, imdeepmvp...
Your /etc/fstab file has some stuff that is in my RHEL3 fstab, but not in my FC2 fstab file: The "LABEL" stuff.
When I first saw that I checked mtab and /proc/mounts to see what was really running.

What is with that "LABLE" stuff? Decode it for me, would you please?
Thanks.
GreyGeek
Reply With Quote
  #5  
Old 19th August 2004, 07:27 PM
kosmosik's Avatar
kosmosik Offline
Registered User
 
Join Date: Apr 2004
Location: Warsaw, Poland
Age: 32
Posts: 1,085
as for devices like removables (floppy, cdrom, pendrive, camera) and network filesystems (smb, nfs) I prefer to use autofs. it is much more convinient. you just pop the cd in and do "cd /misc/removable/cdrom" - cd gets automagicaly mounted and volia when you leave the directory (and no process is opening it) it gets unmounted after 3 seconds... autofs rulez. I wonder why Fedora ships autofs but it is not configured after install? (but the service is running) it is very convinient way of accessing removables. it is very logical - you have a directory (f.e. /misc/removable like I did) and when it has subdirectory like "cdrom" it means cdrom is in, if no such directory - no cdrom
Reply With Quote
  #6  
Old 19th August 2004, 07:31 PM
kosmosik's Avatar
kosmosik Offline
Registered User
 
Join Date: Apr 2004
Location: Warsaw, Poland
Age: 32
Posts: 1,085
the LABEL stuff AFAIR is way to add abstraction from hardware layout. meaning the block device (partition/fs) is accessed by its LABEL not by its physical location (device/partition) as hardware. means that you can f.e. have two drives with one partition on each. disk one is labeled "Root" and disk two is labeled "Home" in fstab you just enter volume names and it is independent on how you phisycaly connect the devices (which wire)... but AFAIR it works only with certain filesystems as extX and SGI XFS...

Last edited by kosmosik; 19th August 2004 at 07:34 PM.
Reply With Quote
  #7  
Old 19th August 2004, 07:39 PM
kosmosik's Avatar
kosmosik Offline
Registered User
 
Join Date: Apr 2004
Location: Warsaw, Poland
Age: 32
Posts: 1,085
this label stuff is good when you use external USB drive. such drive usualy is mapped as /dev/sda(and there go partitions on device) but if you happen to use also a pen drive or camera another external drive it sometimes will appear as diffferent /dev - entry. thus you cannot state explictly in /etc/fstab which FS is which. here LABEL comes handy, you just use LABEL on your externals drive FS and f.e. name one USB drive (1st) and the second (2nd) - then it does not matter if connected drive will apear as /dev/sda or /dev/sdb or whatever... it will still be mounted where you intended. it is also handy with multiple SCSI disks setups...
Reply With Quote
  #8  
Old 19th August 2004, 07:55 PM
imdeemvp's Avatar
imdeemvp Offline
Registered User
 
Join Date: Feb 2004
Age: 44
Posts: 8,256
kosmosik...........dude thanks!

while i was ZzZzZzZzZzZzZzZ.........you were up
__________________
HELP with JAVA, MP3's, Wireless, Repo's, YUM, Partitions, System Monitors, Nvidia, ATI drivers, LIMEWIRE PRO & MORE!.

Easiest and most friendly desktop ever is PCLinuxOS! Includes all this apps. Just try it.

"The greater the struggle THE greater the achievment."

Do you know HIM?

If you are an idiot click here. NThis will test you linux skills :D
Reply With Quote
  #9  
Old 19th August 2004, 08:11 PM
Mat's Avatar
Mat Offline
Retired Community Manager
 
Join Date: Jun 2004
Location: lair of a unix daemon
Posts: 1,155
something to add to the label-issue:

use /sbin/e2label to read/write the labels for the partitions


Mat
__________________
Man will always find a difficult means to perform a simple task
(Rube Goldberg)

Having fun with Tcl at
Mat's Playground
Reply With Quote
  #10  
Old 20th August 2004, 01:00 AM
LinuxHippy Offline
Registered User
 
Join Date: May 2004
Location: Philadelphia, PA-USA
Age: 40
Posts: 869
Question

Nice article-always wondered what those 0s and 1s meant. Got a situation: I want to share email messages between two Linux partitions on hda while the email would be on hdb1. How would I do this so that regular users could read and email on hdb1?

I'm thinking something like this:

/dev/hdb1 /mnt/hdb1 ext3 defaults 1 1

__________________
Marty

My Site: 777.servemp3.com

Last edited by LinuxHippy; 20th August 2004 at 01:43 AM.
Reply With Quote
  #11  
Old 20th August 2004, 01:48 AM
imdeemvp's Avatar
imdeemvp Offline
Registered User
 
Join Date: Feb 2004
Age: 44
Posts: 8,256
you meant you want to transfer them from one linux partition to another linux partition?
__________________
HELP with JAVA, MP3's, Wireless, Repo's, YUM, Partitions, System Monitors, Nvidia, ATI drivers, LIMEWIRE PRO & MORE!.

Easiest and most friendly desktop ever is PCLinuxOS! Includes all this apps. Just try it.

"The greater the struggle THE greater the achievment."

Do you know HIM?

If you are an idiot click here. NThis will test you linux skills :D
Reply With Quote
  #12  
Old 20th August 2004, 07:54 PM
LinuxHippy Offline
Registered User
 
Join Date: May 2004
Location: Philadelphia, PA-USA
Age: 40
Posts: 869
Quote:
Originally Posted by imdeemvp
you meant you want to transfer them from one linux partition to another linux partition?
no. I have FC2 on partition hda2 and Desktop/LX on partition hda5. They are both vers of Linux and both use Sylpheed as a mail reader/writer. My mail is on hdb1. I don't want any permissions to exist on hdb1. I'd like to be able to access my mail to read and write when I am in FC2 and then when I am in Desktop/LX. What do I do to do away with permissions on hdb1?
__________________
Marty

My Site: 777.servemp3.com
Reply With Quote
  #13  
Old 20th August 2004, 03:02 AM
nyba Offline
Registered User
 
Join Date: May 2004
Posts: 13
I have practical question might be related -
How to extend my root partition?

when I first installed fc2, I only give root partition a 6.8G allocation. Now as I am installing tons of applications, and a lot of files in my home directory (which is also on root partition) I used up 90% of that partition ....!

I have a slave harddrive, now have 3 partitions in vfat - I am planning to get one of them to ext3 or reiserfs ... Do you know how to extend my / partition to the new partition? I think most of the files are located at /usr, about 4G ...

thanks!
Reply With Quote
  #14  
Old 20th August 2004, 03:10 AM
imdeemvp's Avatar
imdeemvp Offline
Registered User
 
Join Date: Feb 2004
Age: 44
Posts: 8,256
i dont think linux partitions can be resize or extended.....i know under mandrake it is recommended to do a back up before doing it.......i dont if it can be done in fedora core!
__________________
HELP with JAVA, MP3's, Wireless, Repo's, YUM, Partitions, System Monitors, Nvidia, ATI drivers, LIMEWIRE PRO & MORE!.

Easiest and most friendly desktop ever is PCLinuxOS! Includes all this apps. Just try it.

"The greater the struggle THE greater the achievment."

Do you know HIM?

If you are an idiot click here. NThis will test you linux skills :D
Reply With Quote
  #15  
Old 20th August 2004, 03:22 AM
nyba Offline
Registered User
 
Join Date: May 2004
Posts: 13
I am thinking reformat on vfat to ext3 or possible to to reiserfs, then su
cp -rf /usr /mnt/oldvfat
then edit fstab to mount /usr at this /hdb2 ( 17G space)
what do u think?
Reply With Quote
Reply

Tags
edit, or etc or fstab

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Edit /etc/fstab/ Help ezeze5000 Hardware & Laptops 4 13th March 2005 07:45 PM


Current GMT-time: 05:33 (Sunday, 26-05-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat