How to do a Filesystem Resize (ext3/ext4) on Redhat running on VMware

A filesystem resize can be done in several ways, online, offline, with LVM2 or without LVM2.  However, this blog will describe how to do an online resize of ext3/ext4 filesystems where a virtual disk (vmdk) is online added to a VMware Redhat guest OS.

So let’s start with the online filesystem resize of ext3/4 filesystems on the Redhat guest OS.  A new virutal disk (preferably an eagerd zero thick on VM running Oracle) was added as a pre requirement. Adding a new virtual disk is an online operation and no downtime is required to do it.

The whole procedure in this document is described by using the command line only. There is also a graphical user interface `system-config-lvm` that can perform the job, but that tool is out of scope in this document.

Online resize a ext3/4 filesystem

There are several steps that have to be done. These are in general:

  1. Scanning for new LUN’s
  2. Partition the new LUN’s and partprobe
  3. Create the physical volume
  4. Extend the volume group and the logical volume
  5. Extend the filesystem online

Rescan for new LUN’s

Depending on the number of virtual controllers, you have to scan for your new LUN’s on each of these. In case you know on which the disk was added, then of course, you need to scan only the appropriate one.

Rescan for new LUN’s on the first SCSI Controller (LSI Logic Parallel)

1
# echo "- - -"  > /sys/class/scsi_host/host0/scan*

Rescan for new LUN’s on the second SCSI Controller (Paravirtualized)

1
# echo "- - -"  > /sys/class/scsi_host/host1/scan*

Create a Primary Partion on the new devices

1
2
3
# fdisk /dev/sdx??
 
# fdisk /dev/sdy??

Partprobe the new devices

Partprobe is a program that informs the operating system kernel of partition table changes, by requesting that the operating system re-read the partition table.

1
2
3
# partprobe /dev/sdx??
 
# partprobe /dev/sdy??

Create the Pysical Volumes

1
2
3
# pvcreate /dev/sdx??
 
Physical volume "/dev/sdx??" successfully created
1
2
3
# pvcreate /dev/sdy??
 
Physical volume "/dev/sdy??" successfully created

Extend the Volume Group

1
2
3
# vgextend VGOracle /dev/sdx??
 
Volume group "VGOracle" successfully extended
1
2
3
# vgextend VGOracle /dev/sdy??
 
Volume group "VGOracle" successfully extended

Extend the Logical Volume

1
2
3
4
5
# lvextend -L 72G /dev/VGOracle/LVOracleu??
 
Extending logical volume LVOracleu?? to 72.00 GB
 
Logical volume LVOracleu01 successfully resized

Online Resize the ext3/ext4 Filesystem

After the logical volume is resized successfully, you can resize, in fact any filesystem that is online re-sizable. The following are examples for the ext3/ext4 filesystems. The syntax for ext3 and ext4 differ only slightly. For ext3 you use `resize2fs` even if its ext3 and not ext2, and in case of ext4 you use `resize4fs` were the command name is more logically.

ext3

1
# resize2fs /dev/VGOracle/LVOracleu??

ext4

1
# resize4fs /dev/VGOracle/LVOracleu??

 

That’s it. Now have fun with the bigger filesystem.

0 (0)
Article Rating (No Votes)
Rate this article
Attachments
There are no attachments for this article.
Comments
There are no comments for this article. Be the first to post a comment.
Full Name
Email Address
Security Code Security Code
Related Articles RSS Feed
Linux Audit The Linux security blog about Auditing, Hardening, and Compliance lynis
Viewed 2244 times since Thu, Jan 16, 2020
Fedora 32: Simple Local File-Sharing with Samba CIFS Linux
Viewed 8972 times since Sun, Dec 6, 2020
RHCS: Install a two-node basic cluster
Viewed 10181 times since Sun, Jun 3, 2018
RHCS6: Debug and test multicast traffic between two hosts
Viewed 6840 times since Sun, Jun 3, 2018
12 Tcpdump Commands – A Network Sniffer Tool
Viewed 8889 times since Fri, Jul 27, 2018
Linux An introduction to swap space on Linux systems
Viewed 2571 times since Thu, Jan 23, 2020
How To Use Systemctl to Manage Systemd Services and Units
Viewed 7668 times since Mon, Dec 7, 2020
An easier way to manage disk decryption at boot with Red Hat Enterprise Linux 7.5 using NBDE
Viewed 7761 times since Mon, Aug 6, 2018
LVM: Extend SWAP size by adding a new Logical Volume
Viewed 3290 times since Sat, Jun 2, 2018
linux ssh How to Hide the OpenSSH Version Details when Telnet to Port 22
Viewed 5521 times since Wed, Apr 22, 2020