How to Create Logical Volume (LVM) on Arch Linux

January 30, 2017 | By | Reply More

Logical Volume is a common way to manage multiple hard drives on Linux especially server. Using LVM, we can use multiple hard disks as one big space. We can easily add more disks to existing Volume Group to get more space without any downtime. So, LVM is an advanced way to manage disks and partitions on Linux system. Any Linux OS supports LVM including Arch Linux.

LVM (Logical Volume Management) on Arch Linux

On this tutorial, I will show you the following topics which you can expand to cover your own needs.

  1. Create Physical Volume
  2. Create Volume Group
  3. Create Logical Volume

First thing first is to backup all your data somewhere. This method could break your existing data and hard disk partitions, so backup is a must. On this tutorial, I am using two virtual disks with 5 GB and 10 GB in size. So lets get started.

A. Create Physical Volume

Open Terminal and login as root

Now we need to list all the connected hard drives on our Arch system.

Output:

[root@arch-pc ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 15G 0 part /
`-sda2 8:2 0 4G 0 part /home
sdb 8:16 0 5G 0 disk
sdc 8:32 0 10G 0 disk
sr0 11:0 1 1024M 0 rom

As you can see in red, I have two disks sdb and sdc. I will use the entire disks for LVM layout. The following command is used to create new physical volume with sdb and sdc.

Output:

[root@arch-pc ~]# pvcreate /dev/sdb /dev/sdc
Physical volume “/dev/sdb” successfully created.
Physical volume “/dev/sdc” successfully created.

Now lets check our new PV with this command

Output:

Verify that LVM has registered the new physical volume

Output:

PV VG Fmt Attr PSize PFree
/dev/sdb lvm2 — 5.00g 5.00g
/dev/sdc lvm2 — 10.00g 10.00g

B. Create Volume Group

We have successfully created a new physical volume on the previous step. Now, we need to create a new volume group. I will use TestVolGroup for my new volume group. We will add /dev/sdb and /dev/sdc to the new volume group.

Output:

Volume group “TestVolGroup” successfully created

Now check again using pvs command

Output:

Output:

C. Create Logical Volume

Now we have a new Volume Group called TestVolGroup with total size approximately 15 GB. Now we can start creating new Logical Volume with any size we want. For example we want to create two logical volumes with 2 GB in size for each logical volume. We will use lvcreate command to create new logical volume.

Output:

Now we can check our new logical volume with lvdisplay command

Output:

OK, now we have new logical volumes. We can now mount and format our new logical volume. Thank you for reading this post.

Tags: , ,

Category: Arch Linux

Leave a Reply

%d bloggers like this: