Linux Commands

Working With Vgextend Linux Command

Working with Logical Volume Management (LVM) in Linux gives the users the flexibility to create and work with partitions. You can easily create, modify, resize, and delete various storage volumes.

You can easily resize a volume group by extending it with a physical volume using the vgextend command. The command is simple, and you only need to add the physical volume as an argument when using the vgextend command.

If you haven’t worked with volume groups or are looking for a safe way of extending your volume group, we will cover a practical example in this guide. Let’s get started.

What Is LVM?

LVM is a Linux system responsible for managing file systems and logical volumes in a Linux system. Although there are other volume management tools in Linux, using LVM is recommended for its advanced features. As we will see in this guide, there is so much that you can achieve using this command line tool.

To better understand how to use the vgextend command, we will create two physical volumes and a volume group. Once completed, we will use the vgextend to add one physical volume to the volume group of the other physical volume.

Creating Physical Volumes

Start by checking if any physical volumes are already created using the following command:

$ sudo pvs

We currently have no physical volume. We need a block device to initialize the physical volume. We can list the block devices using the following command:

$ sudo lvmdiskscan

Since we need to create two physical volumes, we will use the /dev/sda1 and /dev/sdb1. But before that, we must unmount the block devices.

To unmount a block device, use the following commands and replace the block device to match your case:

$ sudo umount /dev/sda1

$ sudo umount /dev/sdb1

With our block devices unmounted, we can proceed to use the pvcreate command to initialize the physical volumes.

To create two physical volumes, the following command will be:

$ sudo pvcreate /dev/sda1

$ sudo pvcreate /dev/sdb1

We successfully created our physical volumes and can confirm by using the pvs command.

Creating Volume Groups

We need a physical volume to create a volume group. Let’s start by verifying that we have no volume group in either of the physical volumes using the following command:

$ sudo vgs

We can now proceed to create a volume group for one of the physical volumes, which we will extend its size by adding the other physical volume to it. So, to create a volume group for /dev/sdb1, the following command will be:

$ sudo vgcreate volgroup1 /dev/sdb1

We named our volume group volgroup. We can verify it using the vgs command.

To get more details about the created volume group, use the following command:

$ vgdisplay volgroup1

What we need to focus on is the Free PE size for the volume group. We currently have 1919 Free PE. To extend this size, we can use the vgextend command and add the name of our other physical volume, /dev/sda1, as an argument.

The following command would be:

$ vgextend volgroup1 /dev/sda1

You should get a success message like the one in the previous illustration confirming that the volume group is successfully extended. We can verify the new size as shown in the following:

Bingo! You can note our new free PE size extended from 1919 to 2046. That’s how you can easily use the vgextend Linux command to expand the size of your volume groups by adding a physical volume.


Working with LVM allows you to create partitions and logical volumes and extend them whenever needed. Various Linux commands come in handy when working with LVM. In this guide, we discussed most of the commands for creating physical volumes and volume groups. Our main focus is extending the size of volume groups using the vgextend command. You now understand how to use the vgextend command in Linux.

About the author

Denis Kariuki

Denis is a Computer Scientist with a passion for Networking and Cyber Security. I love the terminal, and using Linux is a hobby. I am passionate about sharing tips and ideas about Linux and computing.