1

I am not too familiar with how volume sizing works, but I have a VPS running Ubuntu 14.04, and I noticed the home directory is all used up. I have a 1TB drive on this machine, how can I allocate more space to /home?

$ df
Filesystem            1K-blocks    Used Available Use% Mounted on
udev                    8186844       4   8186840   1% /dev
tmpfs                   1639632     572   1639060   1% /run
/dev/md1                4095616  378936   3716680  10% /
none                          4       0         4   0% /sys/fs/cgroup
none                       5120       0      5120   0% /run/lock
none                    8198144       4   8198140   1% /run/shm
none                     102400       0    102400   0% /run/user
/dev/mapper/vg00-usr    3997376  901812   2869468  24% /usr
/dev/mapper/vg00-var    3997376  550088   3221192  15% /var
/dev/mapper/vg00-home   3997376 3771276         4 100% /home
George L
  • 113
  • 2
    FYI it's not a directory you need to resize—it's a partition and/or logical volume, as well as the filesystem it contains. (Knowing keywords can help you in searching.) Hope you get the help you need. – Wildcard Jan 13 '16 at 02:14
  • It appears you're using LVM. Could you check with vgs if you have free space in your volume group vg00? If so, this is very easy, and you don't need to worry about any shrinking stuff in Thomas Dickey's answer. – derobert Jan 13 '16 at 03:59

1 Answers1

2

With a VPS, I assume you do not have physical access to the machine, so the usual approach to resizing an in-use filesystem will not work (that would be to use a rescue cdrom).

In your listing, the /dev/mapper/vgxxx mountpoints are the way LVM volumes are mounted.

Tutorials on LVM are fairly easy to find. The problem if you have used all of your space is that shrinking the volume group for a live filesystem is said to be risky.

If you cannot empty out /home then one way to rescue your system would be like this:

  • seeing that you have enough space one either /usr or /var to hold both filesystems,
  • you could copy all of /var to a temporary directory in the /usr tree, and
  • add a line in /etc/fstab to use a bind-mount to make that copy of /var mounted as /var.
  • comment-out the line in /etc/fstab for the "old" /var, reboot
  • You would lose "some" updates to /var (between copying and rebooting), but the reboot would get the system back to normal operation.
  • after rebooting, you could resize the (now-inactive) volume group where you have /var, and
  • add the space (physical volumes) to the group containing /home.

Still, making a backup first is always a good idea.

Further reading:

Per comment, you actually have unused space on your disk, so in this instance it is not necessary to shrink one volume to make room for another. I will leave the work-around suggested since it could be useful advice.

However - when simply growing a logical volume, you have to add space to the volume and then resize the filesystem (the part that you care about). LVM is three layers (seen with pvdisplay, vgdisplay and lvdisplay). If pvdisplay does not reflect your 1Tb, you will have to use fdisk to add a partition to the set of physical volumes. Then update the volume group, adding the physical volume. Finally use resize2fs to increase the size of the filesystem inside that volume group. Here are some useful links:

Thomas Dickey
  • 76,765