0% found this document useful (0 votes)
95 views7 pages

Resize LVM Disk After Extending VMDK

1) Resize the VM disk using VMware tools then rescan the guest OS to recognize the larger disk. 2) Check if the disk is formatted with partitions or as a single LVM PV. If partitions, create a new one and PV, else resize the existing PV. 3) Extend the logical volume with lvextend then resize the filesystem with resize2fs or xfs_growfs to use the new space.

Uploaded by

Bart Simson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
95 views7 pages

Resize LVM Disk After Extending VMDK

1) Resize the VM disk using VMware tools then rescan the guest OS to recognize the larger disk. 2) Check if the disk is formatted with partitions or as a single LVM PV. If partitions, create a new one and PV, else resize the existing PV. 3) Extend the logical volume with lvextend then resize the filesystem with resize2fs or xfs_growfs to use the new space.

Uploaded by

Bart Simson
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

How to expand a VMware vmdk and ext3 / ext4 filesystem on RHEL?

https://access.redhat.com/solutions/202063
How to extend an LVM disk on a RHEL guest machine running on VMware host?
https://access.redhat.com/solutions/30374

1) Resize the vmdk using VMware's management tools.

2) Rescan the scsi bus on the guest so that it sees the new size.
To rescan execute the below step.

echo 1 > /sys/block/sdX/device/rescan

wait a second then run

echo "- - -" > /sys/class/scsi_host/hostN/scan

Where 'N' is your scsi host id.

To determine the SCSI host ID from device names enter : ls -dl /sys/block/sd*/device/scsi_device/*
[root@infra-splunk ~]# ls -dl /sys/block/sd*/device/scsi_device/*
drwxr-xr-x. 3 root root 0 29 juil. 12:33 /sys/block/sda/device/scsi_device/2:0:0:0
drwxr-xr-x. 3 root root 0 29 juil. 12:33 /sys/block/sdb/device/scsi_device/2:0:2:0

You can see the the device name, and 4 numbers a:b:c:d


 a = Hostadapter ID
 b = SCSI channel
 c = Device ID
 d = LUN

3) Verify that the change took effect.

fdisk -l /dev/sdc

4) determine if the entire disk is formatted as an LVM PV OR if the disk is formatted with partition table
(with several partitions)

[root@jtm-app-rec ~]# lsblk


NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 40G 0 disk
├─sda1 8:1 0 1G 0 part /boot
├─sda2 8:2 0 15G 0 part --> sda disk has several partitions (sda1,
sda2…)
│ ├─cl-root 253:0 0 36,4G 0 lvm /
│ └─cl-swap 253:1 0 1,6G 0 lvm [SWAP]
└─sda3 8:3 0 24G 0 part
└─cl-root 253:0 0 36,4G 0 lvm /

[root@plan-app-rec ~]# lsblk


NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
fd0 2:0 1 4K 0 disk
sda 8:0 0 30G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 29G 0 part --> sda disk has several partitions (sda1,
sda2…)
├─sys_vg-root_lv 253:0 0 3G 0 lvm /
├─sys_vg-swap_lv 253:1 0 4G 0 lvm [SWAP]
├─sys_vg-usr_lv 253:2 0 4G 0 lvm /usr
├─sys_vg-home_lv 253:3 0 1G 0 lvm /home
├─sys_vg-opt_lv 253:7 0 1G 0 lvm /opt
├─sys_vg-tmp_lv 253:8 0 2G 0 lvm /tmp
└─sys_vg-var_lv 253:9 0 2G 0 lvm /var
sdb 8:16 0 20G 0 disk --> entire sdb disk is an LPM PV
├─data_vg-VAR_lv 253:4 0 3.1G 0 lvm /VAR
├─data_vg-OPT_lv 253:5 0 1000M 0 lvm /OPT
└─data_vg-USR_lv 253:6 0 100M 0 lvm /USR

IF the entire device is formatted as an LVM PV, resize the PV to claim the new, unallocated space.

pvresize /dev/sdc

ELSE IF the device is formatted with a partition table, and the partitions are used as LVM PVs (for example
/dev/sdc1), then you will need to create new partitions and create PVs on them :

a) Create a new partition using fdisk /dev/sda then save and quit.
If the following error occurs :
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)

Then enter the command :


# partx -v -a /dev/sda

b) Check the device nodes for /dev/sda itself and the partitions on it
# ls /dev/sda*

c) Once a new partition has been created (for example sda3), create a new physical volume and add it to
the existing volume group:
# pvcreate /dev/sda3
# vgextend VolGroup00 /dev/sda3

5) Use pvdisplay and vgdisplay to verify results.

6) Use lvextend to extend the logical volume.

lvextend -l +100%FREE /dev/mapper/cl-root

7) Use resize2fs to resize the ext2/3 filesystem.


resize2fs /dev/VolGroup00/LogVol00

If using Rhel 7, then the command differs, as Red Hat Enterprise Linux 7 uses xfs as the default filesystem
xfs_growfs /dev/VolGroup00/LogVol00
Resize LVM disk after extending Virtual Machine disk (vmdk)
https://www.howtovmlinux.com/articles/vmware/resize-lvm-disk-after-extending-virtual-machine-disk-
vmdk.html

Follow these simple steps to resize a Virtual machine disk (vmdk) and then extend the volume using LVM.
Make sure that you have/make a backup before carrying out these steps. First go ahead and extend the
vmdk from ESXi/vCenter. I increased the disk size from 20GB-->>30GB.

Before

After
Then Go ahead and run these commands to extend the LVM volume on Linux host.

First check the existing partitions

# lsblk

Note: If new size is not visible, Run a re-scan of iscsi bus

# lsscsi -s

# ls /sys/class/scsi_disk/

# echo "1" > /sys/class/scsi_disk/2:0:2:0/device/rescan

Note: as it’s the 2nd disk = sdb, scan the 2nd entry

Now resize the physical volume (PV)


# pvresize /dev/sdb

Check the FREE PE (Physical Extents)

# pvdisplay

Take a note of the PE and use it to extend the FS and its associated Logical Volume.

Then identify the LV of the FS to extend.

I want to extend the « /var ». The associated LV can be determined with the following command :

# df -h | grep "/var"

Now extend LV :

# lvextend -l +2560 /dev/mapper/VolGroup01-var_lv

Here 2560 correspond to the amount of FREE PE in the VG

OR

# lvextend -L+1GB /dev/mapper/VolGroup01-var_lv (For specific size extension)


And finally resize the FS.

If FS type is ext2, ext3 or ext4 :

# resize2fs /dev/mapper/VolGroup01-var_lv

OR if FS type is xfs :

# xfs_growfs /dev/mapper/VolGroup01-var_lv

And that’s it. You should be up and running with the extra space with no downtime required or data loss as
it is LVM.

You might also like