0

I'm using LVM on a single disk and now I need to resize the partition (sda2) I'm using.

I've already resized the Logical Volume but I can't manage to shrink the Volume Group. I know that vgreduce can remove Physical Volumes entirely but I have only one and I need too shrink that one.

Is it possible?

  • Please edit your question to add the operating system, at least to the tags. LVM is a generic concept. The only reason we can guess Linux and not HP-UX is because of the device name. – John Mahowald May 23 at 14:16
1

Assuming Linux LVM.

Reducing the size of a PV, and keeping the same PV partition, is a multiple step process. A little bit dangerous, data corruption is possible if the volumes are reduced too small for the file system.

  1. Backup data.
  2. Reduce the size of the file system. This is not possible for XFS, in which case you will need an alternative solution like restore backups to a smaller volume.
  3. lvreduce --resizefs --size the LV. --resizefs does step #2 at the same time, ensuring the sizes match.
  4. pvresize --setphysicalvolumesize the PV.
  5. Re-partition the PV. Tricky on the PV that contains the root file system. May be necessary to reboot into a rescue enviornment with root not mounted and VG not activated.

vgreduce removes entire PVs from the VG, and is not useful in this example.


As an alternative, if you move to using entire disks and not partitions, this process can be simpler.

  1. Backup data.
  2. lvreduce --resizefs --size if necessary to fit in the new disk
  3. Create disk, say it is named /dev/sdb
  4. vgextend /dev/sdb
  5. pvmove /dev/sda1
  6. vgreduce /dev/sda1

End result, VG moved to new disk, old partition empty and can be deleted.

| improve this answer | |
  • The trick was to use pvmove to "defragment" the volume. All the free space was in the middle of it. – Andreas Wederbrand May 23 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.