Skip to Content

Editing /etc/fstab

CVirus's picture

Hello , Its Me Again

The original author was thinking to write how-to mount windows partition but the idea gets more fat to get more than windows to be generally FSTAB

On Mandrake and some other Distributions, The System mounts Windows Partitions Automatically,

By Other Means, When You cd To /mnt/windows ... You'll Find Your Files there ...

But on Fedora Core and some other Distributions, You Must mount your Windows Partitions each Time you Boot into your System ... Now, The Question is : How To Make it mounted Automaticlly each time your System Boots UP ?!

Before Getting Into Details .. You'll Have to Know That ...

When you Boot Your System .. The Kernel Looks for a File called /etc/fstab Which Describes all the File Systems that Should Be mounted and Then mounts Them All.

This File not Only Includes Your root and swap Partitions but Also Includes any Extra Partitions you Want to mount .. Plus all Logical/Virtual File Systems like the /proc File System.

Note: fstab Stands For "File System Table"

Now, Inorder to Make The Partitions mounted Automaticlly Every Time Your System Boots UP What You Need is to Add Entries in Your /etc/fstab

Here is The Format of The Entry ..

  • device_name: It is the Name Of The Physical Device you Want To Mount ,It could be a network share ,NFS (Network File System ) *nix share or SMB (Server Message Block ) Window$ share ( Network resource ) ..
  • Ex. /dev/hda1 for physical devices and it is also local
  • Ex. files.eglug.org:/share/path NFS resource
  • Ex. //ms.Misr-soft/share-name SMB resource
  • mount_point: It is the Mount Point Where The File System(Partition) will be Mounted .. Ex. mnt/win_c
  • fstype: It is the Type Of the File System of the Partition that Will Be Mounted .. Ex. vfat, ext3 , nfs , smbfs , ntfs and swap

Now, The Common Options Are:

  • user: It Makes the Partition Mountable by any user, but then only that user can unmount it. (For Sure CDROM Drives must have this Option)
  • users: It Makes the Partition Mountable by any user, and any user can unmount it.
  • noexec: No Executable Files Allowed (You Should Use this with Windows Partitions or Else All the Files Will be Considered Executables)
  • ro: Read Only
  • rw: Read/Write
  • noauto: Don't mount this at Boot Time (You May be Wondering What its doing in fstab if it is Not Going to Be mounted at Boot Time, this is Used to Simplify mounting Removable Media like CDROMS and FLOPPIES)
  • uid: Sets Default User id (All Files on your Partition Will be Owned by this User)
  • gid: Sets Default Groups id (All Files will be Owned by this Group)
  • sync: Always Sync File System (Don't Cache Content .. Use this with Floppies)
  • dump_frequency: Is Used to Automatically Backup Files (Only Useful For ext File System)
  • fsck_priority: Is Used to Determine The Order of Checking File Systems when Doing a System Wide fsck at Boot Time, a Value of Zero will Tell the Kernel Never to Check This File System (This is How it Should be For Most Windows Partitions). The two digits allow for parallel checks when you have two different drives, thus speeding up boottime checks.

Note: fsck Stands For File System Check and it is used to Check and Repair a Linux File System

Now Lets Take a Look at My /etc/fstab

/dev/hda2 / ext3 defaults 0 1 /dev/hda6 /home ext3 defaults 0 2 /dev/cdrom /mnt/cdrom iso9660 noauto,user,noexec,ro,uid=501,gid=22 0 0 /dev/cdrom1 /mnt/cdrw iso9660 noauto,user,noexec,ro,uid=501,gid=28 0 0 /dev/fd0 /mnt/floppy vfat user,sync,noauto 0 0 /dev/hda1 /mnt/win_c vfat noexec,rw,uid=501,gid=6 0 0 /dev/hda5 /mnt/win_d vfat noexec,rw,uid=501,gid=6 0 0 none /proc proc defaults 0 0 /dev/hda3 swap swap defaults 0 0 /dev/hdb2 /mnt/edge reiser4 defaults 1 1

OK, So What we Have Here Is :

  • A root Partition on /dev/hda2 .. Its File System is ext3 ( second partition on the primary master drive ) .. Options are Set to defaults and it Should be the First Partition to be Checked by fsck.
  • A reiser4 partition /dev/hdb2 ( second partiton on the primary slave drive ) will be checked at the same time as the previous partition (parallel).
  • Then on /dev/hda6 Lies my /home Partition, Same as the root Partition but Should be Checked by fsck after the root Partition.
  • The /dev/cdrom Has my CDROM Drive, Its mounted to /mnt/cdrom, File Type is iso9660 (DON'T use auto in fstab) .. And the Options Are :
  • noauto: Don't mount at Boot Time since the Drive May be Empty and Media may Change.
  • user: File System is User mountable (This is Important Since its Not mounted on Boot Time, and Users have to be Able to mount their CDROMS).
  • noexec: No Executables Allowed.
  • ro: Read Only File System
  • uid=501: Default User is the User with id 501 (Thats Me)
  • gid=22: Default Group is the Group with id 22 (Thats the CDROM) And no Backups or File Checking is Needed.

The Entry for the CDRW Drive is Exactly the Same As for the CDROM, You Don't Need to Make it read/write Since Writing to the CDR Media is Done While the Media is unmounted.

The Benefit of having a CDROM Entry in Your fstab will be Revealed Now :

Instead of Running :

mount -t iso9660 /dev/cdrom /mnt/cdrom -o noauto,user,noexec,ro,uid=501,gid=22

Simply, You Can Just Run :

mount /mnt/cdrom

OR You Can Use :

mount /dev/cdrom
  • The Windows Partitions /dev/hda1 and /dev/hda5 are mounted at Boot Time to /mnt/win_c and /mnt/win_d .. They are vfat File Systems (Thats FAT32, FAT16 is simply called FAT), Their Options are:
  • noexcutable, read/write File System and a Certain user/group Own the Files on those Partitions.
  • The proc File System Being a Virtual file System has a Device none, It is mounted to /proc and the File System Type is proc.
  • Finlay the swap Partition is on /dev/hda3, mount Point for swap Partitions is swap (Notice NOT /swap) and the File System Type is of Course swap.it is not accessible by anyuser except the kernel .

As you Can See you Don't Really Need to Tweak All Options .. A Line that Says

/dev/hda5 /mnt/win_d vfat

Is Enough to mount your Windows Partition.

some distributions like red-hat/fedora could not mount NTFS file system automatically like the vfat due to patent promise or ,license conflicts so the decide to remove the NTFS.

Network Resource Mounting

locally .it may be also mount network resource on boot .

  • NFS (Network File System) *nix share hostname:/path/to/share /mount/point nfs defaults 0 0

    the defaults may be changed with many other option as i remember some of them

    • ro: read only
    • rw: read write
    • __intr_ : allow to kill the process of request if the server is not accessible
    • nointr: killing the process or interrupt is not allowed it the server is not reachable
    • soft : if the process fails it will give a error message
    • hard : if the process fails it will block that tries to access an unreachable resource
    • rsize : rsize=8192
    • wsize : wsize=8192 this will enhance the mounting and the process of transactions,speed up NFS throughput . 192.168.0.10:/home/conceptor/exports /mnt/mounted nfs defaults,ro,rsize=8192,wsize=8192,soft
      • SMB (Server Message Block )

      the most linux boxes could mount the M$ share resources automatically without any problems

      the entry will looks like //192.168.0.1/myshare-name /mount/point defaults 0 0

      the options is diffrent from nfs the could be

      • __username=x : the MS share is based on usernames and password but nfs is based on hosts -hostnames or IPs- so you should type them
      • password=xx : actully many many people are doing the administrator password blank in M$ ,and linux accept the blank in this case.
      • uid = provid your id or gid

      so the entry will be something like //hostname/files /mount/point defaults,username=diaa,password=eglug,uid=514 0 0

      This Article is Originally Written by Alaa and re-organized by CVirus,and many contributers

Comments

phaeronix's picture

Correction

The option : user allows any user to mount the corresponding mountpoint, and then only that user can unmount it.

However the option : users allows any user to mount the corresponding mountpoint, and then ANY user can umount it. ( With the exception that stuff mounted by root can only be unmounted by root ).

Also You didn't mention why there are two digits for the filesystem check options. It allows for parallel checks when you have two different drives, thus speeding up boottime checks.

for example:

/dev/hda2 / ext3 defaults 0 1

/dev/hdb2 /mnt/anypart ext3 defaults 1 1

Would mean that /dev/hda2 ( second partition on the primary master drive ) will be checked at the same time with /dev/hdb2 ( second partiton on the primary slave drive ).

Alaa's picture

ahem WIKI

dict wikiwikiweb

Alaa


"i`m feeling for the 2nd time like alice in wonderland reading el wafd"

How to mount window$ share with space in between (two-word)

i would like to ask on how to mount window$ share: two-word share name. ie. "cso share"

//192.168.11.254/cso share /mnt/csoshare smbfs auto,exec,credentials=/home/eds/.smbpasswd,uid=eds,gid=500 0 0

above code doesn't work because of the space character in between "cso share".

thanks in advance. eds

CVirus's picture

Use the escape character

Use the escape character followed by the 3 digit octal code for space, so:

//computer/Share\040Name

Get my gpg key: gpg --recv-key --keyserver pgp.mit.edu 4CFE7230 Key Fingerprint: C5A6 BE2B 594A F616 E3C2

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.


Dr. Radut | book