Basic knowledge
centos7 mount disk - five steps
First explain the meaning of disk mount:
Mounting usually refers to assigning a drive letter to a disk partition (including virtualized disk partitions). Third-party software, such as disk partition management software, virtual disk software, etc., usually also comes with a mount function.
In layman's terms, it is said to divide a disk for Linux. Linux uses a directory to manage the drive letter, which is just the opposite of Windows: Windows uses the drive letter to manage the directory.
1. Query the added hard disk, use fdisk -l, the image below implies that it already exists (my document was added later, and the image below shows that there is already a mounted disk)
2. Hard disk partition. The newly added hard disk cannot be used by default, it needs to be partitioned and formatted before it can be used. Partitioning using the fdisk command
fdisk /dev/vdb
Enter n, p, 1, 2048, 1048575999, w respectively
The steps for partitioning are clearly identified in the diagram below. Both the partition number and the starting sector can directly enter and press the default.
3. After the partition is completed, format the hard disk. First use fdisk -l to view the created partition, and then use the mkfs command to format the created partition.
mkfs.ext4 /dev/vdb
4. After the format is completed, create a hard disk mount point, mount the partition that has just been formatted to the server, and then the mounted hard disk can be used. As you can see from the figure below, the new hard disk has been successfully mounted
mkdir /cdh
5. Set up automatic mounting at startup The newly created partition will not be automatically mounted at startup, and must be manually mounted every time the machine is restarted. To set the automatic mount at boot, you need to modify the /etc/fstab file, and add the red mark to the last line of the file.
/dev/vdb1 (disk partition) /data (mount directory) ext4 (file format) defaults 0 0
echo "/dev/vdb /cdh ext4 defaults 0 0" >> /etc/fstab
At this point, the disk mount is over.
Reboot and see if your disk is ok after booting. If df -h is ok and your disk is still there, it is ok
A better link is attached for reference:
https://blog.csdn.net/qq_38776582/article/details/97651213
———————————————
Copyright statement: This article is an original article by CSDN blogger "Alex_81D" and follows the CC 4.0 BY-SA copyright agreement. Please attach the original source link and this statement for reprinting.
Original link: https://blog.csdn.net/Alex_81D/article/details/105043847