Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to shrink my second (LVM) partition, in order to create a new partition in the newly freed space. I am using the Live CD to do so, because I know I can't resize/move this partition while it is in use. When I opened GParted in the Live CD, I realized that I could not resize the partition, because when I right-click it, the option "resize/move" is disabled.

I tried to unmount it, to "lazy" unmount it (umount -l /dev/sda2) but it didn't work.

A screenshot from GParted:

GParted screenshot

share|improve this question

There seems to be plenty of results on Google where people had similar problems. An example:

Back up all your important data before attempting this. Always assume that you can lose all your data when resizing partitions.

Shrink LVM without dataloss

This forum thread suggests the following procedure, in this example we shrink a partition from 10G to 9G:

First, we unmount.

# umount /dev/vg_blah/lv_blah

Check the file system.

# e2fsck -f /dev/vg_blah/lv_blah

Resize the file system.

# resize2fs -p /dev/vg_blah/lv_blah 9G

Reduce the size of the logical volume.

# lvreduce -L -1G /dev/vg_blah/lv_blah

Remove a physical drive from the volume group if desired (if you now have an unused drive).

# vgreduce vg_blah /dev/sdxy

All credit goes to brianmcgee, author of the post who also points out:

It is crucial that you use the exact amount of space. If you reduce volume more than the filesytem you truncate the logical volume and you risk data loss!

Note: vgreduce will fail with "cannot resize to xxxxx extents as later ones are allocated" if you have another lv at the end of the disk - I had a swap lv, which I deleted. See 2 for help on that situation.

share|improve this answer
e2fsck -f /dev/vg_blah/lv_blah returns: "e2fsck: Device or resource busy while trying to open /dev/sda2 Filesystem mounted or opened exclusively by another program?", the same with resize2fs... – iiddaannyy Oct 8 '12 at 13:52
Is it unmounted? What did you type in your command specifically (I'm assuming you didn't type vg_blah) – pzkpfw Oct 9 '12 at 8:39
The answer is missing how to resize the physical volume. Also, I highly recommend combining the two resizing steps into one with lvreduce -r. – Flimm Nov 28 '12 at 17:02
Also, you need to realise that 1G to lvreduce is 1000000000 bytes, whereas to resize2fs it is a gibibyte. If you want to pass 1 gibibyte to lvreduce, use 1g instead. – Flimm Nov 28 '12 at 17:08
You don't use vgreduce; that is for removing a pv from a volume group. – psusi Nov 23 '14 at 22:45

You can shrink/extend a logical volume very easily with a GUI tool: system-config-lvm. Because system-config-lvm is not come pre-installed, once booted from a live-cd, you have to install it:

$ sudo add-apt-repository "deb $(lsb_release -sc) universe"
$ sudo apt-get update
$ sudo apt-get install system-config-lvm

Once it is installed, run the program, select the logical volume you want to change in the left panel, click 'Edit Properties'.

Main Logical Volume Management program GUI

Now change the parameters as you wish!

Edit Logical Volume window

One good thing about system-config-lvm is that it won't allow you to go ahead if the new partition size is smaller than all your existing data combined (I've just tried this and see for myself).


  1. How-To Geek tutorial (this is the origin of the images).
  2. Red Hat's complete guide for the program.
share|improve this answer
GUI is definitely the way to go, however you will likely need to run it from a live CD. – Mike Sep 15 '14 at 8:16
I disagree a bit. Shrinking LVM logical volumes with system-config-lvm is definitely riskier than lvresize -r or lvresize after an earlier file system resize. – uprego Nov 3 '14 at 12:33
why is system-config-lvm riskier than lvresize or lvresize -r? – Thufir Feb 1 '15 at 12:29
You could also try blivet-gui (github, Ubuntu PPA), the next-gen partition manager that handles LVM drives. – bain Feb 21 '15 at 13:27
Beware that system-config-lvm uses powers-of-1024 units, despite using the (incorrect) 'gigabyte' wording. It really should do like palimpsest (a.k.a. Disk Utility) and specify its meaning in unambiguous bytes. – Urhixidur May 22 '15 at 19:41

Only the latest version of Gparted (0.14) supports resizing LVM physical volumes. The version that ships with Ubuntu 12.10 or 13.04 does not support it.

Here's how to resize an LVM physical volume:

  1. If the volume group associated with the LVM physical volume does not have enough unallocated space, you'll need to make some by shrinking a logical volume. Look at bigbadonk420's answer for instructions on how to do that. You can also use GNOME Disks (included with Ubuntu) for some of the steps if you prefer a GUI.

  2. Burn the latest .iso image from GParted's website, and burn it on a CD or put it on a USB stick. Boot from the CD or the USB stick. Alternatively, you could compile the latest version of GParted from source.

  3. 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.

share|improve this answer
Thanks Flimm. I was expecting 12.10 to have a recent enough version of gparted. Your answer pointed me in the right direction. – Martijn Heemels Apr 9 '13 at 21:31
I got the latest gparted, but it won't let me change the partition sizes... I have /dev/sda2 of type ext2 and under that, /dev/sda5 of type lvm2. But gparted says for both that min and max sizes are the same, and therefore does not allow me to change it... :-( – Paul Aug 18 '14 at 14:24
Or use pvresize of the LVM2 suite, right? – uprego Nov 3 '14 at 12:30
@Paul did you solve it? I have exactly the same problem :S – Castiblanco Nov 7 '14 at 22:33
@Castiblanco I didn't solve it, I ended up wiping the whole things and reinstalling without LVM. For me, one lesson learned: Don't use LVM for standard desktop installations. – Paul Nov 9 '14 at 11:37

These are all the steps required to resize a LVM or LVM2 partition -

sudo lvresize --verbose --resizefs -L -150G /dev/ubuntu/root

sudo pvresize --setphysicalvolumesize {any size here} /dev/sda5

/dev/sda5: cannot resize to xxxxx extents as later ones are allocated.

You have to rearrange the unallocated space at the end of the LVM. That means after root and swap_1 partition. So, you need to move that free space using the command below

pvs -v --segments /dev/sda5

This will show the output like below

/dev/sda5 ubuntu lvm2 a-- 698.04g 150g 0 xxx root 0 linear /dev/sda:0-xxx
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g xxx yyyy 0 free                          
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g yyyy end swap 0 linear /dev/sda5:yyyy-end

Now use the command below to remove external fragmentation -

sudo pvmove --alloc anywhere /dev/sda5:yyyy-end

Now let us see how it goes -

pvs -v --segments /dev/sda5

This will show the output like below

/dev/sda5 ubuntu lvm2 a-- 698.04g 150g 0 xxx root 0 linear /dev/sda:0-xxx
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g xxx yyyy swap 0 linear /dev/sda5:xxx-yyyy
/dev/sda5 ubuntu lvm2 a-- 698.04g 150g yyyy end 0 free

After that use the gparted and resize the LVM to maximum used area and rest will be in unallocated space. Enjoy...

share|improve this answer

I found this answer by accident, but this worked for me at least. In my case I had already a reserved unallocated disk space after the root, so I skip the part how you get more space and just explain how I used it on root without booting.

NOTE: Instead of using gparted, you are probably better off using system-config-lvm. Next time I would use that one instead... My gparted version was 0.18.

  1. First I used gparted to extend root partition as much as I could. To my surprise it extended only the physical sizes and did nothing to the logical part. So df -k command said that the disk was full still.
  2. lvresize -l +100%FREE /dev/ubuntu-vg/root extends the logical partition as far as it can. No need to check and calculate GBs or blocks in various methods.
  3. resize2fs /dev/ubuntu-vg/root is then the third step I did: it extends the file system to the size of the logical partition.
share|improve this answer

Warning about the currently most voted answer: To NOT destroy your fresh default installation with LVM option (14.04 Trusty Tahr), 1) read the whole page, 2) delete swap 3) and probably modify the command for "Reduce the size of the logical volume" like this:

lvreduce -L -1g /dev/vg_blah/lv_blah

I strongly recommend system-config-lvm.

share|improve this answer

In addition to the @bigbadonk420's answer, Instead of doing the following:

resize2fs -p /dev/vg_blah/lv_blah 9G
lvreduce -L -1G /dev/vg_blah/lv_blah


lvreduce -r -L 9G /dev/vg_blah/lv_blah

Note the -r which reduces the file system simultaneously and is safe.

share|improve this answer

I would recommend another GUI tool - KVPM. It combines functionality of GParted and system-config-lvm. Moreover, it allows some operations on live (mounted) partitions that system-config-lvm doesn't allow However, the volume has to be unmounted for shrinking.

enter image description here enter image description here

It is in universe repository since Ubuntu 12.04, so just do sudo apt-get install kvpm

Note: start it with root rights sudo kvpm

share|improve this answer

protected by Community Jan 11 at 14:25

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

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