Complete steps for mounting a new data disk in CentOS7

Complete steps for mounting a new data disk in CentOS7

Preface

I just bought a new VPS. The data disk of the new VPS is not mounted to the system by default, so we need to mount it ourselves. When we add a new hard disk to the server, we need to perform a mounting operation. This article briefly records the mounting operation process.

View Hard Drive Information

First, we use the command df -TH to view the current system mount status:

We can see that there is no new data disk mounted, and the data disk is over 200G.

Then use the command fdisk -l to view the hard disk information.

You can see that there are two hard disks /dev/xvda and /dev/xvde. xvda is the system disk, and xvde is our newly added data disk. That is to say, the system found the newly added data disk /dev/xvde, but did not mount it. Note that sometimes the newly added data disk is not called xvde, it may be called xvdb.

Execute the mount command

1. Execute the command fdisk /dev/xvde to enter the fdisk mode and start partitioning the newly added data disk.

In the displayed information, enter n and press Enter. Press Enter for all subsequent operations to accept the default settings. The information displayed by pressing Enter at the end of the above picture tells us that a 200G hard disk partition has been created.

2. Next, enter p and press Enter to view the detailed information of the newly created partition.

As shown above, enter w to save and write the partition results into the partition table.

If the following information is displayed, the partition is successful:

The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3. Execute the partprobe command to synchronize the new partition table changes to the operating system.

4. Execute the following command to set the file system of the newly created partition to the format required by the system.

mkfs -t ext4 /dev/xvde1

5. Mount the newly created partition to the /mnt/datadisk mount point. /mnt/datadisk is a newly created mount point in our system, that is, a directory. If the directory does not exist, you must create it in advance. You can define the mount directory yourself.

mount /dev/xvde1 /mnt/datadisk

6. Use the command df -Th to check the disk mounting status.

The above figure shows that the new disk /dev/xvde1 has been successfully mounted to /mnt/datadisk.

Automatically mount at boot

The mounted disk needs to be set to automatically mount at boot time. We do not use the method of directly specifying /dev/xvde1 in /etc/fstab, but recommend using UUID to configure automatic mounting of data disks.

First execute the command blkid /dev/xvde1 to query the UUID of the disk partition:

/dev/xvde1: UUID="1d4e1d9d-d15c-1273-8442-2303b05b96ad" TYPE="ext4"

Then edit /etc/fstab and add a line at the end:

UUID=1d4e1d9d-d15c-1273-8442-2303b05b96ad /mnt/datadisk ext4 defaults 1 1

Just replace the UUID and directory with your own.

Finally, restart the machine and use df -TH to check the mount status. If you can see the newly added disk mount information, you are done.

Summarize

The above is the full content of this article. I hope that the content of this article will have certain reference learning value for your study or work. Thank you for your support of 123WORDPRESS.COM.

You may also be interested in:
  • How to mount disk in centos7 cloud host system
  • Centos7 hard disk mounting method
  • Centos7 installation and configuration of NFS service and mounting tutorial (recommended)
  • Learn how to mount Centos7 soft raid5
  • Detailed explanation of the mount command in Centos to mount the windows7 shared directory
  • Detailed explanation of CentOS Alibaba Cloud server hard disk partition and mounting
  • How to mount a new data disk on Alibaba Cloud CentOS
  • Tutorial on mounting SSD cloud disk on Alibaba Cloud CentOS 7 system
  • How to mount a data disk on Tencent Cloud Server Centos

<<:  Implementing a web calculator based on JavaScript

>>:  Common operation commands of MySQL in Linux system

Recommend

Detailed explanation of how to install PHP7 on Linux

How to install PHP7 on Linux? 1. Install dependen...

Detailed explanation of for loop and double for loop in JavaScript

for loop The for loop loops through the elements ...

HTML implements the function of detecting input completion

Use "onInput(event)" to detect whether ...

Complete example of Vue encapsulating the global toast component

Table of contents Preface 1. With vue-cli 1. Defi...

Node implements search box for fuzzy query

This article example shares the specific code for...

Detailed explanation of dynamic Christmas tree through JavaScript

Table of contents 1. Animated Christmas Tree Made...

Users need to know why

When I was in the securities company, because the ...

JS implements a simple counter

Use HTML CSS and JavaScript to implement a simple...

A few experiences in self-cultivation of artists

As the company's influence grows and its prod...

Use xshell to connect to the Linux server

Benefits of using xshell to connect to Linux We c...

In-depth analysis of MySQL indexes

Preface We know that index selection is the work ...

The difference between Vue interpolation expression and v-text directive

Table of contents 1. Use plugin expressions 2. Us...

Four practical tips for JavaScript string operations

Table of contents Preface 1. Split a string 2. JS...