[LINUX-LVM] shrinking a volume inside an LVM

Brian McCullough bdmc at bdmcc-us.com
Fri Jan 4 19:38:19 UTC 2008

On Fri, Jan 04, 2008 at 01:07:42PM -0600, Kemp, Levi wrote:
> I'm sure it's been asked before, but I must be terrible at searching because I cannot find the answer. I have, like many, followed defaults and ended up wiht a boot partion and a lvm. Inside the lvm is a / and a swap. I'd like to shrink the / so that I can do another install of a different distro without upsetting my current one. I don't have another computer, or equal setup to run my test on and cannot take this one down yet either. If it's impossible let me know, but either way thanks for the help.

This is relatively easy, as long as you are careful.

First, which filesystem format are you using?  I will base my answer on
ext2/ext3, because that's what I am most familiar with, others can
answer better if you have something else.

Second, I presume from your question that / is not full.

1. Boot with a Rescue Disk or Live CD ( you need to make sure that your
LVM is not Live and being used. )

2. Start a terminal window and run:

3. vgchange -a y

4. e2fsck -f /dev/"volgroupname"/"volname of '/'"  ( you can fill in the
blanks )

5. mkdir /mnt1

6. mount /dev/"volgroupname"/"volname of '/'" /mnt1

7. df ( check the amount of space occupied in / )

8. umount /mnt1

9. resize2fs /dev/"volgroupname"/"volname of '/'" "amount occupied +

10. lvreduce -L "size from 9" /dev/"volgroupname"/"volname of '/'" 
( If you want to be extra paranoid, you can add a "-t" parameter once,
and then run it without. )

11. resize2fs /dev/"volgroupname"/"volname of '/'" 
( This will adjust the filesystem to fit the Logical Volume. )

At this point, you should have a smaller / volume and some free space.
Note that resize2fs will insist on the e2fsck, and may require it more
often than I have shown.

I have put in a couple of paranoia steps, such as 6-8, to make sure that
you are using the correct sizes in the next couple of steps.

Have fun!

More information about the linux-lvm mailing list