jb’s open source blog

Growing a LVM2 + ext3 partition

Posted in Open Source by jbopensrc on October 10th, 2007

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

Detailed

# 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
/dev/mapper/VolGroup00-LogVolVMWareXP
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
/dev/mapper/VolGroup00-LogVolVMWareXP
24G 23G 1.4G 95% /mnt/vmwarexp

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

One Response to 'Growing a LVM2 + ext3 partition'

Subscribe to comments with RSS or TrackBack to 'Growing a LVM2 + ext3 partition'.

  1. dejan said, on October 12th, 2007 at 6:57 pm

    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

Leave a Reply