Page 1 of 1
Ubuntu VM with Dynamic Allocation not growing
Posted: 13. Jun 2020, 13:42
by QJack
I have installed a VM with 10GB of diskspace (SATA Controller), configured for dyanamic allocation.
I went to update my Linux VM and it's telling me I am out of disk space. It's showing (df -h) Used 3.9GB Available 0. I am also using LVM on my Ubuntu 18.04 guest.
The current VDI file is 4 GB, and I would assume that the virtualbox service would allocate more disk space, because I should have 6GB available for it to grow.
I have made certain that my host has plenty of disk space, so at this point what are my options?
Thank you!
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 13. Jun 2020, 14:13
by mpack
If you only allocate a 10GB drive, and if it's a Linux guest, then you'll immediately lose half of that to a swap partition (whose size is related to available disk space and PC RAM).
VirtualBox doesn't grow the disk by magic. As the "dynamic allocation" name suggests, VirtualBox allocates host space to a section of a virtual drive when the VM writes to that section of the drive for the first time. If the VM
never writes to that section then no host space is ever allocated for it, this is precisely what we want from a "dynamic" container format. Under no circumstances will the drive
capacity ever change, unless of course you resize the container (see below).
So, it sounds like you have a big swap partition that is mainly unused, I guess you don't run a lot of memory hogs.
See
How to resize a Virtual Drive. I'll leave you to do your own research on guest OS matters, such as choosing a size for Mint's swap partition.
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 15. Jun 2020, 01:44
by QJack
mpack wrote:If you only allocate a 10GB drive, and if it's a Linux guest, then you'll immediately lose half of that to a swap partition (whose size is related to available disk space and PC RAM).
So, it sounds like you have a big swap partition that is mainly unused, I guess you don't run a lot of memory hogs.
See
How to resize a Virtual Drive. I'll leave you to do your own research on guest OS matters, such as choosing a size for Mint's swap partition.
Thanks, mpack. I thought that too, but my swap space is only half a gig and not really being used.
Code: Select all
NAME TYPE SIZE USED PRIO
/swap.img file 553M 268K -
Fdisk absolutely reports my drive and partitions correctly.
Code: Select all
Device Start End Sectors Size Type
/dev/sda1 2048 4095 2048 1M BIOS boot
/dev/sda2 4096 2101247 2097152 1G Linux filesystem
/dev/sda3 2101248 20969471 18868224 9G Linux filesystem
Now, I've already resized my drive, but I need to be able to install something like partd to be able to resize my partition (no space on disk), but I shouldn't have to because I should see more available space, no? I could totally be understanding how things work.
Cheers!
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 15. Jun 2020, 08:56
by mpack
Read the FAQ carefully, noting step 2.
How to resize a Virtual Drive. The whole point of a FAQ is that I don't have to manually repeat the information for every new person that comes along... and I'm not going to do that.
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 16. Jun 2020, 12:29
by QJack
mpack,
You must have misread...I stated that I already resized my partition, I don't need you to explain it to me. My question, so this doesn't happen again, is why my guest out of disk space and not growing like I thought it should.
You recommended it's a Swap Space reservation of half the allocated disk. I replied with my swap space size which wasn't half, and as a matter of fact I turned it off.
If my total size is 10GB disk, and the partitions are divvied up accordingly, then I should have more than 4 GB allocated to /dev/sda3 which is seen as 9GB but the guest OS
is failing. My point was I shouldn't have had to resize, and if that is what I needed to do, WHY?
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 16. Jun 2020, 13:35
by mpack
QJack wrote:My question, so this doesn't happen again, is why my guest out of disk space and not growing like I thought it should.
What are you asking? Drives never "grow". What OS expects or could cope with a drive that change capacity when written to? "Dynamic" refers to allocation of existing capacity, not increase in capacity. The capacity never changes. I already explained this in my first reply.
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 16. Jun 2020, 17:48
by QJack
OK, it may be just my misunderstanding of how I think Dynamic works.
I thought that if I told my VM to have a storage capacity of 10 GB, let's say, and selected "dynamic", that the VDI file won't pre-allocate the full 10 GB.
My thought was that the VM manager would increase UP TO 10 GB as it needs to and that the guest OS would see that the disk is sized for 10GB. The guest OS partition table definitely does see it this way.
I thought that if my guest OS was truly out of space, my raw VDI file would be ~10GB, but it's not. It's only ~4GB.
If that isn't the case, then why not just pre-allocate all the disk at once?
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 16. Jun 2020, 18:04
by scottgus1
Your understanding of Virtualbox Dynamic is correct. The Dynamic disk has a maximum size. At the beginning, the disk file on the host drive is nothing more than headers & such. Couple of megabytes.
As the guest OS puts data into it's "disk", the disk file on the host gets bigger. The dynamic file can get as big as the size chosen for the disk file when the dynamic disk was made. If the dynamic disk was made to be 10GB final size, it will grow to 10GB max. No bigger.
If the guest OS makes partitions inside the guest "disk", these partitions control how large the data inside the partition can get. If a guest OS makes a 4GB data partition and a 6GB swap partition in the 10GB dynamic disk, then the 4GB data partition will be full when there's 4GB of data in it, even though the 6GB swap partition is still not much used. If the guest OS made use of 1GB of the swap partition too, then the dynamic disk file would be 5GB in size. However, the guest OS will report "full disk", even though the swap is not being fully used and the dynamic disk file has not grown to 10GB, because the data partition is full. The disk file will not increase beyond 5GB unless the guest OS decides to use more swap.
If you want to make more room for this guest to grow, you will need to resize the dynamic disk. See Mpack's link on "How to Resize a Virtual Drive". Roughly speaking, you run a command on the dynamic disk file from the host to change the maximum size it can grow, then alter the partitions in the guest OS to make use of the new space. (Take a backup copy of the disk file before doing anything to it.)
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 16. Jun 2020, 18:27
by QJack
scottgus1 wrote:
If the guest OS makes partitions inside the guest "disk", these partitions control how large the data inside the partition can get. If a guest OS makes a 4GB data partition and a 6GB swap partition in the 10GB dynamic disk, then the 4GB data partition will be full when there's 4GB of data in it, even though the 6GB swap partition is still not much used. If the guest OS made use of 1GB of the swap partition too, then the dynamic disk file would be 5GB in size. However, the guest OS will report "full disk", even though the swap is not being fully used and the dynamic disk file has not grown to 10GB, because the data partition is full. The disk file will not increase beyond 5GB unless the guest OS decides to use more swap.
If you want to make more room for this guest to grow, you will need to resize the dynamic disk. See Mpack's link on "How to Resize a Virtual Drive". Roughly speaking, you run a command on the dynamic disk file from the host to change the maximum size it can grow, then alter the partitions in the guest OS to make use of the new space. (Take a backup copy of the disk file before doing anything to it.)
scottgus1,
Appreciate you stepping in here. Again, I've already resized my partition, etc. What I'm trying to figure out is why I had to do a resize because my VDI file only had a size of ~4GB when I had specified 10GB. I understand the Swap, but it was only set to be ~256MB max, not 6GB. Even if were 6GB, wouldn't my VDI file be ~10GB?
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 16. Jun 2020, 18:38
by scottgus1
Good question. I see you posted your partition layout, I missed that earlier. It certainly seems like there's more space available. Does Linux hide system files so they don't show in the file browser but still takes space, like Windows does?
Can you show a report of the partitions saying how much data is on them & how much free?
Also, please post the command output of:
vboxmanage showmediuminfo "path//to/dynamic/disk/file"
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 16. Jun 2020, 20:39
by multiOS
For info.: Linux does store previous package versions replaced by updates as well as 'old' Linux kernels in case the user needs/wants to 'roll back' to earlier versions. The user has to clean the system regularly to delete those files, much the same as with Windows 10. The method for cleaning the linux system depends on the distro.
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 17. Jun 2020, 13:01
by QJack
multiOS wrote:For info.: Linux does store previous package versions replaced by updates as well as 'old' Linux kernels in case the user needs/wants to 'roll back' to earlier versions. The user has to clean the system regularly to delete those files, much the same as with Windows 10. The method for cleaning the linux system depends on the distro.
Depends on the distro, but either way, that would consume disk space and the VDI file should represent that. You can't hide without it taking up disk.
Re: Ubuntu VM with Dynamic Allocation not growing
Posted: 17. Jun 2020, 13:09
by QJack
scottgus1 wrote:Good question. I see you posted your partition layout, I missed that earlier. It certainly seems like there's more space available. Does Linux hide system files so they don't show in the file browser but still takes space, like Windows does?
Can you show a report of the partitions saying how much data is on them & how much free?
Also, please post the command output of:
vboxmanage showmediuminfo "path//to/dynamic/disk/file"
As I mentioned in the reply to the other user, even if it did hide files, it would take up disk space and the VDI would reflect such.
Unfortunately, I've already resized my partition, etc. But, if it has happened once, then it will happen again (hope not). I certainly am moving forward though with just
pre-allocating disk space. lol.
Thanks, scottgus1. I'm glad you took time to understand my question and did not berate me.
For the moderator, my advice is not to make assumptions of what's being asked. If you don't understand the question ask for clarification. If you don't have the patience for such, perhaps consider resigning the duties to another.