In this HowTo, we’ll examine how to extend your CPBX5 LVM volumes.
By default, CPBX5 virtual images come with a small disk to keep the image file size minimal. After installation, you can either enlarge the existing disk or add a new one. In this HowTo, we will provide examples for both scenarios.
How to enlarge the existing disk
I’m using a virtual machine that has an 8GB hard disk at the moment. We can verify this with the fdisk command:
root@deb12:~# fdisk -l | grep Disk
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: VBOX HARDDISK
Disklabel type: dos
Disk identifier: 0xd30c1426
Disk /dev/mapper/deb12–vg-root: 6.56 GiB, 7046430720 bytes, 13762560 sectors
Disk /dev/mapper/deb12–vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectors
As you can see above there’s a single-volume group called “deb12” with two logical volumes (vg_root and vg_swap). The idea is to extend the size of vg_root so that we have more space to use. If you want to take a closer look at the partitions, then you need to use the df command:
root@deb12:~# df -lh | grep dev
Filesystem Size Used Avail Use% Mounted on
udev 458M 0 458M 0% /dev
/dev/mapper/deb12–vg-root 6.4G 3.3G 2.9G 54% /
/dev/sda1 455M 105M 325M 25% /boot
Here you can see that the vg_root logical volume is 6.4G and has 2.9G available. To increase the “physical” size of our disk, I will power off this machine and extend the size of the disk in VMWare to 10GB:
In order to do that, I will power off the machine, and extend the disk size

The disk was extended to 10G, the next step will be to power on the machine and check the disk again
root@deb12:~# fdisk -l | grep Disk
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX HARDDISK
Disklabel type: dos
Disk identifier: 0xd30c1426
Disk /dev/mapper/deb12–vg-root: 6.56 GiB, 7046430720 bytes, 13762560 sectors
Disk /dev/mapper/deb12–vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectors
Great! Our physical disk is now 10GB, but no changes were made to our physical volume and logical volumes. That’s something we have to do ourselves. The first thing to do is to create a new partition on the disk and tell LVM that it can be used as a physical volume. We do this with the fdisk command. I chose ‘n’ for the new partition, ‘p’ for primary, and ‘3’ for the partition number. Since I want to use the entire available space, I accepted the default values for the First and Last cylinders. Finally, I selected ‘w’ to save the changes.
root@deb12:~# fdisk /dev/sda
Welcome to fdisk (util-linux 2.38.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): p
Partition number (3,4, default 3): 3
First sector (16775168–20971519, default 16775168):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (16775168–20971519, default 20971519):
Created a new partition 3 of type ‘Linux‘ and of size 2 GiB.
Command (m for help): w
The partition table has been altered.
Syncing disks.
I just created a new primary partition on the hard disk and assigned all available free space to it. Take a look at the fdisk output:
root@deb12:~# fdisk -l
Disk /dev/sda: 10 GiB, 10737418240 bytes, 20971520 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd30c1426
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 16775167 15773698 7.5G 5 Extended
/dev/sda3 16775168 20971519 4196352 2G 83 Linux
/dev/sda5 1001472 16775167 15773696 7.5G 8e Linux LVM
Above, you can see the newly created /dev/sda3 Linux partition.
Now we can add it to our physical volume.
Use the pvs command to see the current state of the physical volume. Right now, only the /dev/sda5 partition is a physical volume:
root@deb12:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 deb12-vg lvm2 a– <7.52g 0
We’ll designate our /dev/sda3 partition as a physical volume (PV) using the pvcreate command:
root@deb12:~# pvcreate /dev/sda3
Physical volume “/dev/sda3” successfully created.
Run the pvs command again to see the results:
root@deb12:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 lvm2 — 2.00g 2.00g
/dev/sda5 deb12-vg lvm2 a– <7.52g 0
Our /dev/sda3 partition has been added as a physical volume. Now we can add it to the volume group. Use the vgdisplay command to check for the name of your volume group:
root@deb12:~# vgdisplay | grep Name
VG Name deb12-vg
Our /dev/sda3 partition has been added as a physical volume. Now we can add it to the volume group. Use the vgdisplay command to check for the name of your volume group:
root@deb12:~# vgextend deb12-vg /dev/sda3
Volume group “deb12-vg” successfully extended
The vgextend command adds it to the volume group, let’s look at the volume group again to see our changes:
root@deb12:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 deb12-vg lvm2 a— 2.00g 2.00g
/dev/sda5 deb12-vg lvm2 a–– <7.52g 0
Excellent…our volume group is now close to 10GB. We still have to assign this space to our logical volume. Let’s use lvdisplay to see the name of our logical volumes:
root@deb12:~# lvdisplay | grep Path
LV Path /dev/deb12-vg/root
LV Path /dev/deb12-vg/swap_1
I want to use all the free space from my volume group and add it to the root logical volume. We can use the lvextend command for this:
root@deb12:~# lvextend -l +100%FREE /dev/deb12-vg/root
Size of logical volume deb12-vg/root changed from 6.56 GiB (1680 extents) to 8.56 GiB (2192 extents).
Logical volume deb12-vg/root successfully resized.
There we go – lv_root is now almost 10GB. Let’s verify our work:
root@deb12:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root deb12-vg -wi-ao—- 8.56g
swap_1 deb12-vg -wi-ao—- 980.00m
We are almost done, but we still have to resize the actual filesystem. Otherwise, the operating system will still only be able to use 8GB. I’ll use resize2fs for this:
root@deb12:~# resize2fs /dev/deb12-vg/root
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/deb12-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/deb12-vg/root is now 2244608 (4k) blocks long.
This process can be done without rebooting. If everything goes well, you should now have more free space available:
root@deb12:~# df -lh | grep dev
udev 458M 0 458M 0% /dev
/dev/mapper/deb12–vg-root 8.4G 3.3G 4.7G 41% /
tmpfs 481M 0 481M 0% /dev/shm
/dev/sda1 455M 105M 325M 25% /boot
Great! Our operating system has more free space to use now. Hopefully, this lesson has been useful for you in expanding your logical volume(s) and perhaps understanding CPBX5 LVM a little bit more. If you have any questions feel free to contact Xorcom support!
How to add a disk to LVM
I’m using a virtual machine with an 8GB hard disk at the moment. We can verify this with the fdisk command:
root@deb12:~# fdisk -l | grep Disk
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: VBOX HARDDISK
Disklabel type: dos
Disk identifier: 0xd30c1426
Disk /dev/mapper/deb12–vg-root: 6.56 GiB, 7046430720 bytes, 13762560 sectors
Disk /dev/mapper/deb12–vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectors
As you can see above there’s a single-volume group called “deb12” with two logical volumes (vg_root and vg_swap). The idea is to extend the size of vg_root so that we have more space to use. If you want to take a closer look at the partitions, then you need to use the df command:
root@deb12:~# df -lh | grep dev
Filesystem Size Used Avail Use% Mounted on
udev 458M 0 458M 0% /dev
/dev/mapper/deb12–vg-root 6.4G 3.3G 2.9G 54% /
/dev/sda1 455M 105M 325M 25% /boot
Here you can see that the vg_root logical volume is 6.4G and has 2.9G available. To increase the “physical” size of our disk, I will power off this machine and add another disk of 2GB, in this example, I’m using VirtualBox:

An additional disk was added. The next step will be to power on the machine and check the disk again
root@deb12:~# fdisk -l | grep Disk
Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
Disk model: VBOX HARDDISK
Disklabel type: dos
Disk identifier: 0xd30c1426
Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 sectors
Disk model: VBOX HARDDISK
Disk /dev/mapper/deb12–vg-root: 6.56 GiB, 7046430720 bytes, 13762560 sectors
Disk /dev/mapper/deb12–vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectors
Great! We have another 2GB physical disk marked as /dev/sdb, but no changes were made to our physical volume and logical volumes. That’s something we have to do ourselves.
Now we can add it to our physical volume. Here’s what it looks like right now:
Use the pvs command to see the current state of the physical volume. Right now, only the /dev/sda5 partition is a physical volume
root@deb12:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 deb12-vg lvm2 a– <7.52g 0
We’ll tell LVM that our /dev/sda3 partition is a PV as well with the pvcreate command:
root@deb12:~# pvcreate /dev/sdb
Physical volume “/dev/sdab” successfully created.
Run the pvs command again to see the results:
root@deb12:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 — 2.00g 2.00g
/dev/sda5 deb12-vg lvm2 a– <7.52g 0
Our /dev/sda3 partition has been added as a physical volume. Now we can add it to the volume group. Use the vgdisplay command to check for the name of your volume group:
root@deb12:~# vgdisplay | grep Name
VG Name deb12-vg
In my example, it’s called “deb12-vg”. Let’s add the /dev/sda3 partition to this volume group:
root@deb12:~# vgextend deb12-vg /dev/sdb
Volume group “deb12-vg” successfully extended
The vgextend command adds it to the volume group, let’s look at the volume group again to see our changes:
root@deb12:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sdb deb12-vg lvm2 a— 2.00g 2.00g
/dev/sda5 deb12-vg lvm2 a— <7.52g 0
Excellent! Our volume group is now close to 10GB. We still have to assign this space to our logical volume. Let’s use lvdisplay to see the name of our logical volumes:
root@deb12:~# lvdisplay | grep Path
LV Path /dev/deb12-vg/root
LV Path /dev/deb12-vg/swap_1
I want to use all the free space from my volume group and add it to the root logical volume. We can use the lvextend command for this:
root@deb12:~# lvextend -l +100%FREE /dev/deb12-vg/root
Size of logical volume deb12-vg/root changed from 6.56 GiB (1680 extents) to 8.56 GiB (2192 extents).
Logical volume deb12-vg/root successfully resized.
There we go; lv_root is now almost 10GB. Let’s verify our work:
root@deb12:~# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root deb12-vg -wi-ao—- 8.56g
swap_1 deb12-vg -wi-ao—- 980.00m
We are almost done, but we still have to resize the actual filesystem. Otherwise your operating system can still only use 8GB. I’ll use resize2fs for this:
root@deb12:~# resize2fs /dev/deb12-vg/root
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/deb12-vg/root is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/deb12-vg/root is now 2244608 (4k) blocks long.
This process can be done without rebooting. If everything went OK, you now have more free space to use:
root@deb12:~# df -lh | grep dev
udev 458M 0 458M 0% /dev
/dev/mapper/deb12–vg-root 8.4G 3.3G 4.7G 41% /
tmpfs 481M 0 481M 0% /dev/shm
/dev/sda1 455M 105M 325M 25% /boot
Great! Our operating system has more free space to use now. Hopefully, this lesson has been useful for you to add a disk to your logical volume and perhaps to understand CPBX5 LVM a little bit more. If you have any questions feel free to contact Xorcom support!