The fstab file can be used to define how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem.
In order for partitions to be auto-mounted upon server boot up we have to add them to fstab file.
In this example we will be adding software raid disks: md0, md1, md2 (/dev/sda1 partition already added and mounted to /) :
1. Check partitions’ mount points and find out filesystem type:
[root@backup-44-158 ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/sda1 ext4 103080888 1853756 95967868 2% /
devtmpfs devtmpfs 3975212 0 3975212 0% /dev
tmpfs tmpfs 3984864 0 3984864 0% /dev/shm
tmpfs tmpfs 3984864 8764 3976100 1% /run
tmpfs tmpfs 3984864 0 3984864 0% /sys/fs/cgroup
tmpfs tmpfs 796976 0 796976 0% /run/user/0
/dev/md0 ext4 7752034748 876476 7360453172 1% /disk01
/dev/md1 ext4 7752034748 94232 7361235416 1% /disk02
/dev/md2 ext4 7752034748 94232 7361235416 1% /disk03
tmpfs tmpfs 796976 0 796976 0% /run/user/1000
2. Check for the UUID:
[root@backup-44-158 ~]# lsblk -o NAME,UUID
NAME UUID
sda
└─sda1 abe85247-aa2d-4939-8363-f24e03be2410
sdc
└─md0 3dbca576-c695-406e-bf63-bc63ce2e322f
sdd 2f3796fc-9054-4c42-40b5-3cc65e8c62b6
└─md0 3dbca576-c695-406e-bf63-bc63ce2e322f
sde
└─md0 3dbca576-c695-406e-bf63-bc63ce2e322f
sdf
└─md1 e9bac87f-1e65-4e7f-9d02-f631fbaab74f
sdg 17a82195-6159-494c-c765-a5ce7498d5d2
└─md1 e9bac87f-1e65-4e7f-9d02-f631fbaab74f
sdh 17a82195-6159-494c-c765-a5ce7498d5d2
└─md1 e9bac87f-1e65-4e7f-9d02-f631fbaab74f
sdi
└─md2 19f4562d-0c27-4e1f-89f8-6bab04b72dc5
sdj
└─sdj1 bdf39aef-7473-301f-2acb-4570f1e6b15d
sdk
└─md2 19f4562d-0c27-4e1f-89f8-6bab04b72dc5
sdl
└─md2 19f4562d-0c27-4e1f-89f8-6bab04b72dc5
3. Edit fstab file /etc/fstab and add partitions their mount point and filesystem type into it:
# /etc/fstab
# Created by anaconda on Sat Oct 14 12:35:51 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
UUID=abe85247-aa2d-4939-8363-f24e03be2410 / ext4 defaults 1 1
UUID=3dbca576-c695-406e-bf63-bc63ce2e322f /disk01 ext4 defaults 0 0
UUID=e9bac87f-1e65-4e7f-9d02-f631fbaab74f /disk02 ext4 defaults 0 0
UUID=19f4562d-0c27-4e1f-89f8-6bab04b72dc5 /disk03 ext4 defaults 0 0
Now upon system boot up, partitions will be auto-mounted.