web analytics

Extend partitions in 1&1 dedicated servers

1&1 dedicated servers comes with pre-configured partitions which are too small in size. If you are to host websites, create databases etc, you should definitely extend those partitions, or you will soon be flooded with low disk space warnings.

This post will tell you how you can increase the partition size. In the example I consider here, the server has two disks with 1.5T space each. The server has RAID1, which means the total usable space is 1.5T. This is how my partitions are currently.


[root@abc ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              4.0G  615M  3.4G  16% /
/dev/mapper/vg00-usr  4.0G  1.3G  2.5G  35% /usr
/dev/mapper/vg00-var  4.0G  334M  3.5G   9% /var
/dev/mapper/vg00-home
4.0G  136M  3.7G   4% /home
none                  7.9G   16K  7.9G   1% /tmp

As you can see, my /var, /usr/ /home etc are LVMs with just 4G space.

Now, check the physical volume size using the pvs command

[root@abc ~]# pvs
PV         VG   Fmt  Attr PSize PFree
/dev/md3   vg00 lvm2 a–  1.36t 1.35t

The above output frpm pvs command shows that 1.35t of the physical volume /dev/md3 is free. The logical volume used is vg00. Now let us get the logical volume details.

[root@abc ~]# lvs
LV   VG   Attr      LSize Pool Origin Data%  Move Log Cpy%Sync Convert
home vg00 -wi-ao— 4.00g
usr  vg00 -wi-ao— 4.00g
var  vg00 -wi-ao— 4.00g

It shows the size of the various partitions.  I am planning to put my webfiles, databases etc under /var, so I need /var to be big in size. I am going to add 1T to my /var now. Before that, check the file system type of /var as we will have to extend the file system also along with the partition.

[root@abc ~]# mount
/dev/md1 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 ext4 (rw)
/dev/mapper/vg00-var on /var type ext4 (rw,usrquota)
/dev/mapper/vg00-home on /home type ext4 (rw,usrquota)
none on /tmp type tmpfs (rw)

The output shows that /var is using ext4. Now let us extend the /var partition. Currently it is using 4G, so I need to add 996G to make it 1T. The following command does it.

[root@abc ~]# lvextend -L +996G /dev/mapper/vg00-var
Extending logical volume var to 1000.00 GiB
Logical volume var successfully resized

Now check if the change has gotten into effect.

[root@abc ~]# lvs
LV   VG   Attr      LSize    Pool Origin Data%  Move Log Cpy%Sync Convert
home vg00 -wi-ao—    4.00g
usr  vg00 -wi-ao—    4.00g
var  vg00 -wi-ao— 1000.00g

var is showing 1000G now. You will not see this if you type df -h now. Now, let us extend the file system.

[root@abc ~]# resize2fs /dev/mapper/vg00-var
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg00-var is mounted on /var; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 63
Performing an on-line resize of /dev/mapper/vg00-var to 262144000 (4k) blocks.
The filesystem on /dev/mapper/vg00-var is now 262144000 blocks long.

The above process may take some time depending on the size of the partition.

Now, check if the partition is shown correctly.

[root@abc ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              4.0G  615M  3.4G  16% /
/dev/mapper/vg00-usr  4.0G  1.3G  2.5G  35% /usr
/dev/mapper/vg00-var  985G  340M  934G   1% /var
/dev/mapper/vg00-home
4.0G  136M  3.7G   4% /home
none                  7.9G   16K  7.9G   1% /tmp

Repeat the same process for  /usr and /home also if you want.

[root@abc ~]# lvextend -L +96G /dev/mapper/vg00-usr
Extending logical volume usr to 100.00 GiB
Logical volume usr successfully resized
[root@abc ~]# resize2fs /dev/mapper/vg00-usr
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg00-usr is mounted on /usr; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 7
Performing an on-line resize of /dev/mapper/vg00-usr to 26214400 (4k) blocks.
The filesystem on /dev/mapper/vg00-usr is now 26214400 blocks long.

Once completed, check everything using df -h

[root@abc ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/md1              4.0G  539M  3.5G  14% /
/dev/mapper/vg00-usr   99G  1.1G   93G   2% /usr
/dev/mapper/vg00-var  985G   14G  922G   2% /var
/dev/mapper/vg00-home
99G  143M   94G   1% /home
none                  7.9G   56K  7.9G   1% /tmp

 

 

2 comments to Extend partitions in 1&1 dedicated servers

Leave a reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>