Sharing Ilmu

Sharing for useful things

Creating LVM (Logical Volume Management) in Linux

In this tutorial, I’ll discuss about the manner of creating LVM disk in linux. LVM are used for volume management which make manage disk become easier. When you need to more space in a volume disk, you can be allocate to these logical volume and you can resize that space.

On the LVM concept you must configure some lvm config :

  • Physical Volume (PV) : Whole disk which are configure lvm system must be intialized to PV.
  • Volume Group (VG)  : Volume group is used for pools system for more PV disk.  the logical volume will be create from VG space.
  • Logical Volume (LV) : LV is used for storage which are used by operating system, aplication and etc.

In the following are configuration step on the VLM system.

Before that, I have added new disk on system and then check the new disk partition with lsblk command.  the new disk that has been added namely sdb.

 

Then, make the /dev/sdb partition with gpt  partition label.

# parted /dev/sdb mklabel gpt

check disk information with parted /dev/sdb print command.

 

Create new partition with 2GB size and named as primary

# parted /dev/sdb mkpart primary 1MiB 2049MiB

The new partition has been create, if you’re check in lsblk its named as sdb1.

Set LVM for /dev/sdb1 partition.

# parted /dev/sdb set 1 lvm on

Now create Physical Volume for /dev/sdb1 partition

# pvcreate /dev/sdb1

Show physical volume with pvdisplay command

 

Create new Volume group named test-vg and /dev/sdb1 include the storage pools of test-vg.

Show volume group with vgdisplay command

Create logical volume named mystorage with 2GB size on test-vg volume group.

 

Show logical volume with lvdisplay command

Make the mystorage lv as ex4 filesystem.

 

Then, Test create new directory and mount the mystorage volume to those directories.

# mkdir /mydata

# mount /dev/test-vg/mystorage /mydata

z

Leave a Reply

Your email address will not be published. Required fields are marked *.

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>