CentOS7 uses fdisk original hard disk to expand LVM type partition

In CentOS 7, you can use the fdisk command to expand the hard disk and operate on LVM type partitions. Here's a user-friendly step-by-step guide:

  1. First, use the fdisk command to view the current partition situation. Open a terminal and execute the following command as root user:

    fdisk -l

    This will list the partition information for the current hard drive.

  2. Find the hard disk to be expanded, and record its device name, such as /dev/sda.
  3. Execute the following command to start partitioning the hard drive:

    fdisk /dev/sda
  4. In the fdisk command line interface, enter  pto view the current partition table information.
  5. Select an existing partition to modify, or create a new partition according to the required expansion size. If you choose to modify an existing partition, enter the corresponding partition number (such as 1, 2, 3, etc.); if you choose to create a new partition, enter it  n.
  6. Follow the prompts to enter the starting location and size of the partition. For capacity expansion, you can choose to move the end position of the partition backward, or directly increase the size of the partition.
  7. Enter  tto change the partition type. The code to select the LVM type partition is  8e.
  8. Enter  pto view the updated partition table information to ensure that the modification takes effect.
  9. Enter  wsave and exit the fdisk command line interface. This will partition the hard drive.
  10. Reload the partition table so the operating system recognizes the new partition. Execute the following command:

    partprobe /dev/sda
  11. Use the pvresize command to expand the LVM physical volume of the expanded partition. For example, if you want to extend the /dev/sda1 partition, execute the following command:

    pvresize /dev/sda1
  12. Confirm whether the expansion of the physical volume is successful. Execute the following command:

    pvdisplay

    Check that "PSize" and "PFree" in the output reflect the partition expansion.

  13. If necessary, you can also use the lvextend command to extend the logical volume to take advantage of the newly added physical volume space.

Through the above steps, you can use the fdisk command to expand the hard disk and operate on LVM type partitions. Please note that partitioning a hard drive is a sensitive task and must be done with care, making sure to back up important data and understanding the risks and implications before proceeding.

Guess you like

Origin blog.csdn.net/tiansyun/article/details/132126880