Debian 13 Tutorial / Grow LVM and ext4: Verify PV, VG, LV and Filesystem Sizes
To increase ext4 space on LVM in Debian 13, you need to check the free space in the VG, expand the LV, and then also expand the file system. Just increasing the LV size does not immediately increase the available space shown by df, so check the capacity and existing files at each step separately.
Distinguish PV, VG, LV and Filesystem Capacity
LVM (Logical Volume Manager) pools storage and allocates logical volumes from that space. This Debian 13 lab uses lvm2 2.03.31 and one separately created 4 GiB disk. Preserve both the system disk and the 8 GiB ext4 data disk created earlier; neither is the target.
| Hierarchy | Meaning | This practice |
|---|---|---|
| PV, Physical Volume | The device initialized for LVM to manage space | The entire new 4GiB disk |
| VG, Volume Group | A pool that gathers PV space and allocates it to LVs | lf_vg23 |
| LV, Logical Volume | Logical block device allocated by VG | /dev/lf_vg23/data, initially 1 GiB |
| ext4 | File system that stores files inside the LV | Created on the initial 1 GiB LV, then grown |
A PV can be created on an entire disk or a partition. Here, since the entire new disk is used as a PV, a GPT partition is not created first. The pvcreate manual documents whole-device and partition PVs. Do not use this as an example of converting an existing ext4 partition into a PV.
This configuration is a simple linear LV on a single PV. The configuration itself, which manages the storage space, does not provide replicas or file backups in case of a disk failure. Expanding operational data requires pre-verified backups and a plan for each target.
Install LVM and Identify the Separate New Disk
sudo apt update
sudo apt install --no-install-recommends lvm2
sudo lvm version
sudo pvs
sudo vgs
sudo lvs
lsblk -b -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,SERIAL
Check and approve the packages and dependencies to install. In this environment, lvm2 and four dependencies were newly installed, and there were no existing PVs, VGs, or LVs. In an environment with other VGs, record their names and associated devices, and do not confuse them with the dedicated names used here.
Shut down the VM normally and confirm it is powered off. Attach a newly created 4 GiB VDI to an empty SATA port, then boot the VM. The creation and identification process is the same as new virtual disk addition procedure . Do not reuse or format the previous 8GiB disk. In the practice, the new disk was identified as /dev/sdc with the serial number VBd922d313-5552a22f.
sudo udevadm settle
ls -l /dev/disk/by-id/ata-VBOX_HARDDISK*
pv_disk=/dev/disk/by-id/ata-VBOX_HARDDISK_VBd922d313-5552a22f
expected_serial=VBd922d313-5552a22f
lsblk -b -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINTS,SERIAL "$pv_disk"
sudo wipefs --no-act "$pv_disk"
sudo vgs lf_vg23
ls -ld /mnt/lf-lvm23 /var/backups/lf-debian13-23
Adjust the path and serial number to match your own new disk values. The starting conditions are 4,294,967,296 bytes, no partition, no filesystem and mount, no signatures, no existing VG named lf_vg23 and no existing lab directories. No groups in vgs and no files in ls are the expected results at this stage. Do not judge a disk as empty just because the information says there is no signature; compare it with the new VDI creation record.
Re-examine the target in the same Bash session using the following function.
check_new_lvm_disk() {
test -b "$pv_disk" || return 1
test "$(lsblk -dnro TYPE "$pv_disk")" = disk || return 1
test "$(lsblk -dnro SERIAL "$pv_disk")" = "$expected_serial" || return 1
test "$(sudo blockdev --getsize64 "$pv_disk")" = 4294967296 || return 1
test "$(lsblk -nr -o NAME "$pv_disk" | wc -l)" = 1 || return 1
test -z "$(lsblk -nro FSTYPE,MOUNTPOINTS "$pv_disk" | tr -d '[:space:]')" || return 1
lvm_signature_types=$(sudo wipefs --no-act --noheadings --output TYPE "$pv_disk") || return 1
test -z "$lvm_signature_types" || return 1
}
check_new_lvm_disk && printf 'New LVM disk checks passed\n'
Do not proceed if the inspection fails or a query error occurs. This function is a supplementary check for the current size and new disk conditions. It does not substitute for the judgment that the existing storage structure can be initialized.
Create the Dedicated PV, VG and 1 GiB LV
pvcreate writes an LVM label and metadata to the selected device. Execute it only once on the confirmed new disk. Do not use the force initialization option, and if an error occurs at any stage, do not bypass it by executing subsequent commands separately.
check_new_lvm_disk &&
sudo pvcreate "$pv_disk" &&
sudo vgcreate lf_vg23 "$pv_disk" &&
sudo lvcreate -L 1G -n data lf_vg23
sudo pvs -o pv_name,vg_name,pv_size,pv_free
sudo vgs -o vg_name,vg_size,vg_free
sudo lvs -o lv_name,vg_name,lv_size,devices
Check if the PV belongs to lf_vg23 and if the data LV appears as 1.00g. vgcreate creates the group, and lvcreate allocates that space. The VG may not show the full 4GiB as available space due to metadata and allocation unit alignment.
lv_path=/dev/lf_vg23/data
sudo blockdev --getsize64 "$lv_path"
test "$(sudo blockdev --getsize64 "$lv_path")" = 1073741824 &&
sudo mkfs.ext4 -L lf-lvm23 "$lv_path"
sudo blkid "$lv_path"
sudo test ! -e /mnt/lf-lvm23 &&
sudo install -d -m 755 /mnt/lf-lvm23
sudo mount "$lv_path" /mnt/lf-lvm23
findmnt --mountpoint /mnt/lf-lvm23
sudo install -d -m 750 -o lfstudent -g lfstudent /mnt/lf-lvm23/work
The size of blockdev is expected to be 1,073,741,824 bytes. Run mkfs.ext4 only on the newly created LV. If it reports an unexpected existing filesystem, stop rather than forcing it. After verifying the actual ext4 mount, create a work folder for the user. /dev/mapper/lf_vg23-data and /dev/lf_vg23/data may appear as paths pointing to the same logical device.
Record the File and Capacity Before Growth
Create the file as the regular user lfstudent. If a different user was selected, also set the owner of the work folder to that user.
printf 'lvm-ext4-grow-lab\n' > /mnt/lf-lvm23/work/probe.txt
cat /mnt/lf-lvm23/work/probe.txt
sha256sum /mnt/lf-lvm23/work/probe.txt
df -B1 --output=source,size,used,avail,target /mnt/lf-lvm23
sudo vgs -o vg_name,vg_size,vg_free
sudo lvs -o lv_name,vg_name,lv_size,devices
df shows the capacity of mounted filesystems, lvs shows the size of logical volumes, and VFree of vgs shows the space available for allocation in the VG. Having free space in the root filesystem does not mean you can expand the LV of this VG. This time, check if there is enough VFree to allocate an additional 1GiB.
Store comparison file copies and LVM metadata outside the LV. Do not overwrite if the new backup path already exists.
sudo test ! -e /var/backups/lf-debian13-23 &&
sudo install -d -m 700 /var/backups/lf-debian13-23 &&
sudo cp -a /mnt/lf-lvm23/work/probe.txt /var/backups/lf-debian13-23/probe-before.txt &&
sha256sum /mnt/lf-lvm23/work/probe.txt | sudo tee /var/backups/lf-debian13-23/probe.sha256 > /dev/null &&
sudo vgcfgbackup -f /var/backups/lf-debian13-23/vg-before-grow.vg lf_vg23
vgcfgbackup stores VG configuration metadata and does not back up the contents of files within the LV. Here, small practice files were copied separately, but for actual services, backup and recovery verification considering the entire data and consistency are necessary.
Grow Only the LV to 2 GiB and Compare df
First, check the plan in test mode to ensure the actual size has not changed.
sudo lvextend --test -L 2G "$lv_path"
sudo blockdev --getsize64 "$lv_path"
sudo lvs -o lv_name,vg_name,lv_size
In test mode, the expected output may appear as if the expansion was successful, but it does not record metadata. At this stage, the LV should still be 1GiB. Do not judge expansion completion based solely on the test mode output.
sudo lvextend -L 2G "$lv_path"
sudo blockdev --getsize64 "$lv_path"
sudo lvs -o lv_name,vg_name,lv_size,devices
df -B1 --output=source,size,used,avail,target /mnt/lf-lvm23
sudo sha256sum -c /var/backups/lf-debian13-23/probe.sha256
The LV becomes 2,147,483,648 bytes · 2.00g, but the size in df is still the same as before expansion. Verify that the hash of existing files is OK as well. For this exercise, the option to resize the filesystem together with the LV was deliberately omitted to observe the difference between the two layers. lvextend documentation’s -L 2G is the new total size, and differs from specifying addition to the current size as in -L +1G. Repeated execution of the incremental command may increase it more than intended.
If the VG lacks free space, the requested additional space cannot be allocated. Do not blindly reduce or initialize other LVs; check the actual configuration and available space in pvs, vgs, and lvs. You need to distinguish between situations that require separate procedures to increase PV or VG capacity and situations where only the filesystem is still small on an already large LV.
Grow ext4 and Verify Usable Space
sudo resize2fs "$lv_path"
df -B1 --output=source,size,used,avail,target /mnt/lf-lvm23
sudo blockdev --getsize64 "$lv_path"
sudo blkid "$lv_path"
sudo sha256sum -c /var/backups/lf-debian13-23/probe.sha256
sudo cmp /mnt/lf-lvm23/work/probe.txt /var/backups/lf-debian13-23/probe-before.txt
In this environment, ext4 supported online growth while mounted, and resize2fs expanded the filesystem into the larger LV. The resize2fs manual describes the default size and support conditions. Do not apply this tool to other filesystems such as XFS or Btrfs.
| Actual observation steps | LV bytes | df -B1 Size bytes |
|---|---|---|
| Initial configuration | 1,073,741,824 | 1,020,702,720 |
| after lvextend | 2,147,483,648 | 1,020,702,720 |
| After resize2fs | 2,147,483,648 | 2,077,073,408 |
When checking with df, the values may not match the raw LV size due to file system metadata and other factors. Do not use the exact numbers in the table as fixed values for all ext4 environments; compare which layer's values have changed under the same conditions. In the practice exercise, the file system UUID was preserved, and the contents and hashes of existing files were the same.
To check whether additional space can be used, you can run the following preallocation as a normal user on this dedicated test file system. Do not create large files in the paths of actual services.
fallocate -l 1100M /mnt/lf-lvm23/work/after-grow.bin
stat -c '%s bytes' /mnt/lf-lvm23/work/after-grow.bin
du -B1 /mnt/lf-lvm23/work/after-grow.bin
rm -- /mnt/lf-lvm23/work/after-grow.bin
Confirm that file space allocation of 1,100 MiB, i.e., 1,153,433,600 bytes, is successful, and immediately delete only this test file. fallocate is a preallocation of file space and is not a performance test for writing all user data of this size. The logical size and the allocation calculated by du may differ slightly depending on metadata and file system characteristics.
Remount, Verify and Leave the Lab Unmounted
cd /
sudo umount /mnt/lf-lvm23
sudo mount /dev/lf_vg23/data /mnt/lf-lvm23
sudo sha256sum -c /var/backups/lf-debian13-23/probe.sha256
df -hT /mnt/lf-lvm23
sudo umount /mnt/lf-lvm23
sudo rmdir -- /mnt/lf-lvm23
sudo lvs -o lv_name,vg_name,lv_size,devices
lsblk -o NAME,SIZE,FSTYPE,LABEL,MOUNTPOINTS
After remounting, check that the files are the same and that the expanded size is maintained. The final state leaves PV, VG, a 2GiB LV, the file system, and files intact, with the filesystem unmounted. This practice did not change fstab. If automatic mounting is needed, apply separate verification and reboot checks for UUID and the fstab settings .
If you try to reduce the LV to 1GiB to cancel the expansion, the space used by the file system at the back may be cut, which can corrupt the data. Shrinking is an operation that requires a separate plan, including file system support, unmounting, checking, and shrinking, and it is not provided as a reversal command in this course. If you need to initialize the practice, compare and decide with the method of preparing a new dedicated storage again after verifying the backup of the necessary files. Simply restoring the LVM metadata backup will not safely return the enlarged file system and file contents to their previous size.




