fstab demystified how to add partitions and more
In this post you will learn to understand fstab and it’s entries. This post is a follow up to: How to partition new hard drives the easy way. It will show you how to add the new partitions of the new hard drive to fstab to mount the partitions automatically on boot.
Unfortunately there is no way to do this in a “point and click” manner. At least I’ve not been able to find one.
Let’s take a look at the contents of fstab:
nano /etc/fstab
Note where not editing yet so we do not need to sudo this command yet, we will do so this when we start editing.
Contents:
# /etc/fstab: static file system information. # # < file system> < mount point> < type> < options> < dump> < pass> proc /proc proc defaults 0 0 /dev/sda1 / ext3 relatime,errors=remount-ro 0 1 /dev/sda3 /home ext3 nodev,nosuid,errors=remount-ro 0 2 /dev/sda5 none swap sw 0 0 /dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
Lets pick the line for root apart.
| 1 | 2 | 3 | 4 | 5 | 6 |
| /dev/sda1 | / | ext3 | relatime,errors=remount-ro | 0 | 1 |
(from WikiPedia)
The columns are as follows:
1. The device name or other means of locating the partition or data source.
2. The mount point, where the data is to be attached to the filesystem.
3. The filesystem type, or the algorithm used to interpret the filesystem.
4. Options, including if the filesystem should be mounted at boot.
5. dump-freq adjusts the archiving schedule for the partition (used by dump).
6. pass-num indicates the order in which the fsck utility will scan the partitions for errors when the computer powers on.
Now let’s find out what the dev point is of the new partition:
sudo fdisk -l
The contens could look like this:
Disk /dev/sda: 120.0 GB, 120034123776 bytes 255 heads, 63 sectors/track, 14593 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x983b983b Device Boot Start End Blocks Id System /dev/sda1 * 1 4020 32290618+ 83 Linux /dev/sda2 14220 14593 3004155 5 Extended /dev/sda3 4021 14219 81923467+ 83 Linux /dev/sda5 14220 14593 3004123+ 82 Linux swap / Solaris Disk /dev/sdb: 750.1 GB, 750156374016 bytes 255 heads, 63 sectors/track, 91201 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Disk identifier: 0x0002d62c Device Boot Start End Blocks Id System /dev/sdb1 1 6452 51825658+ 83 Linux /dev/sdb2 6453 39179 262879627+ 83 Linux /dev/sdb3 39180 91201 417866715 83 Linux Partition table entries are not in disk order
In this case the first disk(sda) is a 120GB disk the second(sdb) is a 750GB disk.
sda has 5 Partitions sda1, sda2 etc.
sdb has 3 partitions sdb1, sdb2 and sdb3.
We’re going to add sdb1 to the fstab file. I get asked often what to do with the options the answer nothing unless you are experiencing problem.
We need to create a mount point. Most mount point are created in /media or /mnt but you could put the mount point any where you want. I always choose /media.
sudo mkdir /media/partiotion1
Open fstab for editing:
sudo nano /etc/fstab
Now add the following line bellow what is already there:
/dev/sdb1 /media/partition1 ext3 defaults 0 3
let’s explain again:
/dev/sdb1: dev stands for “device file system” and sdb1 the partition on our hard disk.
/media/partition1: the mount point in other words the folder that the new partition will be mounted to.
ext3: the file system used on the partition.
defaults: the defaults option this will automatically define these options: rw,suid,dev,exec,auto,nouser,async all the options we need to get the partition to work properly.
0: the dump frequency all the fstabs I’ve seen so far don’t change this setting so it don’t either explanation of this will follow in another post some other time.
3: this sets the order of fsck file system checking I happen to like all my partitions checked every once in a while so I changed this to 3. If you don’t want the partition checked simply set this to 0.
Close the fstab file(ctrl->x y enter).
If there is anything you want further explanation of please feel free to leave a comment. Also comment if this post was helpful at all.
Tags: command, device boot, drive, ext3, fdisk, filesystem type, folders, fstab, hard, hard drives, linux, nano, new hard drive, partition, partitions, static file, sudo, Terminal


