Configure fstab
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 using the credentials username / password, I would add the following line:
//smack/videos /home/gr0x0rd/smack cifs username=username,password=password 0 0
Note: as before, make sure your mount points exist within your local filesystem. I'd create the mount point referenced above using the following commands:
# mkdir /home/gr0x0rd # mkdir /home/gr0x0rd/smack
It's also wise to set the appropriate permissions so users can read the data contained in this mount point:
# chown -R root:users /home/gr0x0rd/smack # chmod 777 /home/gr0x0rd/smack
As also previously mentioned, you'll need to ensure you have emerged either the net-fs/mount-cifs package as shown in system utilities or the net-fs/samba package as shown in the Samba section, and support for cifs filesystems built into your kernel.
Finally, you'll also need to tell your system where it can find the computer in the example above. This is done by creating an alias for the computer's local IP address in your /etc/hosts file.
Once you are satisfied with the contents of your /etc/fstab, you can save the file and proceed to configure the bootloader.