This brief tutorial shows students and new users how to use Linux Logical Volume Management (LVM) to create a volume group from your physical volumes.
When it comes creating volume groups from multiple hard disk drives, Volume Group (VG) is the key to that process.
VG is the architecture that allows you to combine multiple physical volumes to create a single storage structure, that is equal to the storage capacity of the combined physical devices.
The physical volume devices are initialized using LVM.
For example, if you take two physical 1GB hard drive disks and combine them to create a volume, you’ll end up with 2GB storage capacity, representing the two disks.
For students or new users looking for a Linux system to learn on, the easiest place to start is Ubuntu Linux OS. It’s a great Linux operating system for beginners.
Ubuntu is an open source Linux operating systems that runs on desktops, laptops, server and other device.
While learning Ubuntu, you will find that Linux isn’t so different than Windows and other operating systems in so many ways, especially when it comes to using the system to get work done.
To get started with creating logical volumes on Ubuntu, follow the steps below:
Step 1: Install LVM2 Package
In order to create logical volume groups by combining multiple disks, you must first install LVM2 package. By default, it doesn’t come installed in Ubuntu.
To install, run the commands below:
sudo apt update
sudo apt install lvm2
That should install LVM2 package on Ubuntu
Step 2: Create a Logical Volume Group
Now that you’ve install LVM2 package, continue below to creating your first logical volume group.
First list the physical drives on the machine. You can do that by running the commands below:
sudo pvs -a
The command above will list all the disks available on the system. A similar screen below should appear on your console.
PV VG Fmt Attr PSize PFree
/dev/loop0 --- 0 0
/dev/loop1 --- 0 0
/dev/loop2 --- 0 0
/dev/loop3 --- 0 0
/dev/loop4 --- 0 0
/dev/loop5 --- 0 0
/dev/loop7 --- 0 0
/dev/sda1 --- 0 0
/dev/sdb --- 0 0
/dev/sdc --- 0 0
For this tutorial, we’re going to be combing /dev/sdb and /dev/sdc and we’re going to called our logical volume group LVMSDBSDCBlk using the vgcreate command.
To do that, run the commands below:
sudo vgcreate LVMSDBSDCBlk /dev/sdb /dev/sdc
After running the commands above, you should get a success message similar to the one below:
Physical volume "/dev/sdb" successfully created. Physical volume "/dev/sdc" successfully created. Volume group "LVMSDBSDCBlk" successfully created
After creating the volume group, you can list it using the command below:
sudo pvs
It should then list the newly created volume group similar to the one below:
PV VG Fmt Attr PSize PFree /dev/sdb LVMSDBSDCBlk lvm2 a-- 1020.00m 1020.00m /dev/sdc LVMSDBSDCBlk lvm2 a-- 1020.00m 1020.00m
That’s it!
Conclusion:
You have learned how to create a logical volume group on Ubuntu using the LVM2 command. In order to create logical volumes, you’ll need to us the lvcreate command.
We’ll explore how to create new volumes from the group we created above using the lvcreate command.
Until then, enjoy!
You may also like the post below: