The key steps for expanding LVM logical volumes are as follows: 1. First use vgdisplay to check whether there is any remaining space in the volume group; 2. Use lvextend to expand the logical volume, and you can specify the size or use all remaining space; 3. Execute resize2fs or xfs_growfs according to the file system type to update the file system capacity; 4. Finally, verify the expansion results through df -h and lvdisplay. The entire process does not require uninstalling the file system, but it must be operated strictly in sequence, especially the XFS file system is irreversible.
It is actually not difficult to expand the LVM logical volume, but many people are easily confused by commands and processes when they operate it for the first time. Simply put, as long as your volume group (VG) has room left, you can directly expand the logical volume (LV), and then adjust the file system size and you will be completed.
The following are a few key steps to explain how to do it.
Confirm whether there is space available for the volume group
Before you start, check whether there is free space in the volume group where the logical volume you are preparing to expand. You can use this command to view:
vgdisplay
Focus on the Free PE / Size
item. If the value is not 0, it means there is still room for use directly.
If there is no space available, you have to expand the volume group first, such as adding a new hard disk or expanding an existing physical volume. This part is not within the scope of this article.
Extended logical volume itself
After confirming that VG has room, the next step is to expand LV. Suppose you want to expand /dev/vg_name/lv_name
by 10GB, you can do this:
lvextend -L 10G /dev/vg_name/lv_name
You can also use percentages, such as using all the remaining space of VG:
lvextend -l 100%FREE /dev/vg_name/lv_name
Note: Here
-L
is the specified size,-l
is expanded according to the number of PEs. It is usually recommended to use-l 100%FREE
to save trouble, especially when you are not sure how much it can be expanded.
This step is just "expanding the disk", but the file system will not automatically recognize the added space.
Adjust the file system to identify new space
This is the easiest step to miss. If you are using the ext4 file system, execute:
resize2fs /dev/vg_name/lv_name
If it is an XFS file system, use:
xfs_growfs/mount point path
For example, if your logical volume is mounted in /data
, the command is:
xfs_growfs /data
Tips:
- No need to uninstall the file system, it can be expanded while running
- You must remember this step, otherwise the expansion will be like not doing it
Verification is successful
Finally, use these two commands to check the results:
df -h
See if the capacity displayed by the file system has increased.
Use again:
lvdisplay
Confirm that the logical volume size has also been updated.
Basically that's it. The whole process is not complicated, but the order cannot be wrong: first expand the LV, then adjust the file system. Reversing the order may cause problems, especially the XFS file system can only grow but not shrink.
The above is the detailed content of How to extend LVM logical volume. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

LVM, LogicalVolumeManger, is a logical volume management function provided by the Linux kernel. It is composed of kernel drivers and application layer tools. It creates a logical layer based on the hard disk partitions, which can be very flexible and very convenient to manage storage devices. . LVM uses the device-mapper function of the Linux kernel to virtualize the storage system (system partitions are independent of the underlying hardware). Through LVM, the storage space can be abstracted and virtual partitions can be established on it. Partitions can be expanded and reduced more easily. When adding or deleting partitions, there is no need to worry about not having enough contiguous space on a certain hard disk to avoid losing space for the one being used. disk

1. Introduction to LinuxLVM LinuxLogicalVolumeManager (LVM) is a tool for managing disks and storage space. It provides flexible storage management through volume groups and logical volumes. The core concepts of LVM include physical volumes, volume groups and logical volumes. Physical volume (PhysicalVolume, PV): A physical volume is a physical hard disk or partition, which is used by LVM to store data. LVM combines one or more physical volumes into volume groups. Volume Group (VG): A volume group is a logical storage unit composed of one or more physical volumes. Logical volumes are created on volume groups, and they can dynamically allocate and reclaim storage space. A system can contain multiple volume groups. logical volume (

Linux uses lvm. LVM refers to logical volume management, which is a mechanism for managing disk partitions in the Linux environment. LVM is a logical layer built on the hard disk and partitions to improve the flexibility of disk partition management. The biggest feature of LVM is that it can dynamically manage disks. Because the size of the logical volume can be dynamically adjusted without losing existing data; if a new hard disk is added, it will not change the existing upper logical volume. As a dynamic disk management mechanism, logical volume technology greatly improves the flexibility of disk management.

The lvm partition of Linux refers to "logical volume management". The full English name of lvm is "Logical Volume Manager", which is a mechanism for managing disk partitions in the Linux environment; LVM is a logic built on the hard disk and partitions. layer to improve the flexibility of disk partition management.

Linux uses lvm. LVM refers to logical volume management, which is a mechanism for managing disk partitions in the Linux environment. LVM is a logical layer built on the hard disk and partitions to improve the flexibility of disk partition management. The biggest feature of LVM is that it can dynamically manage disks. Because the size of the logical volume can be dynamically adjusted without losing existing data; if a new hard disk is added, it will not change the existing upper logical volume. As a dynamic disk management mechanism, logical volume technology greatly improves the flexibility of disk management. Introduction to LVM LVM is the abbreviation of Logical Volume Manager (LogicalVolumeManager). It is a method for managing disk partitions in the Linux environment.

LVM is the abbreviation of LogicalVolumeManager (Logical Volume Management), which is a mechanism for managing disk partitions in the Linux environment. LVM virtualizes one or more disk partitions (PV) into a volume group (VG), which is equivalent to a large hard disk, on which we can divide some logical volumes (LV). When the space in the volume group is insufficient, new disk partitions can be added. We can also allocate some space from the remaining space of the volume group for use by logical volumes that do not have enough space. The LVM model is as shown below: There is no need to restart to refresh the new hard disk file. First, use the cat command cat/proc/scsi/scsi to browse the Id:??What is the largest one? Then echo "scsiadd-

LVM (LogicalVolumeManagement) is a flexible storage management tool in Linux, which is easier to scale and manage than traditional partitions. It allows multiple physical disks to be combined into a volume group and create dynamically resized logical volumes from it, suitable for variable storage needs. For example, when a directory is insufficient, its capacity can be expanded directly from the volume group without repartitioning or restarting the system. In addition, LVM supports snapshot functionality, which can create instant copies of logical volumes for backup without interrupting service operation. Snapshots are thinly configured to take up extra space only when data changes, making them suitable for frequently updated databases or file systems. Finally, LVM also supports online resizing logical volume sizes, in conjunction with ext4 or

The key steps for expanding LVM logical volumes are as follows: 1. First use vgdisplay to check whether there is any remaining space in the volume group; 2. Use lvextend to expand the logical volume, and you can specify the size or use all remaining space; 3. Execute resize2fs or xfs_growfs according to the file system type to update the file system capacity; 4. Finally, verify the expansion results through df-h and lvdisplay. The entire process does not require uninstalling the file system, but it must be operated strictly in sequence, especially the XFS file system is irreversible.
