Thursday 2 December 2010

Increasing the size of a partition using Red Hat Enterprise Linux 5.5 under VMware Workstation

As with many of my posts, please please please use caution here - your mileage may vary and, in the worst case, you'll LOSE YOUR DATA. If in doubt, back up first. If still in doubt, DON'T DO IT :-)

This is a rough set of notes, which I'll polish up at some future time ...

Problem

I'd exceeded the 20 GB I'd allocated to a VM running RHEL, and didn't want to have to rebuild it from scratch.

Having increased the size of the disk image within VMware, I then needed to work out how to get Linux to use the extra 10 GB added.

Solution

(a) *CAUTION* Use the FDISK command to add a new partition to utilise the extra 10 GB *CAUTION*

fdisk /dev/sda

adding a new primary partition of type 8e ( Linux LVM )

meaning that the command: -

fdisk -l /dev/sda

returns: -

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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        3916    10490445   8e  Linux LVM

rather than: -

Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 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

(b) reboot to have the new partition table picked up: -

reboot

(c) Create the new Physical Volume (PV) which will utilise the new partition: -

pvcreate /dev/sda3

(d) Extend the Volume Group to include the new PV: -

vgextend VolGroup00 /dev/sda3

(e) Increase the size of the Logical Volume (LV): -

lvextend -L +10G /dev/VolGroup00/LogVol00

(f) Increase the size of the file system using the LV: -

resize2fs -p /dev/VolGroup00/LogVol00

Having done this, the command df -km / now shows that my disk is 44% utilised rather than 81% utilised.

Now to test it ....

Much of this came from this LinuxQuestions.org thread.

As with many of my posts, please please please use caution here - your mileage may vary and, in the worst case, you'll LOSE YOUR DATA. If in doubt, back up first. If still in doubt, DON'T DO IT :-)

No comments:

Visual Studio Code - Wow 🙀

Why did I not know that I can merely hit [cmd] [p]  to bring up a search box allowing me to search my project e.g. a repo cloned from GitHub...