Activities

January 2011
M T W T F S S
« Dec   Feb »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

1 and 1 : How to extend my lvm partition

Today I have given a server to configure it in production mode. The client actually sent a 1and1 welcome that does’t have any access details.

I had provided customer account details before to setup a domain pointer. I used that account and find the root access to the newly dedicated server.

After the login, I’m curious to view the partition layout as I know that plesk is using “/var” to store the data ( What a shit idea !! :-d nowadays)

All my excitement gone in a seconds and got the following output,

[root@u15320123 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 3.7G 350M 3.4G 10% /
/dev/mapper/vg00-usr 4.0G 1.4G 2.7G 35% /usr
/dev/mapper/vg00-var 4.0G 255M 3.8G 7% /var
none 2.0G 4.0K 2.0G 1% /tmp
tmpfs 2.0G 0 2.0G 0% /usr/local/psa/handlers/before-local
tmpfs 2.0G 0 2.0G 0% /usr/local/psa/handlers/before-queue
tmpfs 2.0G 0 2.0G 0% /usr/local/psa/handlers/before-remote
tmpfs 2.0G 0 2.0G 0% /usr/local/psa/handlers/info
tmpfs 2.0G 0 2.0G 0% /usr/local/psa/handlers/spool

[root@u15320123 ~]# df -h</strong>
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1             3.7G  350M  3.4G  10% /
/dev/mapper/vg00-usr  4.0G  1.4G  2.7G  35% /usr
/dev/mapper/vg00-var  4.0G  255M  3.8G   7% /var
none                  2.0G  4.0K  2.0G   1%
/tmptmpfs                 2.0G     0  2.0G   0%
/usr/local/psa/handlers/before-localtmpfs                 2.0G     0  2.0G   0%
/usr/local/psa/handlers/before-queuetmpfs                 2.0G     0  2.0G   0%
 /usr/local/psa/handlers/before-remotetmpfs                 2.0G     0  2.0G   0% /usr/local/psa/handlers/infotmpfs                          2.0G     0  2.0G   0%
/usr/local/psa/handlers/spool

“/var” partition has only 4 GB. What’s the 1&1 motivation behind this idea. I know 99% customers those who knows file system wont accept this server with this 4GB storage by lefting 600GB freely.

My next move to identify the no. disk attached to the server, PV and VG volumed used for. Found only a single disk is attached 🙁 which having 600Gb storage.

[root@u15320123 ~]# lvdisplay
— Logical volume —
LV Name /dev/vg00/var
VG Name vg00
LV UUID SKfTTL-pIrm-JHfO-Uw12-2NUC-Cchv-297y4I
LV Write Access read/write
LV Status available
# open 1
LV Size 4.00 GB
Current LE 76800
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1

Then I found VG volume have 600GB size. So that we can extend the LVM and can be merged with the file system.

[root@u15320123 ~]#<strong> vgdisplay</strong>
  --- Volume group ---
  VG Name               vg00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  <strong>VG Size               693.04 GB</strong>
  PE Size               4.00 MB
  Total PE              177417
  Alloc PE / Size       103424 / 404.00 GB
  Free  PE / Size       73993 / 289.04 GB
  VG UUID               aJBL0l-swMb-ClBF-4V9n-khyf-JeQv-wGWwNf

Now I’m going to extend the lvm used for “/var” partition” to 300GB

[root@u15320123 ~]# lvextend -L 300G /dev/vg00/var
[root@u15320123 ~]# lvdisplay | grep “/dev/vg00/var”
— Logical volume —
LV Name /dev/vg00/var
VG Name vg00
LV UUID SKfTTL-pIrm-JHfO-Uw12-2NUC-Cchv-297y4I
LV Write Access read/write
LV Status available
# open 1
LV Size 300.00 GB
Current LE 76800
Segments 2
Allocation inherit
Read ahead sectors auto
– currently set to 256
Block device 253:1

Showing LVM is extended !!! But still df -h showing the old partition size.
I tried resize2fs
[root@u15320123 ~]# resize2fs /dev/mapper/vg00-var
resize2fs 1.39 (29-May-2006)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/vg00-var
Couldn’t find valid filesystem superblock.

Got error and getting same with ext2online command also. Mount command shows that file system is different rather than I expected 🙁

[root@u15320123 ~]# <strong>mount</strong>
/dev/sda1 on / type ext3 (rw)
none on /proc type proc (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/mapper/vg00-usr on /usr type <strong>xfs</strong> (rw)
/dev/mapper/vg00-var on /var type <strong>xfs</strong> (rw,usrquota)

So I need to find the equvelent to “resize2fs” for xfs filesystem. Here is xfs_growfs which comes to me,

[root@u15320123 ~]# xfs_growfs /dev/vg00/var
meta-data=/dev/vg00/var isize=256 agcount=4, agsize=262144 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=1048576, imaxpct=25
= sunit=0 swidth=0 blks, unwritten=1
naming =version 2 bsize=4096
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=0
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1048576 to 78643200

Then check the partition was changed, by executing
[root@u15320123 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 3.7G 350M 3.4G 10% /
/dev/mapper/vg00-usr 4.0G 1.4G 2.7G 35% /usr
/dev/mapper/vg00-var 300G 264M 300G 1% /var

That’s grown up as I planned. Now I have a question ? Did 1and1 offering a job for us by pre-imaging the OS partition like this ?!!! My solution is they have to update the custom kickstart file according to the new server plans they made.

It’s still a question 🙂

Moral of the story : To resize the XFS filesysystem, You may use the command “xfs_growfs” other ext2 commands (resize2fs/ext2online) won’t work for you.

May use the following link for doing the same in ext2 file system. But this blog is used to add new disk and added the existing lvm volume.

13 comments to 1 and 1 : How to extend my lvm partition

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>