5

I want to shrink a Linux LVM partition from 200GB to 150GB. A test is carried out with the following steps:

  • Shrink a file system in a logical volume with reszie2fs
  • Shrink the logical volume with lvreduce
  • Delete the 200GB LVM partition with fdisk
  • Recreate the same LVM partition, but with size a reduced of 150GB

I am able to access a test file using the above method. But, vgdisplay and vgs both reported the old size of 200GB. I think I might have missed out a vgreduce step after shrinking the logical volume. But, from the man page, it seems to say that vgreduce can only be performed on an empty physical volume. In my situation above, the whole volume group resides in one physical volume.

What is the correct way to shrink this LVM partition?

Question Overflow
  • 4,568
  • 19
  • 57
  • 84
  • http://blog.shadypixel.com/how-to-shrink-an-lvm-volume-safely/ – slm Feb 05 '14 at 13:50
  • 1
    @slm, I am referring to the physical _partition_, not logical volume. – Question Overflow Feb 05 '14 at 13:56
  • They're called VG & LV. Volume Group and Logical Volumes. – slm Feb 05 '14 at 14:13
  • @slm, I am referring to shrinking a partition such as /dev/sda3 containing the VG and LVs. – Question Overflow Feb 05 '14 at 14:16
  • 1
    I believe to reduce the VG so you can eventually shrink the partition they're on using `fdisk` you'd need to follow this: http://unix.stackexchange.com/questions/67702/how-to-reduce-volume-group-size-in-lvm – slm Feb 05 '14 at 14:23
  • Are you just trying to learn using these tools or are you trying to get something done? I think I'd encourage you to use gparted instead of doing it in this manner. – slm Feb 05 '14 at 14:38
  • But obviously to use `gparted` or, if available, `partitionmanager`, only **after** reducing the VG, right? – 41754 Feb 05 '14 at 14:42
  • @slm, thanks for the link, `pvresize` is what I am looking for. – Question Overflow Feb 06 '14 at 08:07

1 Answers1

4

I'm not sure if you're just trying to learn using these tools or are trying to get something done, in either case I think I'd encourage you to use gparted instead of doing it using the straight commands in this manner.

Use GParted to resize the LVM physical volume. GParted won't let you shrink the LVM physical volume to a size smaller than what the unallocated space allows.

References

slm
  • 363,520
  • 117
  • 767
  • 871