Skip to main content

Extend Logical Volume (LV) Size in Linux

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 ~]# lvs

lv_u01 vg_u01 -wi-ao—- <256.00g

1.3. Now, Need to check the volume group of this mount point,

[root@hostname ~]# vgs

vg_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 -h

Disk /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 -h

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

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/sdc

enter -> press n -> enter -> enter -> enter -> enter -> enter -> press t -> enter -> press 8e -> enter -> press p -> enter -> press w -> enter. Then run partprobe command.

[root@hostname~]# partprobe

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/sde1

4.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/sde1

5.2. Check the VG size,

[root@hostname ~]# vgs

vg_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/lvname

e.g.

[root@hostname ~]# lvextend -r -l +100%FREE /dev/vg_u01/lv_u01

Or, 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/lvname

e.g.

[root@hostname ~]# lvextend -r -l +865071 /dev/vg_u01/lv_u01

Or, 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/lvname

e.g.

[root@hostname ~]# lvextend -r -L +3.3t /dev/vg_u01/lv_u01

6.2. Check LV size,

[root@hostname ~]# lvs

lv_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

Popular posts from this blog

Upgrading Issue for RHEL 7 to 8 With Leapp

Overview The Leapp utility is a framework for updating and upgrading operating systems as well as applications. The operations of this utility consist of two phases 1. the preupgrade Phase – that chack the upgrade possibilities and 2. the actual upgrade phase – that map packages between previous and current versions of the software packages. Issue – 01: After running ‘ sudo leapp preupgrade ‘ sometimes you find the below issue in ‘ /var/log/leapp/leapp-report.txt ‘. Detail: Risk Factor: high (inhibitor) Title: Leapp detected loaded kernel drivers which have been removed in RHEL 8. Upgrade cannot proceed. Summary: Support for the following RHEL 7 device drivers has been removed in RHEL 8: – pata_acpi Key: f08a07da902958defa4f5c2699fae9ec2eb67c5b Remediation: 1. Disable detected kernel drivers in order to proceed with the upgrade process using the rmmod or modprobe -r . rmmod – Simple program to remove a module from the Linux Kernel modprobe – Add and remove modules from the Linux Ke

Upgrading Oracle Linux 6 to 7

Overview It is possible to upgrade an Oracle Linux 6 system to Oracle Linux 7.6 under the following conditions: The system meets the minimum installation requirements for Oracle Linux 7 as described in Chapter 1, System Requirements and Limits. The Oracle Linux 6 system has been completely updated from the ol6_x86_64_latest channel or ol6_latest repository. UEK R3 or UEK R4 has been installed on the system to be upgraded and is the default boot kernel. Upgrading from UEK R2 is not supported. Note that the system is upgraded to use the UEK R5 release provided with Oracle Linux 7.6. Upgrading is supported only for systems that are installed with the Minimal Install base environment. If additional packages are installed from an alternative repository or channel, upgrade might fail or the resulting upgrade might not function as expected. reference: https://docs.oracle.com/en/operating-systems/oracle-linux/7/relnotes7.6/ol7-install.html#ol7-upgrade-ol6 Verifying the system before Upgrade: #

Software-only Installation of oracle Database 21c on RHEL 8

Overview Oracle Database 21c is a multi-model database that provides full support for relational and non-relational data, such as JSON, XML, text, spatial and graph data. There are lots of new features available in this new release like partitioned hybrid tables, encryption capabilities in the built-in data dictionary, statistics-only queries, and many more. It also enables Oracle's Autonomous Database Cloud Services. This article describes the installation of Oracle Database 21c 64-bit on Red Hat 8 64-bit. Lab Environment Particulars                                     Database Info --------------                                            ------------------------------------------------------- OS Release                                     Red Hat Enterprise Linux release 8.4 (Ootpa) Kernel                                              4.18.0-425.10.1.el8_7.x86_64 IP Address                                     1 92.168.0.10 Host Name                                  oemsrv User Na