Ubuntu webserver is out of space

Posted on

Ubuntu webserver is out of space – Managing your servers can streamline the performance of your team by allowing them to complete complex tasks faster. Plus, it can enable them to detect problems early on before they get out of hand and compromise your business. As a result, the risk of experiencing operational setbacks is drastically lower.

But the only way to make the most of your server management is to perform it correctly. And to help you do so, this article will share nine tips on improving your server management and fix some problem about linux, ubuntu, disk-space-utilization, hard-drive, mount.

Apparently, I was using xvda1 disk which is out of space.

How do I change the /etc/fstab so that I can make my xvda2 for top level, and xvda1 as additional resource?

It’s an EC2 instance:

root@~# cat /etc/fstab
LABEL=cloudimg-rootfs   /    ext4   defaults    0 0
/dev/xvda2  /mnt    auto    defaults,nobootwait,comment=cloudconfig 0   2

root@:/# du --max-depth=1 -h
4.0K    ./selinux
1.7G    ./opt
29M ./boot
du: cannot access `./proc/23342/task/23342/fd/4': No such file or directory
du: cannot access `./proc/23342/task/23342/fdinfo/4': No such file or directory
du: cannot access `./proc/23342/fd/4': No such file or directory
du: cannot access `./proc/23342/fdinfo/4': No such file or directory
0   ./proc
98M ./lib
13M ./etc
2.8M    ./home
72M ./run
8.0K    ./dev
4.0K    ./media
8.0M    ./sbin
20K ./mnt
4.0K    ./srv
0   ./tmp
8.3M    ./bin
1.4M    ./build
0   ./sys
1.4G    ./usr
3.9G    ./var
16K ./lost+found
233M    ./root
7.4G    .

root@:~# df
Filesystem     1K-blocks    Used Available Use% Mounted on
/dev/xvda1       8361916 7845404     97084  99% /
udev             1929404       8   1929396   1% /dev
tmpfs             773948   73672    700276  10% /run
none                5120       0      5120   0% /run/lock
none             1934860       0   1934860   0% /run/shm
overflow            1024      64       960   7% /tmp
/dev/xvda2     412814512  203156 391641580   1% /mnt

Solution :

If I were I would just replace it with a bigger one, with few minutes down time.

  1. Stop the instance
  2. In the console take snapshot of the root volume
  3. Create new ebs from that snapshot with bigger volume size
  4. detach the old volume and attach the new volume
  5. start your instance again

I guess this is EC2 instance (because xvda is what EC2 is using). In short, you can’t do that in EC2.

Instead, you can permanently mount /dev/xvda2 (by editing /etc/fstab) at say, /home or /mnt and use it as an additional “pool” to put your data.

You can play with symlinks to try and split your data into 2 data sets of about the same size. Typically it is not difficult to get this to work.

Usually a unix/linux file system is split up into multiple partitions for /, /usr, /var, /home, /tmp and maybe /srv. If you cannot rebuild or repartition your system, look where the most space is used up and move that to your xvda2 partition. You can then bind mount or symlink parts of it into your file system.

For example, if your web space and mysql space are the biggest parts, you can

  • stop mysql and webserver
  • move /var/lib/mysql and /var/www to your /mnt partition
  • replace these directories with symlinks to /mnt/mysql and /mnt/www
  • restart mysql and webserver

Don’t forget to backup your data, before playing around.

Leave a Reply

Your email address will not be published.