3

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 answer, 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 Im missing here? Do I have to do anything else? Why isnt GParted allowing me to shrink the partition?

jfneis
  • 241
  • 2
  • 7
  • Look at mount or mount | grep ubuntu-vg. – waltinator Jun 07 '18 at 21:05
  • I think you can use a different approach, you have more than 200 GB left in sd3, you could create another vg to use that space and install Ubuntu 18.04. – Philippe Delteil Jun 07 '18 at 21:46
  • @waltinator not listed. simply deactivating via GParted removes the key icon, but resizes keep not working at all. – jfneis Jun 07 '18 at 21:56
  • @PhilippeDelteil I couldn't find a way to tell Ubuntu 18 installation that I want to use a specific VG inside sda3 to install it. Actually it lists sda3 (LVM) as "unknown" and the only option is to choose it as a whole (which I can't as I would lose my other installation) – jfneis Jun 07 '18 at 21:57

1 Answers1

2

Ok, so after a whole afternoon and part of my evening I found what was going on.

  1. pvresize was changed last year and now it prompts for confirmation when you want to resize a PV to a smaller size than the device it's in
  2. apparently GParted wasn't updated yet, as it will fail when trying to resize a partition as it answers NO to the prompt
  3. as GParted won't run pvresize successfully, it won't calculate blocks and run fdisk after it (just became clear to me after reading this post)

Maybe this bug only happens with newer versions of pvresize (as I'm trying Ubuntu 18.04 it would make sense).

jfneis
  • 241
  • 2
  • 7
  • Switching to Ubuntu 16.04 on a live usb resolve the pvresize issue for me – Robert Kleinsasser Jul 29 '18 at 22:22
  • @RobertKleinsasser yeap, it was confirmed as a bug in GParted related to newer versions of pvresize (that ask for confirmation). The GParted team already released a fix to it, so updating GParted in Ubuntu 18.04 will solve the issue too. – jfneis Jul 31 '18 at 14:20