Steps and operations for mounting a hard disk to the system on CentOS 7


This article introduces the detailed steps of mounting a hard disk to the system on CentOS 7. By determining the hard disk device name, creating a mounting directory, viewing the partition table, formatting the hard disk, mounting the hard disk to the target directory, checking the mounting status, and implementing automatic mounting at system startup, you can successfully mount the hard disk to CentOS 7. on the system.

To mount the hard disk to the system on CentOS 7, you can follow the following steps:

1: Query unmounted hard disk

First, determine the device name of the hard disk to be mounted. You can use lsblkthe command to view all hard drives and partitions on the server. Find the device name of the hard drive you want to mount, eg /dev/sdb.

 lsblk

Insert image description here

2: Create a mounting directory

Create a directory for mounting. You can optionally /mntcreate a new directory under the directory, for example /mnt/mydisk. Create the directory using the following command:

sudo mkdir /data

Insert image description here

3: Check whether the disk is partitioned

Use sudo fdisk -lthe command to view the hard disk partition table and make sure there are no partitions on the hard disk. If the hard disk has been partitioned, you need to use fdiskthe command to create the partition first.

sudo fdisk -l`

Function: Partitioning is the process of dividing a hard disk into different logical parts. Each partition has its own file system and can store data independently. Partitioning can help us better organize and manage the data on the hard disk so that it can be accessed and utilized more efficiently by the computer system. Through partitioning, we can store different types of data (such as operating system files, applications, personal files, etc.) in different partitions to improve data security and management flexibility.

4: Format the hard drive

  1. Use sudo mkfsthe command to format the hard drive. For example, if you want to format your hard drive with an ext4 file system, you can run the following command:
sudo mkfs -t ext4 /dev/vdb

Insert image description here

5: Mount directory

Use sudo mountthe command to mount the hard disk to the target directory. For example, to /dev/sdbmount the hard disk to /mnt/mydiskthe directory, you can run the following command:

sudo mount /dev/vdb /data

Insert image description here

6: Check the mounting status

Check whether the mount is successful. You can use df -hthe command to view the list of mounted file systems and confirm that the hard disk has been successfully mounted.

df -h

Insert image description here

7: Set up automatic mounting at startup

If you want to automatically mount the hard disk when the system starts, you need to add the mounting information to /etc/fstabthe file. Open the file and add the following line:

/dev/sdb   /mnt/mydisk   ext4   defaults   0   0

Operate it yourself if necessary

Summarize:

Mounting a hard drive to your system on CentOS 7 is a simple and effective process by following the specified steps. By determining the hard disk device name, creating a mounting directory, formatting the hard disk, mounting the hard disk to the target directory, and realizing automatic mounting when the system starts when needed, you can easily access and manage the contents of the hard disk.

Guess you like

Origin blog.csdn.net/qq_28245087/article/details/131976258