Linux_centos system uses lvm root partition to expand capacity [detailed graphic explanation]

        When you use virtual machines and deploy too many services, you often run out of disks, and you don't want to delete the current virtual machines and reconfigure them.

        So today Xiaoli will write you a guide on how to expand the root partition.

Prerequisites

        Before installing the virtual machine, we have set up the logical volume LVM for the root partition by default, otherwise we have to configure LVM for the root partition ourselves.

        Authentication method:

1. Add disk

1. Shut down the virtual machine, add the disk manually, open [Settings] and click [Add]

 2. Select [Hard Disk] and click [Next]

3. By default, the [SCSI] disk type with the highest transfer rate is selected, and click [Next]

4. Select [Create a new virtual machine disk] and click [Next]

5. Please note next that you set the size of the added disk according to your actual needs. I set the size of 10G here. Select Settings [Single File] and click [Next]

6. Click [Finish]

L

 2. Partition the disk and set the disk type

1. Use the fdisk command to partition, follow the instructions in the picture, and don’t forget to use the w command to save.

2. Use partx /dev/sdb1, or partprobe to load the configured partition into the kernel

 3. Format the partition and set the partition type for your new key partition

 3. Expand the LVM capacity of the newly created partition

 1. Check the volume group information. In fact, we also checked it at the beginning. The volume name is cents. It currently has a disk size of 19.70G.

 2. Create a physical volume from the newly added disk

    authenticating:

3. Add the physical volume to the volume group of the root partition, which is the "centos" just found

         Verification: Now there are 29.70G, which is the 10G size we added

4. Expand LVM and allocate all disks to it

5. Expand the file system

         Final verification: My original size was 18G, but now it is 28G.

Guess you like

Origin blog.csdn.net/m0_68495664/article/details/132954022