Monday, February 02, 2009

fstab

Key points:

One can use Label, UUID, besides the device nodes to mount a device.

More information can be found at http://ubuntuforums.org/showthread.php?t=283131


Understanding fstab

Sorry this is such a long post.

I added much of this information to the Ubuntu wiki.

Ubuntu Wiki : fstab

There are essentially 5 sections:

1. Introduction / Mount.
2. "fstab syntax" - Syntax and fstab options.
3. How to label, FAT and Linux file systems.
4. Examples, FAT and Linux native file systems.
5. References


Scroll down to the section you need.

Introduction

/etc/fstab is a system configuration file and is used to tell the Linux kernel which partitions (file systems) to mount and where on the file system tree.

/etc/mtab is an index of all mounted partitions/file systems.

Note: See references section at the end of this how to for useful links.

How to mount

The mount command and fstab go hand in hand:

1. Options for mount and fstab are similar.
2. If a device/partition is not listed in fstab ONLY ROOT may mount the device/partition.
3. Users can mount a removable device using pmount.
4. Users may mount a device/partition if the device is in fstab with the proper options.


How to mount
Mount Partitions Automatically (At BOOT).
Filesystems and Mounting Thanks Hermanzone

mount has a multitude of options. Manpage: man mount

pmount: Pmount allows a user to mount removable media.
pmount uses /media/ as the mount point.

Syntax:
Quote:
pmount
Example:
Code:

pmount /dev/dsa1 data

This creates a directory "data" in /media (mount point is /media/data) and mounts your removable device there.

To unmount:
Code:

pumount

Note: pmount does not like to mount to an existing directory in /media.

* For example, if you have a directory /media/usb ; pmount /dev/sda1 usb may fail.
* If you are having problems with gnome-volume-manager or pmount check the contents of /media and delete directories as needed.
* Obviously do not delete a directory in /media if a device is mounted to this mount point.


Configure pmount for internal drives

To show your partitions/usb devices, first plug in your usb card.

To list your mounted partitions:
Code:

mount

To list all your partitions, mounted or not:
Code:

sudo fdisk -l

To list all your partitions by UUID:
First connect all your devices, then:
Code:

ls /dev/disk/by-uuid -alh

============== END OF INTRODUCTION ===============


fstab Syntax

Quote:
[Device] [Mount Point] [File_system] [Options] [dump] [fsck order]
Device = Physical location.

/dev/hdxy or /dev/sdxy.

x will be a letter starting with a, then b,c,....
y will be a number starting with 1, then 2,3,....

Thus hda1 = First partition on the master HD.

See Basic partitioning for more information

Note: zip discs are always numbered "4".
Example: USB Zip = /dev/sda4.

Note: You can also identify a device by udev, volume label (AKA LABEL), or uuid.

These fstab techniques are helpful for removable media because the device (/dev/sdxy) may change. For example, sometimes the USB device will be assigned /dev/sda1, other times /dev/sdb1. This depends on what order you connect USB devices, and where (which USB slot) you use to connect. This can be a major aggravation as you must identify the device before you can mount it. fstab does not work well if the device name keeps changing.

To list your devices, first put connect your USB device (it does not need to be mounted).
By volume label:
Code:

ls /dev/disk/by-label -lah

By id:
Code:

ls /dev/disk/by-id -lah

By uuid:
Code:

ls /dev/disk/by-uuid -lah

IMO, LABEL is easiest to use as you can set a label and it is human readable.

The format to use instead of the device name in the fstab file is:

LABEL=

Blog Archive