How to create LVM Disk on Ubuntu 17.04

April 28, 2017 | By | Reply More

LVM (Logical Volume Management) is a great system to manage local volumes, filesystems. It comes with many modern features you need, much better than traditional disk partitioning systems. On this tutorial, I am going to show you how I manage my Ubuntu 17.04 with LVM. I choose LVM partitioning during initial Ubuntu 17.04 installation. For the Ubuntu official wiki about LVM, please visit this page: https://wiki.ubuntu.com/Lvm.

In LVM, we will manage the following three items:

  • Volume Group (VG)
  • Physical Volume (PV)
  • Logical Volume (LV)

First we need to display current LVM that exist on our Ubuntu 17.04. This command below will display information about current LVM volumes.

Output:

On the example above, I am currently have 1 active LVM physical volume and I have another 2 disks which can be used to extend this current Volume Group or create a new one.

Display existing Volume Group

Output:

As you can see, my current VG name is: pydio-vg and it size would be: 10.0 GB.

Display Existing Physical Volume

Use this command to display the physical volume on the system

Output:

Current Volume Group has only 1 physical volume which is /dev/vda1.

Display Existing Logical Volume

To display current Logical Volume, use lvdisplay command as follow

Example:

OK now we have any information we need. We are going to create a new LVM volume. First, we need to create a physical volume.

Create new Physical Volume

From the lvmdiskscan command, we can see that there are two disks that currently not used (/dev/vdb). I want to create a new physical volume using /dev/vdb. The following command will use the whole /dev/vdb disk as a new physical volume.

Output:

Make sure that the new physical volume is listed using pvdisplay command

Please notice that the /dev/vdb is now listed in new Physical Volume.

Create New Volume Group

Now we can create a new Volume Group (VG) using the newly created PV from the step before.

The command will create a new VG called gamblisfx-vg which contains /dev/vdb device.

Output:

Check the new VG

Output:

OK now basically I have two vg’s in my Ubuntu system. The first one was created during Ubuntu installation (pydio-vg) and the second one (gamblisfx-vg) is the one we’ve just created.

Create a new Logical Volume 

Now we have a new Volume Group so next we can create a new LV. For example I want to create a new LV with 5GB in size.

Output:

Check using lvdisplay command

As you can see, my new LV called lv01 is listed and now I can use it for other purposes, format it, mount it to store data etc.

Tags: , ,

Category: Ubuntu

Leave a Reply