Core Concepts: Understanding /etc/fstab, and seriously, WTF is fstab???

o rlyI just couldn’t help myself, I had to post at least something on my birthday, and what better thing to talk about, then fstab! Many new Linux users are mystified when their external drives, even mounted internally in their computer enclosures, don’t auto mount. They typically only discover this after manually mounting them in the File Explorer, then adding this media directory/source to something like XBMC, only to discover that there are no files if they reboot and re-enter XBMC.

Well fear no more Bros and Lady types! Hopefully by the end of this, you know how to auto mount your external drives and anything else you throw at it. Heck, I’ll even show you a few newbie-friendly GUI/Graphical applications if requested! If you have any questions, be sure to ask in the comments. Ok, let’s get this rolling.

Read on…

What the HECK is fstab?

“fstab” is a file located under most Linux distributions in /etc/fstab.  This is the mother-freaking-mothership of mount points, or in simple terms, where all your internal and external hard drive devices are specified to be “mounted” or “connected” when you boot up your computer.  But you never restart your Linux box right? hehe.  fstab may look scary at first, and believe me, when I first started learning Linux in 2004, I had to do a little bit of research before I fully got going.  Once you understand the core concepts, it is really not that daunting.

Let’s being by looking at a screenshot of my fstab file: (Do NOT open your own, or at your own risk!)

fstab

Holy sh** on a shingle!  What IS* all that?

Lets study the screenshot a bit with a few key points (open up two terminal programs if you wish to compare back and forth):

  • Take note of the labeling structure here:#

<file system> <mount point> <type> <options> <dump> <pass>

  • <filesystem>
    • This can be a bit vague.  As you can see above, the first object starts with “UUID=”  So what the heck is a UUID?  UUID or “Universally Unique Identifier,”  is as it says, the UNIQUE “code” for that particular device.  Some may tell you something to the effect of use “/dev/sda#” instead.  I have always and still believe that is a poor decision.  Why?  It is not unique by a long stretch, and another device could take its place  if swapped/mounted to that location without you knowing.  A “UUID” code/location is specific to that drive, and that drive only*.  To find the UUID of your devices, go to the Terminal and type:
blkid

fstab2

Take note of the numbers following “UUID=”  This is  your UUID for that drive.  Select and right click , copy, or* write it down.

  • <mount point>
    • The mount point is where you want the drive to appear at or be “mounted.”   Generally you would do the following:
sudo mkdir /media/my_user_name/external_drive_name

At this point, back in fstab, we can fill this next section in with that location.   So far we have this:

UUID=0000000000000   /media/user_name/drive_name
  • <type>
    • Type is the type of file system the drive is.  If your drive came from the Windows XP/Win7/Win8, you will want to fill in “ntfs” here.  Otherwise, you will want to check out this list of file-system disk types to better acquaint yourself. This field represents the filesystem to be used when mounting the device or partition. Typical values for this field are ext2, ext3, reiserfs, vfat, iso9660, and udf. auto can be used if multiple filesystems can be used on removable devices such as card readers, CD-ROMs, and DVD-ROMs.
    • Ext2/3/4: Standard Linux file systems, 4 being the most featured and current
    • reiserfs Your Linux partitions may very well be formatted as ReiserFS. 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 type “swap” is used in your swap partitions.
    • vfat and ntfs : Your USB stick is most likely formatted as Vfat (more widely known as FAT32). ntfs is the file system used by  windows drives.
    • auto:  The option “auto” simply means that the filesystem type is detected automatically.
    • Note: Generally a space is fine between each <section>, but generally hitting TAB to put some space inbetween is acceptable):
    • Now let’s see where we are:
UUID=0000000000000   /media/user_name/drive_name   ntfs
  • <options>
    • This is one of those more technical areas.   Some mount options are file system specific. These are options given to the mount, umount and eject commands. A value of defaults means to use the default options for the filesystem being used. users means that any user can mount the device. owner means that only the owner of the device can mount and unmount the device. Usually this is the administrator. rw means to mount the device for read and write access. ro means the device is mounted for read-only access. There are quite a few other options that can be placed in this field.  Those are just the typical options.
  • <dump> and <pass>
    • These two columns represent the backup utility and the fsck utility, respectively.  The fsck utility will do file system checking, similar to chkdsk on Windows.  If either are 0, they will not occur, while making them 1 will invoke them.  You will not break you system by having both 0, and saves the system some time processing them.
    • The root filesystem should be specified with a fs_passno of 1, and other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware.  See the man page for fstab and fsck.

That is pretty much it.  As stated BACKUP on an EXTERNAL USB DRIVE (in addition to possibly locally on your system), your /etc/fstab file before making changes.  You never know what you will break.  Often for non-critical disks, you can check you mount by refreshing fstab with this command:

sudo mount -a

That will also show you any verbose output, if errors do occur.

Other graphical tools to accomplish all of this:

  • PySDM (pretty good universal GUI mount tool, GTK based)
  • MountManager (KDE based Desktop Environments, QT based)
  • Disks (on gnome based Desktop Environments)

Leave questions of comments below!

Till next time,

-Professor

Advertisements

About professorkaos64

www.libregeek.org

Posted on 20130620, in Core Concepts, How-To and tagged , , , , , , . Bookmark the permalink. 3 Comments.

  1. Great article!
    I also found this page on the Ubuntu community help site useful: https://help.ubuntu.com/community/Fstab

    • professorkaos64

      Thank you very much for your support. I run this thing by myself so it’s very appreciated. I am always welcome to criticisms/suggestions/corrections.

  1. Pingback: Mount it! Part 1: How to manually mount your Local Hard Drive: | The_Linux_Cauldron

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s