How to mount a hard driver in CentOS 7/RHEL 7
Mounting a disk in CentOS could be relatively easy if we have the right guide, then we will see how we could format and mount a hard disk in CentOS 7.
The first thing we will do is check the hard drives in our system with the command (fdisk -l).
# fdisk -l
As we already know the disk drives available in our system, we can format it in the case of a new disk drive, it is necessary to format it, which could be ext4 or ext3. So we could format it with the following command and the disk drive of our preference in my case (/ dev / sdf).
# mkfs.ext3 /dev/sdf
Once the format of our hard disk is finished, we can mount it, for this the first thing is to create a file where we want the data of our disk drive to be saved once it is mounted. To create a file we can do it with the following command in the directory of our preference and with a name that we can identify it, in my case the root directory (/disk-50gb).
# mkdir /disk-50gb
We check that our file has been created correctly with the following command:
[root@s]# ls -la /
dr-xr-xr-x. 20 root root 4096 May 17 17:47 .
dr-xr-xr-x. 20 root root 4096 May 17 17:47 ..
lrwxrwxrwx. 1 root root 7 Apr 13 16:05 bin -> usr/bin
dr-xr-xr-x. 6 root root 4096 May 16 00:06 boot
drwxr-xr-x 20 root root 3600 May 17 17:45 dev
drwxr-xr-x. 117 root root 12288 May 17 17:50 etc
drwxr-xr-x 4 root root 4096 May 17 17:47 disk-50gb
drwx--x--x. 26 root root 4096 May 17 17:47 home
Finally, we mount our disk drive (/ dev/sdf) to the directory (/disk-50gb) with the following command:
# mount /dev/sdf /disk-50gb
We check that our disk drive has been mounted correctly with the following command:
[root@s]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdc 8:32 0 953.9G 0 disk
├─sdc1 8:33 0 10G 0 part /boot
└─sdc2 8:34 0 943.9G 0 part
├─centos-root 253:0 0 600G 0 lvm /
├─centos-swap 253:1 0 50G 0 lvm [SWAP]
└─centos-home 253:2 0 782.9G 0 lvm /home
sdd 8:48 0 489.1G 0 disk
└─sdd1 8:49 0 489G 0 part
└─centos-home 253:2 0 782.9G 0 lvm /home
sde 8:64 0 279.5G 0 disk
sdf 8:80 0 50G 0 disk /disk-50gb
sr0 11:0 1 1024M 0 rom
sr1 11:1 1 1024M 0 rom
In order for our disk to load permanently on each restart of our system, we edit (fstab) and add the following line to the end of the content (/dev/sdf /disk-50gb ext3 defaults 0 0).
nano /etc/fstab
#
# /etc/fstab
# Created by anaconda on Sat Mar 14 19:14:11 2015
#
# 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
#
/dev/sdf /disk-50gb ext3 defaults 0 0
To unmount the same disk drive we could do it with the following command:
# unmount /dev/sdf /disk-50gb
We could also unmount a disk drive in the following way:
# unmount /dev/sdf