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

Resolving MySQL implicit conversion issues

1. Problem Description root@mysqldb 22:12: [xucl]...

About Generics of C++ TpeScript Series

Table of contents 1. Template 2. Generics 3. Gene...

How to deploy DoNetCore to Alibaba Cloud with Nginx

Basic environment configuration Please purchase t...

An example of the difference between the id and name attributes in input

I have been making websites for a long time, but I...

Using JS timer to move elements

Use JS timer to make an element to make a method ...

Summary of 50+ Utility Functions in JavaScript

JavaScript can do a lot of great things. This art...

How to locate MySQL slow queries

Preface I believe that everyone has had experienc...

Pure CSS to achieve cloudy weather icon effect

Effect The effect is as follows ​ Implementation ...

Installing Windows Server 2008 operating system on a virtual machine

This article introduces the installation of Windo...

How to implement Hover drop-down menu with CSS

As usual, today I will talk about a very practica...

Collection of 12 practical web online tools

1. Favicon.cc To create ico icon websites online,...

Detailed explanation of the difference between alt and title

These two attributes are often used, but their di...

WeChat applet calculator example

WeChat applet calculator example, for your refere...