[linux] Physical disk mounting directory - (partitioning, formatting, automatic mounting after restart)

Hello everyone, I am a studious junior fellow student!

There is a new physical disk that needs to be mounted to a certain directory. The steps are as follows. 

Table of contents

          1. Disk partition

 2. Disk formatting

 3. Disk mounting

 4. Restart automatic mounting


important point:

1. The directory must exist. If it does not exist, it needs to be created manually with mkdir.

2. The directory needs to be a blank empty directory. If there is content in the directory, the original file content will be overwritten.

1. Disk partition

1. The disk needs to be partitioned first. Even if the entire capacity of a disk is mounted to a directory, it still needs to be partitioned first.

Select the corresponding command according to the disk size. If a disk is larger than 2T, use the parted command to partition; if a disk is less than or equal to 2T, use fdisk to partition.

fdisk -l 
#先用上面的命令,来查看你需要挂载的磁盘容量大小

 As you can see here, our disk capacity is less than 2T, so we just use the fdisk command.

fdisk  /dev/sdf
#使用上面的命令进行分区,后面的路径是你所需要进行分区的磁盘路径

After using the command, you will see the picture below. In the first step, select n to create a partition; in the second step, select p to create a primary partition.

If you want to use all the disk capacity for one directory, after completing these two steps, you can keep pressing Enter on the keyboard (press until all printed contents are repeated to stop), and then enter w, Exit partition operation

 If you want to create multiple partitions, after completing the above two steps, he will display a partition number (1-4): let you choose which partition number (1 is the first partition, 2 is the second partition Partition...), generally 4 primary partitions can be created. We usually do it in order, here we choose 1.

Note: After selecting the partition number, there will be two places below that you need to enter, the starting point of the partition and the increased size . Here we only need to fill in the increased size and that's it. Just press the Enter key at the beginning. Just press it once, don't press it more.

Increase the size according to actual needs  

Template: + Number size ( M, G, T units)

 Complete steps

 2. Disk formatting

mkfs.xfs -f /dev/sdc1
#这边我选择的文件系统格式是xfs格式,-f是强制性覆盖
#如果你有两个分区,那就再来一个mkfs.xfs -f /dev/sdc2    就完事了

3. Disk mounting

mount /dev/sdc1 /data01

#/data01为已存在的空目录

4. Restart automatic mounting

First check the format of the disk with df -T to see if it is xfs.

The second step is to add the path and mounting directory to the configuration file; fill it in according to the content in the file and you are done. After filling in, save and exit

vim /etc/fstab
#去这里面添加磁盘路径和挂载目录即可


It’s not easy for newcomers to create. If you think it’s good, please give it a thumbs up! ! !

Please indicate the source when reprinting!

                                                            

Guess you like

Origin blog.csdn.net/weixin_43784564/article/details/128034564