Jump to content

Recommended Posts

Posted

It's been an awful long time since I've ever needed to extend disk space, could someone please help me with a procedure.

 

I've added the disks to the SAN, and I've resized the LUN to +1TB

The machine "sees" the extra disk space.

 

Do I now need to increase the size of the physical volume (how?), then resize the logical volume, then resize the file system or am I supposed to add another physical volume, add the new PV to the volume group and then expand the logical volume and resize the file system.

confused...

Posted (edited)

You add another PV consuming the new free space, then extend the volume group by adding the new PV.

 

I've done exactly this quite recently. Almost incredibly, I took notes:

Follow them to the letter and it works just fine (from experience)

 

You might want to try a modern rescue image with a modern Gparted - it might be able to add the volume groups using the nice GUI.

 

 

Note: these notes are written for my particular systems with two drives, but you'll get the principle.

 

 

 

 

Extending a logical volume in a virtual machine running Red Hat or Cent OS (1006371)

 

Purpose

This article provides steps for extending the root partition residing in a logical volume created with Logical Volume Manager (LVM) in a virtual machine running Red Hat/Cent OS.

Resolution

To extend the logical volume:

 

Note: These steps only apply to EXT3 file systems.

 

Caution: VMware recommends having a complete backup of the virtual machine prior making these changes.

Power off the virtual machine.

Edit the virtual machine settings and extend the virtual disk size. For more information, see Increasing the size of a virtual disk (1004047). Probably don’t need this as the disks can be resized with the VMWare GUI.

Boot with a GParted image and resize the partition. If you are using a version that will cope with LVM, you can skip the following few sections about resizing partitions.

Power on the virtual machine.

Identify the device name, which is by default /dev/sda, and confirm the new size by running the command:

fdisk -l

Create a new primary partition:

Run the command:

# fdisk /dev/sda (sdX depending the results of the step 4)

If you get a message about invalid partition tables, use the ‘w’ command to write the changes. Reboot and continue.

Press p to print the partition table to identify the number of partitions. By default there are 2: sda1 and sda2.

Press n to create a new primary partition.

Press p for primary.

Press 3 for the partition number, depending the output of the partition table print.

Press Enter two times.

Press w to write the changes to the partition table.

 

 

Restart the virtual machine.

Run this command to verify that the changes were saved to the partition table and that the new partition has an 83 type:

# fdisk -l

 

Run this command to convert the new partition to a physical volume:

 

# pvcreate /dev/sda3

 

Run this command to extend the physical volume:

 

# vgextend VolGroup00 /dev/sda3

 

Note: To determine which volume group to extend, use the command vgdisplay.

 

Run this command to verify how many physical extents are available to the Volume Group:

 

# vgdisplay VolGroup00 | grep "Free"

 

If you have used a modern GParted which can cope with LVM, you can drop in at this point as GParted will have already done the groundwork of extended the logical group.

 

Run the following command to extend the Logical Volume:

 

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

 

Where # is the number of Free space in GB available as per the previous command.

 

Note: to determine which logical volume to extend, use the command lvdisplay.

 

Run the following command to expand the ext3 filesystem online, inside of the Logical Volume:

 

# ext2online (or resize2fs) /dev/VolGroup00/LogVol00

 

Note: Use resize2fs instead of ext2online if it is not a Red Hat virtual machine.

 

Run the following command to verify that the / filesystem has the new space available:

 

# df -h /

Edited by jinnantonnixx
  • Thanks 1
Posted

Awesome, Thanks.

I followed half of that; and decided to do a mix of the instruction above and also try and increase the size of the physical volume.

It is a production machine so it was a bit nerve racking. Basically I deleted the partition using fdisk. Then recreated the partition. I then used pvresize and the I followed the procedure above.

All worked out well. Disk has gone from 360GB to 1.4TB

 

fdisk /dev/sdb

delete partition

create new partition (starting at same cylinder)

write changes

run pvresize /dev/sdb1

reboot

lvextend -L+1000G /dev/mapper/VolGroup01-LogVol00

e2fsck -f /dev/mapper/VolGroup01-LogVol00

resize2fs /dev/mapper/VolGroup01-LogVol00

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...