Overview
The Logical Volume Manager (LVM) provides tools to create virtual block devices from physical devices. Virtual devices may be easier to manage than physical devices and can have capabilities beyond what the physical devices provide themselves. A Volume Group (VG) is a collection of one or more physical devices, each called a Physical Volume (PV). A Logical Volume (LV) is a virtual block device that can be used by the system or applications. Each block of data in an LV is stored on one or more PV in the VG, according to algorithms implemented by Device Mapper (DM) in the kernel. – man page.
1. Check the details about mount point
1.1. Check the mount point,
[root@hostname ~]# df -h/dev/mapper/vg_u01–lv_u01 256G 9.2G 247G 4% /u01
I want to increase the size of /u01 to 3.5TB. This directory relies on the vg_u01 volume group and lv_u01 logical volume.
1.2. So, Need to check the logical volume of this mount point,
[root@hostname ~]# lvslv_u01 vg_u01 -wi-ao—- <256.00g
1.3. Now, Need to check the volume group of this mount point,
[root@hostname ~]# vgsvg_u01 1 1 0 wz–n- <256.00g 0
1.4. Now, Need to check the physical volume of this mount point,
[root@hostname ~]# pvs/dev/sdb1 vg_u01 lvm2 a– <256.00g 0
So, disk sdb is assigned to volume group vg_u01 and this volume group assign to logical volume lv_u01 finally it is mounted to /u02 directory. So, the above things are in a pictorial view. There is no free space on this disk to extend its toper. So, we need to add extra disks.
2. Add physical or logical Disk to server
2.1. Check how many disks are there on the server,
[root@hostname~]# fdisk -l | grep /dev/sd | sort -hDisk /dev/sdb: 256 GiB, 274877906944 bytes, 536870912 sectors
/dev/sdb1 2048 536870911 536868864 256G 8e Linux LVM
Disk /dev/sda: 128 GiB, 137438953472 bytes, 268435456 sectors
/dev/sda1 2048 2099199 2097152 1G EFI System
/dev/sda2 2099200 4196351 2097152 1G Linux filesystem
/dev/sda3 4196352 268433407 264237056 126G Linux LVM
In my case, I have two disks (sda and sdb) attached and already used. Disk sdb is mounted to /u01.
2.2. Attach the adequate disk to the server. I attached 3 disks to fulfill my purpose.
[root@hostname~]# fdisk -l | grep /dev/sd | sort -hDisk /dev/sdc: 1.1 TiB, 1209462790144 bytes, 2362232012 sectors
Disk /dev/sdd: 1.1 TiB, 1209462790144 bytes, 2362232012 sectors
Disk /dev/sde: 1.1 TiB, 1209462790144 bytes, 2362232012 sectors
My new attached three disks are sdc, sdd snd sde all are 1.1 TB in size.
3. Disk Partition
3.1. Partition these three disks with LVM type,
[root@hostname~]# fdisk /dev/sdcenter -> press n -> enter -> enter -> enter -> enter -> enter -> press t -> enter -> press 8e -> enter -> press p -> enter -> press w -> enter. Then run partprobe command.
Subsequently, do this for all disks. In my case, fdisk /dev/sdd and fdisk /dev/sde.
3.2. Now, check the formatted disk,
[root@hostname~]# fdisk -l | grep /dev/sd | sort -h[root@hostname ~]# fdisk -l | grep /dev/sd | sort -h
/dev/sda1 2048 2099199 2097152 1G EFI System
/dev/sda2 2099200 4196351 2097152 1G Linux filesystem
/dev/sda3 4196352 268433407 264237056 126G Linux LVM
/dev/sdb1 2048 536870911 536868864 256G 8e Linux LVM
/dev/sdc1 2048 2362232011 2362229964 1.1T 8e Linux LVM
/dev/sdd1 2048 2362232011 2362229964 1.1T 8e Linux LVM
/dev/sde1 2048 2362232011 2362229964 1.1T 8e Linux LVM
Disk /dev/sda: 128 GiB, 137438953472 bytes, 268435456 sectors
Disk /dev/sdb: 256 GiB, 274877906944 bytes, 536870912 sectors
Disk /dev/sdc: 1.1 TiB, 1209462790144 bytes, 2362232012 sectors
Disk /dev/sdd: 1.1 TiB, 1209462790144 bytes, 2362232012 sectors
Disk /dev/sde: 1.1 TiB, 1209462790144 bytes, 2362232012 sectors
In the partition name (e.g. sdc1) numeric number 1 is the partition number. We can create multiple partitions for a single disk. Such as there have three partitions sda1,sda2 and sda3 for disk sda.
4. Create Physical Volume
4.1. Create physical volume for these formatted disks,
[root@hostname~]# pvcreate /dev/sdc1 /dev/sdd1 /dev/sde14.2. Check the newly created physical volume,
[root@hostname ~]# pvs/dev/sdc1 lvm2 — <1.10t <1.10t
/dev/sdd1 lvm2 — <1.10t <1.10t
/dev/sde1 lvm2 — <1.10t <1.10t
5. Extend Volume Group
5.1. Now, to extend volume group vg_u01 attached these physical volumes to it.
[root@hostname ~]# vgextend vg_u01 /dev/sdc1 /dev/sdd1 /dev/sde15.2. Check the VG size,
[root@hostname ~]# vgsvg_u01 4 1 0 wz–n- <3.55t <3.30t
The New VG size is 3.55 TB and 3.30TB is free.
6. Extend Logical Volume
6.1. The LV lv_u01 is on top of the vg_u01 and its present size is 256GB. Now, to extend logical volume lv_u01 we need to attach the free space of vg_u01 to it.
to attach all free space of the VG,
[root@hostname ~]# lvextend -r -l +100%FREE /dev/vgname/lvnamee.g.
[root@hostname ~]# lvextend -r -l +100%FREE /dev/vg_u01/lv_u01Or, to add a particular amount of physical extent, In that case, the final size will be existing size + extents_number,
[root@hostname ~]# lvextend -r -l +extents_number /dev/vgname/lvnamee.g.
[root@hostname ~]# lvextend -r -l +865071 /dev/vg_u01/lv_u01Or, to add a particular amount of volume, In that case, the final size will be existing size + volume_size_in_unit,
[root@hostname ~]# lvextend -r -L +volume_size_in_unit /dev/vgname/lvnamee.g.
[root@hostname ~]# lvextend -r -L +3.3t /dev/vg_u01/lv_u016.2. Check LV size,
[root@hostname ~]# lvslv_u01 vg_u01 -wi-ao—- <3.55t
The LV size is perfectly extended to 3.55TB. It will also resize (-r) the file system,
6.3. Check the file system,
[root@hostname ~]# df -h/dev/mapper/vg_u01-lv_u01 3.6T 34G 3.6T 1% /u01
Done.
Comments
Post a Comment