Configure fstab

From gr0x0rd
Revision as of 16:25, 1 December 2010 by Gr0x0rd (talk | contribs) (Created page with "== Configure fstab == The fstab is an abbreviation for ''file system table''. This file is read at boot time and instructs the system how to compose the linux filesystem from th…")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Configure fstab

The fstab is an abbreviation for file system table. This file is read at boot time and instructs the system how to compose the linux filesystem from the physical partitions available on the physical drives connected to the system, as well as any network resources.

A default fstab has been provided for you, so all you'll need do is edit the example. As with previous steps, be sure to replace /dev/sda with whatever you system has designated your primary drive as. The format of the file is fairly simple: the first item is the partition attached to the system, the second is what part of the linux filesystem that device should be mounted as, the third is the filesystem type, and the fourth and fifth are filesystem specific settings.

# nano -w /etc/fstab

file: /etc/fstab

###########################
#
# gr0x0rd's fstab
#
###########################

/dev/sda1		/boot		ext2		noauto,noatime,user	1 2
/dev/sda3		/		ext3		noatime		0 1
/dev/sda2		none		swap		sw		0 0
#/dev/cdrom		/mnt/cdrom	auto		noauto,user	0 0
#/dev/fd0		/mnt/floppy	auto		noauto		0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for 
# POSIX shared memory (shm_open, shm_unlink).
# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will
#  use almost no memory if not populated with files)
shm			/dev/shm	tmpfs		nodev,nosuid,noexec	0 0

Note in the file above that both the cdrom and floppy disk devices are commented out: the floppy because there is no floppy drive attached to the system, and the cdrom because mounting and configuration of cdrom devices is now handled by udev and your desktop manager.

If you have another drive or partition that you wish to connect to the system, you can add it to the fstab so it is mounted at boot time and you needn't mount it once the system is up and running. For example, if I had a second hard drive and wanted to mount its 3rd partition to the folder /usr/local/storage/gr0x-X within my filesystem, I would add the following line:

/dev/sdb3               /usr/local/storage/gr0x-X       ext3    noatime         0 0



Note: before adding devices to your fstab, make sure your mount points within your filesystem exist, and you've set the appropriate permissions, or it won't be possible to mount or access them. With a new installation, the folder /usr/local/storage/gr0x-X would not exist. I'd create it using the following commands:

# mkdir /usr/local/storage
# mkdir /usr/local/storage/gr0x-X

Now let's set the appropriate permissions so users can read and write data contained in this mount point:

# chown -R root:users /usr/local/storage/gr0x-X
# chmod -R 777 /usr/local/storage/gr0x-X


If I had a third SATA hard drive with a single partition formatted for Microsoft Windows using the NTFS filesystem, I would add the following line:

/dev/sdc1               /usr/local/storage/gr0x-0       ntfs-3g noatime         0 0

To mount a shared drive that exists on a Windows machine located somewhere else on your network, I would add the following line: