How to Add New Disks Using LVM to an Existing Linux System

LVM (Logical Volume Management) is a flexible and advanced option available to manage hard disks in most of the major Linux distributions. It is easy to manage the disks with LVM than the tradition tools like fdisk, parted or gparted.

Some of the terms which you need to understand while using LVM:

  • Physical Volume (PV): Consists of Raw disks or RAID arrays or other storage devices.
  • Volume Group (VG): Combines the physical volumes into storage groups.
  • Logical Volume (LV): VG’s are divided into LV’s and are mounted as partitions.

In this article, we will take you through the steps to configure Disks using LVM in existing Linux machine by creating PV, VG’s and LV’s.

Note: If you don’t what to use LVM, you can add disk directly to an existing Linux system using these guides.

  1. How to Add a New Disk to Linux System
  2. How to Add a New Disk Larger Than 2TB to Linux System

Let’s consider a scenario where there are 2 HDD of 20GB and 10GB, but we need to add only 2 partitions one of 12GB and another 13GB. We can achieve this using LVM method only.

Once the disks has been added, you can list them using the following command.

# fdisk -l
Verify Hard Disks
Verify Hard Disks

1. Now partitions both the disks /dev/xvdc and /dev/xvdd using fdisk command as shown.

# fdisk /dev/xvdc
# fdisk /dev/xvdd

Use n to create the partition and save the changes with w command.

Partition Hark Disks
Partition Hark Disks

2. After partitioning, use the following command to verify the partitions.

# fdisk -l
Verify New Partitions
Verify New Partitions

3. Create Physical Volume (PV).

# pvcreate /dev/xvdc1
# pvcreate /dev/xvdd1
Create Physical Volume
Create Physical Volume

4. Create Volume Group (VG).

# vgcreate testvg /dev/xvdc1 /dev/xvdd1

Here, “testvg” is the VG name.

Create Volume Group
Create Volume Group

5. Now use “vgdisplay” to list all details about the VG’s in the system.

# vgdisplay
OR
# vgdisplay testvg
List Volume Group
List Volume Group

6. Create Logical Volumes (LV).

# lvcreate -n lv_data1 --size 12G testvg
# lvcreate -n lv_data2 --size 14G testvg

Here, “lv_data1” and “lv_data2” are LV name.

Create Logical Volumes
Create Logical Volumes

7. Now use “lvdisplay” to list all details about the Logical volumes available in the system.

# lvdisplay
OR
# lvdisplay testvg
List Logical Volumes
List Logical Volumes

8. Format the Logical Volums (LV’s) to ext4 format.

# mkfs.ext4 /dev/testvg/lv_data1
# mkfs.ext4/dev/testvg/lv_data2
Format LV to Ext4 Format
Format LV to Ext4 Format

9. Finally, mount the file system.

# mount /dev/testvg/lv_data1 /data1
# mount /dev/testvg/lv_data2 /data2

Make sure to create data1 and data2 directories before mounting the filesystem.

Mount Filesystem
Mount Filesystem

That’s it! In this article, we discussed how to create a partition using LVM. If you have any comments or queries regarding this, feel free to post in the comments.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Lakshmi Dhandapani
I work on various platforms including IBM-AIX, Solaris, HP-UX, and storage technologies ONTAP and OneFS and have hands on experience on Oracle Database.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

9 thoughts on “How to Add New Disks Using LVM to an Existing Linux System”

  1. Why would you people create partitions? The WHOLE point of lvm is to replace traditional partitions with something more flexible. On a physical disk, it’s just a redundancy, but in the virtual world, you are just creating a partition prison for your data that you cannot easily expand.

    If you pvcreate on the raw device instead of a partition, should that raw device ever change sizes (as in growing a virtual disk), it is trivial to expand it to use the space. With a partition, it’s a huge problem.

    There is no benefit to a partition, other than for admins who still use fdisk instead of lsblk to see disk volumes. The ONLY place you need a partition is for your boot volume, as that is a limitation of traditional hardware.

    Reply
  2. I was taught that the hard drive naming convention in Linux is ‘/dev/hdx#‘ or ‘/dev/sdx#‘. In the article, you are using ‘xvdc‘ and ‘xvdd‘.

    # fdisk /dev/xvdc
    # fdisk /dev/xvdd
    

    Have I been misinformed?

    Reply
  3. Can just a single partition be part of a logical device? I have a Win10 notebook. The Win10 requirements occupy most of the space on sda. Can I set up a small Linux partition on sda that connects with a physical USB disk I keep plugged into the machine to make up a logical disk for Linux? My Win install is MBR, non-UEFI, not secure boot, but would that make any difference?

    Reply
  4. Hi nice article. I noticed that you did’t change the partition type to lv i.e. 8e but created a 83 type. I thought we needed to create a 8e type partition to be able to create a physical volume or is this distro specific.

    Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.