Difference between revisions of "Configure fstab"

From gr0x0rd
Jump to navigation Jump to search
Line 27: Line 27:
 
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:
 
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
 
  /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:
 
'''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:
Line 41: Line 39:
 
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:
 
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
 
  /dev/sdc1              /usr/local/storage/gr0x-0      ntfs-3g noatime        0 0
 
 
 
----
 
----
 
'''Note:''' in order to successfully mount an NTFS partition and be able to read and write to it, you must have the ''sys-fs/ntfs3g'' package installed and support for the NTFS filesystem enabled in the kernel. Instructions on how to do this are located in the [[Emerge System Utilities]] and [[Configure_the_Kernel#Other_Recommended_Options | Configure the Kernel]] sections respectively.
 
'''Note:''' in order to successfully mount an NTFS partition and be able to read and write to it, you must have the ''sys-fs/ntfs3g'' package installed and support for the NTFS filesystem enabled in the kernel. Instructions on how to do this are located in the [[Emerge System Utilities]] and [[Configure_the_Kernel#Other_Recommended_Options | Configure the Kernel]] sections respectively.
Line 48: Line 44:
  
  
To mount a shared drive that exists on a Windows machine located somewhere else on your network, I would add the following line:
+
It is also possible to add shared drives located on a Windows machine somewhere else on your network. If I wanted to mount a share called ''videos'' located on a computer on my network called ''smack'' to a local folder at ''/home/gr0x0rd/smack'', I would add the following line:
 +
//smack/videos          /home/gr0x0rd/smack    cifs    username=''username'',password=''password'' 0 0

Revision as of 16:48, 1 December 2010

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

Notice 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

Note: in order to successfully mount an NTFS partition and be able to read and write to it, you must have the sys-fs/ntfs3g package installed and support for the NTFS filesystem enabled in the kernel. Instructions on how to do this are located in the Emerge System Utilities and Configure the Kernel sections respectively.



It is also possible to add shared drives located on a Windows machine somewhere else on your network. If I wanted to mount a share called videos located on a computer on my network called smack to a local folder at /home/gr0x0rd/smack, I would add the following line:

//smack/videos          /home/gr0x0rd/smack     cifs    username=username,password=password 0 0