Under Centos7 (Linux), mount the data disk (new partition) to the specified directory; or merge the data disk to the root directory

888u

Last update at :2024-07-12,Edit by888u

Some VPS come with a data disk as a gift, or a data disk purchased separately. The following is to mount the data disk to the specified directory; or merge the data disk to the root directory. For the second and third parts below, just choose one.

In fact, it is not only applicable to Centos systems, but also other Linux systems.

1. Partition the new hard drive (data disk) (ignore the already partitioned ones)

1. Check whether it is mounted

df-h

If you don’t see the data disk, you haven’t mounted it

2. View partitions

fdisk -l

Usually /dev/vdb, whether it is a mounted data disk

3. Partition the data disk

fdisk /dev/vdb

Enter n, then default, finally enter w, and save.

4. Synchronize partitions to the system

partprobe

5. Format partition

mkfs -t ext4 /dev/vdb1

2. Mount the data disk to the specified directory

1. Mount to the specified directory

a. Create directory

mkdir /www

b. Mount to the /www directory

mount /dev/vdb1 /www

2. Mount at boot

vi /etc/fstab

Add a line at the end

/dev/vdb1 /www ext4 defaults 1 2

Finally, restart and see if it was successful.

3. Merge the data disk to the root directory

1. Create a physical volume First use lvdisplay to obtain the LV Path and VG Name.

pvcreate /dev/vdb1 vgextend centos /dev/vdb1

After the execution is completed, the message Volume group “VolGroup” successfully extended indicates that it is OK.

2. Check the remaining space

vgdisplay

View Free PE/Size.

3. Capacity expansion

lvresize -L +49.8G /dev/centos/root

/dev/centos/root is the LV Path obtained in step 4. Subtract 0.2G slightly from the integer and you won't go wrong.

Please use mount | grep root to check the format

resize2fs /dev/centos/root

Please use xfs format

xfs_growfs /dev/centos/root

Recommended site searches: Tianjin server rental, free mainland China space, jsp host, mainland China registration-free host, registered international domain name registered domain name query, registration-free cdn acceleration, domain name query network, forum registration, Hong Kong server rental 99idc,

Under Centos7 (Linux), mount the data disk (new partition) to the specified directory; or merge the data disk to the root directory

All copyrights belong to 888u unless special state
取消
微信二维码
微信二维码
支付宝二维码