Adding more disk space to an LVM-based partition in Red Hat 5

In this example, I have a Red Hat 5 VM running in VMWare Fusion on a MacBook Pro. The '/' partition is on a single LVM logical volume. I want to increase its size from 20GB to 25GB. If you're not using LVM, try these instructions instead : http://www.howtoforge.com/linux_resizing_ext3_partitions_p2

Here's the problem:

[root@rhel5-oracle ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       19G   18G  6.2M 100% /
/dev/sda1              99M   18M   77M  19% /boot
tmpfs                 506M     0  506M   0% /dev/shm

First step is to shut down the VM and give it more disk space via the VMWare 'Settings' panel. In this example, I just added space to the existing single virtual disk, but you could just as well create a separate virtual disk. The instructions below work just as well if you've got a non-virtual OS which you want to add more real physical storage to.

Then boot the VM again, and do the following in the guest OS.

fdisk /dev/sda

Create a new partition for the newly available space.

## Check what you're starting with.
Command (m for help): p

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM

## Create the new partition
Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (2611-3263, default 2611):
Using default value 2611
Last cylinder or +size or +sizeM or +sizeK (2611-3263, default 3263):
Using default value 3263

## Make it LVM
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)

## Double-check
Command (m for help): p

Disk /dev/sda: 26.8 GB, 26843545600 bytes
255 heads, 63 sectors/track, 3263 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        2610    20860402+  8e  Linux LVM
/dev/sda3            2611        3263     5245222+  8e  Linux LVM

## Commit your changes
Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

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.
Syncing disks.

Now reboot the VM and proceed. Online resizing of ext3 is supported in 2.6 kernels, so you don't even need to use Knoppix or some other CD-based distro.

[root@rhel5-oracle ~]# pvcreate /dev/sda3
  Physical volume "/dev/sda3" successfully created
[root@rhel5-oracle ~]# vgextend VolGroup00 /dev/sda3
  Volume group "VolGroup00" successfully extended
[root@rhel5-oracle ~]# lvextend -L+5G /dev/VolGroup00/LogVol00
  Extending logical volume LogVol00 to 23.88 GB
  Logical volume LogVol00 successfully resized
[root@rhel5-oracle ~]# resize2fs /dev/mapper/VolGroup00-LogVol00

And here's the final outcome...

[root@rhel5-oracle ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       24G   18G  4.6G  80% /
/dev/sda1              99M   18M   77M  19% /boot
tmpfs                 506M     0  506M   0% /dev/shm

You'r da man! this is just what I need to get the job done!

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.