Under Linux LVM-based disk expansion disk size adjusted

Partition online expansion after adjusting the size of the disk under Linux, based on the premise LVM does not add new LV (hey obsessive-compulsive disorder and committed) is mainly used in:

  • SAN mount partition increased capacity after a corresponding increase in the capacity of the LUN system partition
  • Corresponding increase in the capacity of the system partition to increase disk capacity of the virtual machine

The disk is assumed to be adjusted / dev / sda, to install lvm CentOS, use the default partition, where the original system

  • PV: / dev / sda3
  • VG:/dev/centos-test
  • LV:/dev/centos-test/root和/dev/centos-test/swap

STEP1 partition size adjustment with parted

Run parted, enter the partition management mode

# parted

Use print all the hard disk size See adjustment (eg: after adjusting the maximum capacity is 21.5GB)

(parted) print all
...
Disk /dev/sda: 21.5GB
...

resizepart resize

(parted) resizepart
Partition number? 3 # 此处选择分区号(Number),即Flags为lvm标签的Number,这里是3
End? [15GB] 21.5GB # 此处输入新的结束位置,如21.5GB
...
(parted) quit

STEP3 scan the disk surface changes

# partprobe

LVM physical volume size adjustment STEP4

# pvresize /dev/sda3

/ Dev / sda3 capacity is needed is a physical volume corresponding to the volume group

STEP5 adjust LVM logical volume size

# lvresize -l +100%FREE /dev/centos-test/root

Description:
100% the FREE: use all the remaining free space
/ dev / centos-test / root : logical volume is created

STEP6 resize the file system

# resize2fs /dev/centos-test/root

If xfs file system is recommended to use the following command

# xfs_growfs /dev/centos-test/root

Guess you like

Origin blog.51cto.com/huanghai/2447827