Beware this content is over 4 years old and considered stale. It may no longer be accurate and/or reflect the understanding of the author but remains here for reference only. Please keep this in mind as you use this content.

I’ve been using 1&1 Linux Dynamic Cloud Server for some time now and realised that one particular site had utilised almost all of it’s available space in /var. I had already extended the space by 10 GB using the fairly helpful information contained / hidden in the 1&1 FAQs on their website but needed to expand it yet again and thought I could condense the instructions for my own future reference.

While the 1&1 Linux packages come with CentOS as standard, I always reformat to use Ubuntu because it’s so much easier to troubleshoot and install all the modules I need.

That is why these instructions are geared toward Ubuntu, for CentOS, checkout the link above to the FAQ.

OK, lets get started. I’ll assumed you’ve already got access to the server by the command line via SSH and you are already logged in as root or have sudo capabilities.

First display the disk free space and sizes.

1
2
3
4
5
6
7
8
9
10
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 4.0G 3.4G 641M 85% /
udev 3.9G 4.0K 3.9G 1% /dev
tmpfs 1.6G 208K 1.6G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
/dev/mapper/vg00-usr 4.0G 776M 3.0G 21% /usr
/dev/mapper/vg00-var 9.9G 4.6G 4.9G 49% /var
/dev/mapper/vg00-home 4.0G 367M 3.4G 10% /home

View the total hard disk size and partitions on the disk.

1
2
3
4
5
$ fdsik -l
Device Boot Start End Blocks Id System
/dev/xvda1 63 8401994 4200966 83 Linux
/dev/xvda2 8401995 12611024 2104515 82 Linux swap / Solaris
/dev/xvda3 12611025 781240949 384314962+ 8e Linux LVM

You’ll be using the one with the Linux LVM system type.

View information on the physical volume, using the physical volume show command. As I understand it, that should tell you have much available space you have to play with in total. In my case, the 1&1 Linux Dynamic Cloud Server was original configured and bought with 400 GB hard disk space.

1
2
3
$ pvs
PV VG Fmt Attr PSize PFree
/dev/xvda3 vg00 lvm2 a- 366.51g 348.51g

Use the logical volume extend command to increase the size of a logical volume
by specifying the size in GB and the volume path. Here I am extending my /var which is mapped via /dev/mapper/vg00-var by 100 GB.

1
2
3
$ lvextend -L +100G /dev/mapper/vg00-var
Extending logical volume var to 110.00 GiB
Logical volume var successfully resized

The output should mention the new total size of your logical volume but now you’ll need to tell the filesystem to utilise the extra space you’ve added.

You can initially, confirm the logical volume has been “extended” but the filesystem needs to be informed too.

1
2
3
4
5
$ lvs
LV VG Attr LSize Origin Snap% Move Log Copy% Convert
home vg00 -wi-ao 4.00g
usr vg00 -wi-ao 4.00g
var vg00 -wi-ao 110.00g

You’ll need to know what the filesystem type is of the logical volume, using the next command.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
$ mount
/dev/xvda1 on / type ext3 (rw)
proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
/dev/mapper/vg00-usr on /usr type ext4 (rw,errors=remount-ro)
/dev/mapper/vg00-var on /var type ext4 (rw,errors=remount-ro)
/dev/mapper/vg00-home on /home type ext4 (rw,errors=remount-ro)
none on /proc/xen type xenfs (rw)

Towards the bottom you find the entry for /dev/mapper/vg00-var which is the one we’re dealing with and the type is ext4.

In the FAQ it examples that to increase the filesystem you’ll need to use the right command that matches the type so you’ll use either:
xfs_growfs if the filesystem uses xf or resize2fs if the filesystem is ext4

As our logical volume is ext4 we’ll use this command:

1
2
3
4
5
6
$ resize2fs /dev/mapper/vg00-var
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/mapper/vg00-var is mounted on /var; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 7
Performing an on-line resize of /dev/mapper/vg00-var to 28835840 (4k) blocks.
The filesystem on /dev/mapper/vg00-var is now 28835840 blocks long.

You can now confirm that everything has been updated from the changes you’ve made by checking the disk free space again.

1
2
3
4
5
6
7
8
9
10
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 4.0G 3.2G 810M 81% /
udev 3.9G 4.0K 3.9G 1% /dev
tmpfs 1.6G 208K 1.6G 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 3.9G 0 3.9G 0% /run/shm
/dev/mapper/vg00-usr 4.0G 776M 3.0G 21% /usr
/dev/mapper/vg00-var 109G 4.6G 99G 5% /var
/dev/mapper/vg00-home 4.0G 367M 3.4G 10% /home

That should be it. Drop a comment if you get stuck.