Expand LVM vg after virtual disk expansion

Original link: https://blog.frytea.com/archives/763/

75

new space partition

When using the fdisk tool to allocate additional disk space to the LVM PV, you need to follow the steps below:

  1. Run the fdisk -l command to view information about the currently available disks and partitions in the system.
  2. Run fdisk /dev/sdX command (where sdX represents the disk to be resized) to edit the partition table for that disk.
  3. Use the command p to view the disk partition table and determine the partition number to be modified.
  4. Use the command n to create a new partition. Follow the prompts to enter information such as partition type, start and end locations. Note that the new partition must start at the same location as the existing LVM PV ends.
  5. Use the command t to change the type of the new partition. Select Type 8e to set it as the LVM partition type.
  6. Use the command w to write the new partition table to the disk and exit the fdisk tool.
  7. Run pvresize /dev/sdXn command (where sdXn is the newly created LVM PV partition device file name) to add the new partition to the existing LVM physical volume.

After completing the above steps, you can use the lvextend command to extend the size of the logical volume and the resize2fs command to resize the file system to reflect the new logical volume size.

extended vg

 # 查看vg vgs # 将物理卷添加到存储池vgextend <vg name> /dev/sdd

create lv

 # 类似这样创建lv lvcreate -L 10G -n lv_var_log vg0 mkfs.xfs /dev/mapper/vg0-lv_var_log

This article is transferred from: https://blog.frytea.com/archives/763/
This site is only for collection, and the copyright belongs to the original author.