Mir Sayeed Hassan – Oracle Blog

Oracle DBA – Tips & Techniques | Learn with real-time examples

  • Translate

  • It’s Me






  • My Certificates

  • Links

    My Acclaim Certification : Credly Profile
    My Oracle ACE Pro Profile

  • Achievements

    Awarded Top 100 Oracle Blogs from Worldwide - #RANK 39
  • VISITORS COUNT

  • Verified International Academic Qualification from World Education Service (WES)

    Verified International Academic Qualification from World Education Service (WES)

  • Jobs

How to extend/increase the size of a existing Linux LVM disk by adding a new disk

Posted by Mir Sayeed Hassan on February 3rd, 2021

How to extend/increase the size of a existing Linux LVM disk by adding a new disk

Detect the new disk space

[root@testdb ~]# echo "- - -" > /sys/class/scsi_host/host0/scan

New disk allocated to extend existing disk

[root@testdb ~]# fdisk -l

Disk /dev/sdf: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 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

Partition the new disk
[root@testdb ~]# fdisk /dev/sdf
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xdac6f363.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): p

Disk /dev/sdf: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 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: 0xdac6f363

Device Boot Start End Blocks Id System

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-39162, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-39162, default 39162):
Using default value 39162

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): p

Disk /dev/sdf: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 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: 0xdac6f363

Device Boot Start End Blocks Id System
/dev/sdf1 1 39162 314568733+ 8e Linux LVM

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Verify

[root@testdb ~]# fdisk -l

Disk /dev/sdf: 322.1 GB, 322122547200 bytes
255 heads, 63 sectors/track, 39162 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: 0xdac6f363

Device Boot Start End Blocks Id System
/dev/sdf1 1 39162 314568733+ 8e Linux LVM

Increasing the logical volume

[root@testb ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_db lvm2 a-- 29.51g 0
/dev/sdc1 vg_db lvm2 a-- 30.00g 0
/dev/sde vgod1 lvm2 a-- 50.00g 200.00m
[root@testdb ~]# pvcreate /dev/sdf1
Physical volume "/dev/sdf1" successfully created

[root@testdb ~]# pvdisplay /dev/sdf1
"/dev/sdf1" is a new physical volume of "300.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdf1
VG Name
PV Size 300.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID M4FH0u-EJsm-LTWX-ExVL-IxYO-wBN2-w8Gpcg
[root@testdb ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_db 2 2 0 wz--n- 59.50g 0
vgod1 1 1 0 wz--n- 50.00g 200.00m
[root@testdb ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vgod1/lvod1
LV Name lvod1
VG Name vgod1
LV UUID M6FN4t-L7yl-fD4g-OQ8S-ifqV-ey5u-pTZnXa
LV Write Access read/write
LV Creation host, time xrmdb, 2020-07-15 18:54:05 +0430
LV Status available
# open 1
LV Size 49.80 GiB
Current LE 12749
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:2

--- Logical volume ---
LV Path /dev/vg_db/root
LV Name root
VG Name vg_db
LV UUID eez7EB-bgNa-tMh5-ye90-FYzl-SJs8-qjWaOE
LV Write Access read/write
LV Creation host, time DB, 2016-02-03 08:24:00 +0330
LV Status available
# open 1
LV Size 51.69 GiB
Current LE 13233
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:0

--- Logical volume ---
LV Path /dev/vg_db/swap
LV Name swap
VG Name vg_db
LV UUID av6BuN-Dqm2-jMcD-g7HX-5fNU-q2dp-V1nW50
LV Write Access read/write
LV Creation host, time DB, 2016-02-03 08:24:02 +0330
LV Status available
# open 2
LV Size 7.81 GiB
Current LE 2000
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:1

Extend the logical volume into existing disk

[root@testdb ~]# vgextend vgod1 /dev/sdf1
Volume group "vgod1" successfully extended
[root@testdb ~]# lvextend -l +100%FREE /dev/vgod1/lvod1
Size of logical volume vgod1/lvod1 changed from 49.80 GiB (12749 extents) to 349.99 GiB (89597 extents).
Logical volume lvod1 successfully resized

Resize into existing disk

[root@testdb ~]# resize2fs /dev/vgod1/lvod1
resize2fs 1.43-WIP (20-Jun-2013)
Filesystem at /dev/vgod1/lvod1 is mounted on /oradata1; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 22
The filesystem on /dev/vgod1/lvod1 is now 91747328 blocks long.

Verify

[root@testdb ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_db-root
51G 31G 18G 63% /
tmpfs 5.8G 232K 5.8G 1% /dev/shm
/dev/sda1 477M 79M 370M 18% /boot
/dev/sdb1 99G 49G 45G 53% /oradata
/dev/sdd1 99G 82G 12G 88% /u02
/dev/mapper/vgod1-lvod1
345G 12G 318G 4% /oradata1

=====Hence tested & Verified in our test env=====