Shrink LVM volume for Windows partition


In order to release space from an LVM volume to finally get a free physical partition requires the following steps:

  1. Resize File Sytem in the LVM volume
  2. Resize Physical Volume
  3. Create a NTFS partition

Also, root access is necessary

Resize File Sytem in the LVM volume

# lvresize --resizefs --verbose -L -30G /dev/machine_vg/root

Resize Physical Volume

# pvresize --setphysicalvolumesize [the size of your volume - 30G] /dev/sdaX

If you get an error as: /dev/sdaX: cannot resize to X extents as later ones are allocated. It means there’s another volume between the free space and the end. To see it:

# pvs -v --segments /dev/sdaX

To move the free space towards the end, grab the last column from the output for the volume to move and use it in pvmove:

# pvmove --alloc anywhere /dev/sdaX:xxxxx-xxxx

Create a NTFS partition

# fdisk
n
c
1-n [partition number, probably sdaX+1]
L
87
# mkfs.ntfs /dev/sdaX