0

I have a virtual machine (on Hyper-V host) running Ubuntu server 16.04.3. It is set up to have dynamically expanding virtual hard disk (VHDX).

I have disk space issues when trying to "tab-complete" names:

-bash: cannot create temp file for here-document: No space left on device

I asked df -h and here is what the server responded:

Filesystem                 Size  Used Avail Use% Mounted on
udev                       221M     0  221M   0% /dev
tmpfs                       48M  1.8M   47M   4% /run
/dev/mapper/zapp--vg-root  2.0G  2.0G     0 100% /
tmpfs                      240M     0  240M   0% /dev/shm
tmpfs                      5.0M     0  5.0M   0% /run/lock
tmpfs                      240M     0  240M   0% /sys/fs/cgroup
/dev/sda1                  472M   70M  379M  16% /boot
tmpfs                       48M     0   48M   0% /run/user/1000

Obviously, that 2.0G partition is full. However, the virtual disk hadn't reached the size allowed size (3.0GB max, 2.69GB real).

We tried to expand the disk limit to 5GB, but the server doesn't seem to notice and use the available space - even after a restart.

Is it possible to allow these partitions to expand when needed until the cap of disk size is reached? Or what should be done here?

3
  • I don't know about Hyper-V, but the way VirtualBox does dynamic virtual disks is that the guest sees the drive as the maximum size, even though the file on the host is dynamic.
    – wjandrea
    Dec 6, 2017 at 20:35
  • Yeah, the guest sees sda as having 5GB now. I was hoping the partitions could take up more space as needed, is that not possible?
    – Džuris
    Dec 6, 2017 at 20:43
  • I meant to say that you can avoid this issue in the future by setting the max VHD size higher, and it won't actually take up more space on the host unless the guest needs it.
    – wjandrea
    Dec 6, 2017 at 21:36

2 Answers 2

2

First you need to run parted and use its resizepart command to expand the partition to use the whole disk, then run pvresize to tell LVM about the new space, then run lvresize to grow the logical volume, and finally resize2fs on the logical volume to grow the filesystem to use the new space. This can be done without a reboot.

1

If the machine sees the expanded space, and if you're using LVM (which appears to be the case), then you can use the lvresize command to resize the partition to fill up the new space. This does not happen automatically.

You'll want to become familiar with the man page of lvresize, and in particular the --resizefs and --size switches.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .