Hi,
In this post/chapter I am going to talk about how to automate the process of mounting of partitions of the disk...
We are going to use the partitions created in chapter-02 to mount automatically , to recollect let me summarize the partitions here briefly...
Disk Partition | Partition Name | Partition Type | Size of the Partition |
/dev/sde1 | boot | ext2 | 100 MB |
/dev/sde2 | root | ext4 | 30 GB |
/dev/sde3 | swap | swap | 9.9 GB |
The purpose of having this post/chapter is when ever the system is shutdown... the mount point we established would vanish and it becomes tedious for the user to mount the partitions again and again after every system boot.
This is where fstab comes handy as a solution to this problem.
the following would describe the edition of fstab and check whether the mounting has happened without error...
Identifying the UUID of the partitions
To identify the UUID of the partitions we can the use the utility called "blkid" which would list all the UUID of the partitions available in the system.
$ blkid
The output of the above command is sampled below...
from the above command output, we can inference the following details...
Disk Partition | Partition UUID | Partition Type |
/dev/sde1 | 86fa30de-9907-4ced-a5ba-c6043ae04aee | ext2 |
/dev/sde2 | d9bfa86a-9ba8-4681-9bd0-3c3e25ee9ce3 | ext4 |
/dev/sde3 | 3ce6bf45-e899-4c48-94b4-0c11305c2353 | swap |
Editing the FSTAB file
Before we edit the fstab file, we have to know the structure of the file, the structure of the table is furnished in the table below to have the understand what each parameter is meant for...
File System | Denotes the partition name or the UUID of the partition |
Mount Point | The location at which the partition is mounted |
Type | Type of the file system on the partition |
Options | Denotes the options available in the manual page of fdisk |
Dump | Denotes the flag for the back up, 0=no-backup, 1=yes-backup |
Pass | - |
Based on the above understanding, we would arrive the fstab entries as follows...
File System | Mount Point | Type | Options | Dump | Pass |
UUID=d9bfa86a-9ba8-4681-9bd0-3c3e25ee9ce3 | /mnt/lfs | ext4 | defaults | 0 | 1 |
UUID=86fa30de-9907-4ced-a5ba-c6043ae04aee | /mnt/lfs/boot | ext2 | defaults | 0 | 1 |
UUID=3ce6bf45-e899-4c48-94b4-0c11305c2353 | swap | swap | defaults | 0 | 0 |
Use the command below to edit the fstab file...
$ sudo vi /etc/fstab
after we include the above fstab entires in fstab file, the file would like the one shown below...
Testing or Validating the fstab entries
This testing phase is required after including the fstab entries because the system would not boot properly if there is an error in any of the entries included.
For the SWAP partitions to be mounted, we should have switched on SWAP using the following command
$ sudo swapon /dev/sde3
In order to check or test the entires, use the command below...
$ sudo mount -a
This command would try to mount all the entries made available in the fstab file.
$ sudo mount
This command would display the result of each entires as that of the one show below... you have to cross check whether the partition is mounted correctly or not, if there is no error then the partition would show up or else not.
You can also use an other command to check whether the partitions are mounted correctly or not.
Key in the "lsblk" command at the prompt, to have the result
the command "lsblk" is just an other option, the former is the actual way to check the integrity of the entires...
No comments:
Post a Comment