Booted from an USB Ubuntu 18.04 and I'm trying to shrink my current Ubuntu 16.04 partition.

For the sake of completion, this is what lsblk returns in the momento I'm writing this:

sda                     8:0    0 465.8G  0 disk 
├─sda1                  8:1    0   512M  0 part 
├─sda2                  8:2    0   488M  0 part 
└─sda3                  8:3    0 464.8G  0 part 
  ├─ubuntu--vg-root   253:0    0 248.9G  0 lvm  
  └─ubuntu--vg-swap_1 253:1    0  15.9G  0 lvm  
sdb                     8:16   1   1.9G  0 disk /cdrom
├─sdb1                  8:17   1   1.8G  0 part 
└─sdb2                  8:18   1   2.3M  0 part 

As you can see, my /dev/sda3 has 464.8G but just 264.8G are in use by vg-root and vg-swap. What I want is to shrink sda3 so I can install Ubuntu 18.04 in another partition.

Following this article, after resizing my LV, I'm trying to run pvresize:

ubuntu@ubuntu:~$ sudo pvresize --setphysicalvolumesize 265G /dev/sda3
/dev/sda3: Requested size 265.00 GiB is less than real size 464.78 GiB. Proceed?  [y/n]: y
  WARNING: /dev/sda3: Pretending size is 555745280 not 974721024 sectors.
  Physical volume "/dev/sda3" changed
  1 physical volume(s) resized / 0 physical volume(s) not resized

Given the message, I understand that everything worked successfully, but when running lsblock (or GParted), everything remains the same: sda3 was not shrinked.

Important to note that GParted is showing a key icon beside sda3 as if it was mounted, when it is not (as I booted from USB). Running umount confirms that:

GParted screen

ubuntu@ubuntu:~$ sudo umount /dev/sda3
umount: /dev/sda3: not mounted.

Also, if I try to resize sda3 using GParted it will run the same pvresize but will answer NO to the confirmation, so it results is an error.

What am I missing here? Do I have to do anything else? Why isn't GParted allowing me to shrink the partition?

  • 5
    Possible duplicate of Cannot shrink lvm2 partition – Emmanuel Rosa Jun 7 '18 at 21:21
  • This is not a good answer to duplicate against, since it is XFS-specific. XFS cannot be shrunk. But ext4 - the default Linux filesystem - can be. – sourcejedi Jun 9 '18 at 11:43

Why isnt GParted allowing me to shrink the partition?

I expect it detects that LVM is using it. lvchange -an ... should allow deactivating LV's (Logical Volumes), such as /dev/ubuntu--vg-root and /dev/ubuntu--vg-swap_1. vgchange -an ubuntu should allow deactivating the ubuntu VG (volume group).

Note, if gparted can shrink the partition, it is not necessary to run pvresize beforehand.

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.