jb’s open source blog

A look into my work and play in open source

Growing a LVM2 + ext3 partition

with 4 comments

I have Windows XP in a VMWare virtual machine for the times I need to use Windows. I love open source software, but I have to admit, I’m quite fond of C# and ASP.NET. (Now that I’ve lost half my readers…)

I made my VMWare partition too small on purpose: I wanted it to be a tight fit so as to not waste any space – and if I had issues, I could just grow it with LVM2. When I booted my VM, VMWare complained that there wasn’t enough free space and I might corrupt the VM’s RAM. So I wanted to add 1 gig to it.

Quick and to the point

# lvextend -L +1G /dev/VolGroup00/LogVolVMWareXP
# resize2fs /dev/VolGroup00/LogVolVMWareXP

Wow! That’s it! I didn’t have to reboot, I didn’t even have to umount the partition! (Mind you, I wasn’t brave enough to try this while things were going on in this partition – no files were open and the VM wasn’t booted. EDIT: 1GB wasn’t enough, so I added another 512MB while the VM was “hot” with no issues!) Surprisingly, the resize2fs command needed no parameters: it just grows to fill the partition. LVM-HOWTO helped me with this. I ignored the part that said “the online resizing patch is rather dangerous, so use at your own risk“, hoping it’s outdated *knock on wood*.


# vgdisplay |grep -i free
Free PE / Size 639 / 19.97 GB
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 VolGroup00 lvm2 a- 51.66G 19.97G
# df -h /mnt/vmwarexp/
Filesystem Size Used Avail Use% Mounted on
23G 23G 335M 99% /mnt/vmwarexp
# lvscan
ACTIVE '/dev/VolGroup00/LogVolFedora' [7.81 GB] inherit
ACTIVE '/dev/VolGroup00/LogVolSwap' [1.00 GB] inherit
ACTIVE '/dev/VolGroup00/LogVolVMWareXP' [22.88 GB] inherit
# lvextend -L +1G /dev/VolGroup00/LogVolVMWareXP
Extending logical volume LogVolVMWareXP to 23.88 GB
Logical volume LogVolVMWareXP successfully resized
# resize2fs /dev/VolGroup00/LogVolVMWareXP
resize2fs 1.40.2 (12-Jul-2007)
Filesystem at /dev/VolGroup00/LogVolVMWareXP is mounted on /mnt/vmwarexp; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup00/LogVolVMWareXP to 6258688 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVolVMWareXP is now 6258688 blocks long.
# vgdisplay |grep -i free
Free PE / Size 607 / 18.97 GB
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 VolGroup00 lvm2 a- 51.66G 18.97G
# lvscan |grep VM
ACTIVE '/dev/VolGroup00/LogVolVMWareXP' [23.88 GB] inherit
# df -h /mnt/vmwarexp/
Filesystem Size Used Avail Use% Mounted on
24G 23G 1.4G 95% /mnt/vmwarexp

So far LVM2 is pretty neat. Should be interesting digging deeper into it.


Written by jbopensrc

October 10, 2007 at 9:22 pm

Posted in Open Source

4 Responses

Subscribe to comments with RSS.

  1. Using Qemu you can create a partition the same way and it will only use as much space as you plan to install on it.

    As for .NET I am sure you have heard of Mono, its quiet capable of compiling C# code.
    It will even be more compatible once MS releases its .NET library code see here http://developers.slashdot.org/developers/07/10/03/1626209.shtml


    October 12, 2007 at 6:57 pm

  2. Hi there,
    Thanks yaar. This is what I needed. I need to expand one of my partitions on linux and was able to


    July 23, 2008 at 3:34 am

  3. Thanks a lot – I was trying to use GParted and failing miserably.


    September 3, 2008 at 6:03 am

  4. Thanks, worked like a charm :)


    July 21, 2009 at 10:45 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: