0

Notice: I know this type of question has been asked (many times) before, but I have some remarks about the provided answers.

I run a RHEL (7.1) VM on Hyper-V. The VM has 2 IDE disks attached. I need to expand the second disk from 80 GB to 160 GB, so I expanded the disk in Virtual Machine Manager. Now there's some stuff that needs to be done on the Linux side.

Most solutions I've read boil down to this:

  1. Create a new primary partition with fdisk /dev/sdb
  2. Set partition type to LVM (0x8e)
  3. Create a new Physical Volume (pvcreate)
  4. Extend the Volume Group with the new PV (vgextend)
  5. Extend the Logical Volume (lvextend)
  6. Extend the filesystem (xfs_growfs)

An other solution is adding a second disk and adding that disk to the Volume Group. We don't want to go that route and keep only those 2 disks.

This all works great, I've done it before. Now I'm wondering if it's possible to extend the already existing partition (e.g. sdb1) instead of adding a sdb2, because as far as I remember there's a limit on the number of primary partitions? Imagine: what if I need to expand this disk 5 times? Then I have 6 primary partitions.

parted is not an option anymore, because they removed the resize and move commands. GParted could be a solution, but then I have to boot the VM with the GParted live CD, and I want to avoid that.

What are your thoughts?

EsTeGe
  • 271
  • 1
  • 5
  • 14

1 Answers1

0

Yes!

use partition tool like parted or fdisk. Remove the original partition of the partition on which you have the PV created on, but remember the start and end cylinder/block on there and be sure that you make your new partition start on same place and use more than the original size else you mess up the filesystem on there.

having done that, it is posible that the new partition size will be detected with tool like partprobe, but if it's on the fs mounted on /, then a reboot may be necessary to detect the new partition size. I don't remember.

So having done that, it should now be possible for you to follow the remaining steps from your list.

I have a tip though: If the whole disk is a PV (ie no partition table on there), then next time when growing the filesystem, there you can just skip to step 4.

Petter H
  • 3,443
  • 1
  • 16
  • 19
  • Thanks for your input. Removing the partition was another option I forgot to mention.Deleting "stuff" always seems risky. Also, I didn't know I could add a whole disk as a PV to a VG. Good know! – EsTeGe Oct 22 '15 at 12:52