How to create LVM on Linux

Linux System Administrator

Create LVM on Linux

Logical Volume Manager(LVM) is a storage device management system for Linux.If the server needs more space create LVM and extend space. also, you can reduce space from the server using LVM. in this article we share how to configure LVM on Linux.

[root@web /]# fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes
64 heads, 32 sectors/track, 16384 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009c150

Device Boot Start End Blocks Id System
/dev/sda1 * 2 201 204800 83 Linux
/dev/sda2 10202 11201 1024000 82 Linux swap / Solaris
/dev/sda3 11202 16384 5307392 5 Extended
/dev/sda4 11203 13251 2098175+ 8e Linux LVM

Physical volume “/dev/sda4” successfully created
[root@mail1 /]# pvdisplay
“/dev/sda5” is a new physical volume of “2.00 GiB”
— NEW Physical volume —
PV Name /dev/sda5
VG Name
PV Size 2.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID iEg1B1-DPdw-g0JB-Ranc-j39J-0ICJ-qCr3fm

[root@web /]# vgcreate vg_01 /dev/sda4
Volume group “vg_01” successfully created
[root@mail1 /]# vgdisplay
— Volume group —
VG Name vg_01
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 2.00 GiB
PE Size 4.00 MiB
Total PE 511
Alloc PE / Size 0 / 0
Free PE / Size 511 / 2.00 GiB
VG UUID ZhnpN3-N8rU-MSet-4Ezd-plEL-HwSF-NKIVkH

[root@web ~]# lvcreate -L 1024 -n vol_var vg_01
Logical volume “vol_var” created.

[root@web ~]# lvdisplay
— Logical volume —
LV Path /dev/vg_01/vol_var
LV Name vol_var
VG Name vg_01
LV UUID 4dyitg-f4NJ-WiHK-7YlV-0bix-HjLq-YptNur
LV Write Access read/write
LV Creation host, time mail1.lqs.co.in, 2016-11-08 12:19:10 +0530
LV Status available
# open 0
LV Size 1.00 GiB
Current LE 256
Segments 1
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:0

[root@web ~]# mkfs.ext4 -m 0 /dev/vg_01/vol_var
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
65536 inodes, 262144 blocks
0 blocks (0.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=268435456
8 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376

Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 32 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

[root@web]# fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes
64 heads, 32 sectors/track, 16384 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0009c150

Device Boot Start End Blocks Id System
/dev/sda1 * 2 201 204800 83 Linux
/dev/sda2 10202 11201 1024000 82 Linux swap / Solaris
/dev/sda3 11202 16384 5307392 5 Extended
/dev/sda4 11203 13251 2098175+ 8e Linux LVM

Disk /dev/mapper/vg_01-vol_var: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

[root@web ~]# mount /dev/vg_01/vol_var /var/

1 thought on “How to create LVM on Linux

Leave a Reply

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