LVM resize question

Joonas Hämäläinen list-joonas at nettitieto.fi
Wed Mar 19 13:00:32 UTC 2008


Lopez, Denise kirjoitti:
> Hi all,
> 
>  
> 
> I am in the process of setting up a Xen server and I want to have the 
> Guest OS’s on LVM’s.  I have created a 10GB LVM and installed a CentOS 
> guest on it.  Now before it goes production I want to do testing of 
> increasing the space for the Guest OS.  I have found documentation that 
> says to use resize2fs after you extend the logical volume but when I try 
> this command on the logical volume I get the following error.
> 
>  
> 
> root at xen ~]# resize2fs /dev/XenServers/CentOS5
> 
> resize2fs 1.39 (29-May-2006)
> 
> resize2fs: Bad magic number in super-block while trying to open 
> /dev/XenServers/CentOS5
> 
> Couldn't find valid filesystem superblock.
> 
>  
> 
> I tried with the –f option too but still the same error. 
> 
>  
> 
> Any ideas?

Hips,

I don't know if you have got this problem solved, but as there wasn't 
one confident reply how to solve this on list, I'll reply too. Better 
later than never as they say.

I have similar setup as you have, xen domU:s on lvm, running even Centos 
guests. I dug this solution when setting them up, and been using it 
happily ever since:

To increase size of partition to 6GB in size:
[root at example ~]# lvextend -L6G /dev/domUarray/demodomU
   Extending logical volume demodomU to 6.00 GB
   Logical volume demodomU successfully resized

If you want to upgrade 10GB partition to 12GB, you either say -L12G or 
-L+2G and it does the trick.

After lvm has been resized, you have to use resize tool of filesystem:


[root at example~]# e2fsck -f /dev/domUarray/demodomU
e2fsck 1.35 (28-Feb-2004)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/domUarray/demodomU: 24528/89664 files (0.7% non-contiguous), 
161312/179200 blocks

[root at example~]# resize2fs /dev/domUarray/demodomU
resize2fs 1.35 (28-Feb-2004)
Resizing the filesystem on /dev/domUarray/demodomU to 1572864 (4k) blocks.
The filesystem on /dev/domUarray/demodomU is now 1572864 blocks long.


Or if using reiserfs:
# resize_reiserfs -f /dev/domUarray/demodomU
# resize_reiserfs /dev/domUarray/demodomU

Upper one of those is for online partition, below is one for offline 
partition.

And you didn't ask, but telling you answer so you know when you 
encounter it, how to shrink partition:

When making it smaller, we do it in reverse order. You also have to know 
block size of partition you want it to be:
# resize2fs /dev/domUarray/demodomU 524288
# lvreduce -L-1G /dev/domUarray/demodomU

and same with reiserfs, where you don't have to know block size of new size:

# resize_reiserfs -s-1G /dev/domUarray/demodomU
# lvreduce -L-1G /dev/domUarray/demodomU

Hope this helps you, and others having similar problem.

Regards,
Joonas Hämäläinen




More information about the redhat-sysadmin-list mailing list