编程知识 cdmana.com

ECS practice case: operation guidance for creating and expanding logical volume

Abstract : Cross hard disk usage , On top of the traditional hard disk , In the cloud server, we can achieve cross EVS Use , In some scenarios, users need to create logical volumes or expand existing logical volumes , Or in some cases, the above operation fails due to misoperation .

【 Background description 】:

Cross hard disk usage , On top of the traditional hard disk , In the cloud server, we can achieve cross EVS Use , In some scenarios, users need to create logical volumes or expand existing logical volumes , Or in some cases, the above operation fails due to misoperation .

【 Operation Overview 】:

The whole process of creating logical volume : Create a physical volume → Create a volume group → Create logical volumes → Set up a file system → Create mount point → Mount file system → Set up auto mount after power on

The whole process of expanding logical volume : Expansion volume group ( Expand idle volume groups into volume groups )→ Expand logical volumes → Expand the file system

【 Operation steps 】:

Operation 1 : Create logical volumes

(1) adopt fdisk –l Command to view all physical volumes

The partition of the data disk mounted above has created a file system , At the same time, the file system is mounted . The physical volume creation command fails directly , The file system needs to be unloaded , At the same time, in the process of creating logical volume , There will be operations to delete the file system .

(2) Create a volume group

【 Be careful 】 The premise is that the partition cannot have a file system , You can't mount it at the same time

pvcreate /dev/vdb1 /dev/vdc1  perhaps  pvcreate /dev/vd[b,c]1( wildcard )

Because the disk has established a file system before , So you need to clean up the file system

If the echo command does not exist , adopt yum install lvm2 Command to download the installation tool

(3) adopt pvs View physical volumes

(4) adopt vgcreate vg1 /dev/vdb1 /dev/vdc1 Command to create a volume group

【 Be careful 】 One pv You can't join two vg

(5) adopt lvcreate -L 100M -n lv1 vg1 Command to create a logical volume

The content in the red box is the size of the newly created logical volume 、 Name and create in that volume group

(6) Create mount point

# mkdir /mnt/test

(7) Set up a file system

# mkfs.ext4 /dev/vg1/lv1

(8) Mount file system ( Can be in /etc/fstab Set auto mount when power on )

# mount /dev/vg1/lv1 /mnt/test

Operation two : Expand logical volumes

(1) Expansion volume group :vgextend vg1 /dev/vdd1

At this time, the logical volume has not been expanded

(2) Expand logical volume :lvextend –L +20G /dev/vg1/lv1

At this point, the file system has not expanded

(3) Expanding the file system

about ext4 file system , The order is :resize2fs /dev/vg1/lv1

If /dev/vg1/lv1 File system text of xfs, The order is :xfs_growfs /dev/vg1/lv1

This article is shared from Huawei cloud community 《【ECS】 Operation guide for creating and expanding logical volume 》, Original author : Cloud technology Porter .

 

Click to follow , The first time to learn about Huawei's new cloud technology ~

版权声明
本文为[Huawei cloud developer community]所创,转载请带上原文链接,感谢
https://cdmana.com/2020/12/20201224103553607u.html

Scroll to Top