17

I have Ubuntu 12.04 running on VirtualBox 4.2.4 in a Dynamic VDI disk with the limit set to 8gb on a real ext4 partition with more than 40gb of empty room available. However, the VDI it does not expand to the limit. 8gb is more than enough for what I want to do.

How do I make the rest of the space available? Available space in / and .home is 41kb.

vm

vdi

  • Is this a bug then? – jeremyjjbrown Nov 19 '12 at 1:59
  • My hack-ish solution was to just add another virtual drive. BTW I didn't test this myself, but this page suggests that the issue is caused by the fact that the swap partition is placed after the main partition. I'll try rearranging partitions next time I'm installing ubuntu guest and post a follow-up. – Андрей Беньковский Apr 4 '16 at 18:32
  • You probably made a partition that is too small, explaining the full disk. – Dr_Bunsen Jun 20 '19 at 9:20
2

I fixed my VirtualBox machine by setting the path on Windows 7 host machine to include the VirtualBox install directory (Steps):

  1. click start button
  2. Right click computer
  3. Click Properties
  4. Click Advanced System Settings
  5. On [Advanced] tab click [Environment Variables] button
  6. Under System Variables, scroll down to path and click [Edit]
  7. Add everything in quotes to end of line ";C:\Program Files\Oracle\VirtualBox\"
  8. Click [Ok]

Next move to the directory of the VirtualBox Disk (under username\VirtualBox VMs) taken from (https://forums.virtualbox.org/viewtopic.php?f=7&t=52351)

  1. open cmd and move to the VirtualBox drive
  2. enter this command: VBoxManage showhdinfo
  3. Take note of the UUID of the disk.
  4. enter this command: VBoxManage modifyhd UUID_of_the_VDI_disk --resize 80000 (this makes the disk 80 gigs, adjust to the size you want)

IMPORTANT STEPS START HERE: Next boot the Virtual machine on LiveCD (Install disk) (taken from Extending Ubuntu Partition size with the unallocated space (swap is between these two))

I can't stress this enough:

It is highly recommended to backup any important files before doing resize/move/extend operations.

The way to do it, is by deleting the swap partition, extend the partition that you want, and then re-create the swap partition.

Swap partition can only be deleted after swap is turned off:

SWAP off: sudo /sbin/swapoff -a SWAP on: sudo /sbin/swapon -a

The steps:

  1. Boot from the Ubuntu LiveCD
  2. Open terminal, and turn swap off
  3. Install GParted
  4. Extend the partiton that you want, but leave space for swap
  5. commit the changes
  6. create swap partition
  7. turn swap on

Note: If your swap is not your primary hard drive, then see SwapFaq on how to activate the swap partition

It is highly recommended to backup any important files before doing resize/move/extend operations.

| improve this answer | |
2

Had the same problem on Ubuntu 15.04 running Ubuntu Gnome 15.04 in a Virtual Machine. It seems that despite it being 'Dynamically allocated storage' VirtuaBox wasn't increasing it and I was down to my last 100MB and it wouldn't let me update via Software Updates. The solution was to perform the update via the terminal.

sudo apt-get upgrade

This seemed to force VirtualBox to create the additional storage, it jumped up to 500MB free as soon as the update started.

| improve this answer | |
  • That's really odd. I ran dpkg -i and apt-get update got a message about being out of space, but apt-get upgrade worked on Ubuntu Gnome 16.04 – Josiah Jun 1 '16 at 14:16
1

/tmp is going to be a tmpfs - i.e. a filesystem stored in RAM. So unless you assigned you have ~800MB free RAM in your VM, it isn't going to be enough to hold the ISO.

This is probably not what you intended: just save the ISO in a 'real' directory (e.g. /home/<username>) and it should work just fine.

| improve this answer | |
  • So if I am trying to load 1+GB of files into MongoDB and the VM memory is set to 1024 is it likely that I would be running into the same issue? – jeremyjjbrown Nov 19 '12 at 0:22
  • Where is the file stored? If it's disk-backed, then no - MongoDB should read the file in chunks and load it rather than loading the entire file at once. By storing your ISO in /tmp, you're forcing the OS to store the entire ISO in memory. – Jay Nov 19 '12 at 0:24
  • dbpath=/var/lib/mongodb I'm getting the computer is running out of disk space message from the OS. Apparently, my image was misleading. – jeremyjjbrown Nov 19 '12 at 0:26
1

It doesn't seem to be related to the growth of your virtual disk as you should have an error message from VirtualBox telling you that it can't allocate more disk space for your virtual disk.

Some ideas:

  • Did you use a special partitionning scheme in your VM?
  • What's the result of df -h in your VM?
  • You may use baobab to search what consumes all your / space.
| improve this answer | |
  • +1 for baobab. Although it did not tell me why the vdi won't grow it's going to be useful in the future. – jeremyjjbrown Nov 22 '12 at 1:02
  • Thanks. From what I can tell, your vdi don't grow because the OS inside don't need it to grow. I mean, surely your /tmp or even / filesystem is full in your VM. The filesystem won't expand by itself. What df -h tells you? – Christophe Drevet-Droguet Nov 22 '12 at 7:09
1

Try setting up a shared folder, it may be a solution to your problem.

  1. From VirtualBox enter your VM settings > shared folders and add a new one; choose the path in your host machine name it FOLDER_NAME and check Auto mount and make permanent.
  2. Install Guest additions; look at this to see how
  3. Make a folder on your guest VM to point to the folder created on the host, just create a new folder, for example /home/"your_user_name"/shared
  4. Mmount the shared folder: sudo mount -t vboxsf "FOLDER_NAME" /home/"your_user_name"/shared
  5. To make the mount automatic, add mount -t vboxsf "FOLDER_NAME" /home/"your_user_name"/shared" to the end of "/etc/rc.local" before "exit 0"
| improve this answer | |
1

VirtualBox Dynamic Disk Not Utilizing Available Free Disk Space to Grow Partition Automatically

This post was written for Ubuntu Server 18.04 Guest OS running on Virtualbox 6.1.6.

I believe that the correct description to this problem should be something along the lines of this:

"Although a 32GB dynamic disk was created, the OS partition hit a "disk full" message at around 4GB and wasn't able to automatically increase its size by utilizing the "free" 28GB from the 32GB dynamic disk."

If this is the problem you encountered, and you had setup the Guest OS using Ubuntu Linux and LVM (and EXT4 filesystem), then the solution to this problem is to use lvextend and resize2fs commands. See my solution and description below:

Start up the VM and login. Once in, open up a terminal.

  1. Display information about allocated disk storage:

    $ df -h

    Filesystem Size Used Avail Use% Mounted on
    udev 966M 0 966M 0% /dev
    tmpfs 200M 1.1M 199M 1% /run
    /dev/mapper/ubuntu--vg-ubuntu--lv 3.9G 2.9G 835M 78% /
    tmpfs 997M 0 997M 0% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    tmpfs 997M 0 997M 0% /sys/fs/cgroup
    /dev/loop0 97M 97M 0 100% /snap/core/9436
    /dev/loop1 97M 97M 0 100% /snap/core/9665
    /dev/sda2 976M 212M 697M 24% /boot
    tmpfs 200M 0 200M 0% /run/user/1000

The output shows the root partition (/) has a size of 3.9G and that 2.9G (78%) is used.

  1. Display information on block devices:

    $ lsblk

    NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    loop0 7:0 0 96.5M 1 loop /snap/core/9436
    loop1 7:1 0 97M 1 loop /snap/core/9665
    sda 8:0 0 32G 0 disk
    ├─sda1 8:1 0 1M 0 part
    ├─sda2 8:2 0 1G 0 part /boot
    └─sda3 8:3 0 31G 0 part
    └─ubuntu--vg-ubuntu--lv 253:0 0 4G 0 lvm /
    sr0 11:0 1 1024M 0 rom

The output shows that block device sda has a physical size of 32GB. It contains 3 partitions (sda1, sda2 and sda3). The root partition (/) mounted on the logical volume of sda3 only has 4GB allocated storage. This means that there is still approximately 27GB of unallocated (free) storage that we can use to grow the LVM's logical volume.

  1. Display filesystem information on the block devices:

    $ lsblk --fs

    NAME FSTYPE LABEL UUID MOUNTPOINT
    loop0 squashfs /snap/core/9436
    loop1 squashfs /snap/core/9665
    sda
    ├─sda1
    ├─sda2 ext4 7cafee4a-d300-4b17-957d-c822c73882fc /boot
    └─sda3 LVM2_member GwPZus-EMpD-BgZw-e1Nx-Fd9J-LLeN-XnbvEE └─ubuntu--vg-ubuntu--lv ext4 dcc015b4-b6b8-4e05-9a18-93c263cc05ed /
    sr0

    The output shows that filesystem of the lvm root partition is ext4.

  2. Display information about physical volume:

    $ sudo pvs

    PV VG Fmt Attr PSize PFree
    /dev/sda3 ubuntu-vg lvm2 a-- <31.00g <27.00g

    $ sudo pvdisplay

    --- Physical volume --- PV Name /dev/sda3
    VG Name ubuntu-vg
    PV Size <31.00 GiB / not usable 0
    Allocatable yes
    PE Size 4.00 MiB
    Total PE 7935
    Free PE 6911
    Allocated PE 1024
    PV UUID GwPZus-EMpD-BgZw-e1Nx-Fd9J-LLeN-XnbvEE

    The output provides another perspective on the allocated / unallocated space on LVM PV sda3.

  3. Display information about volume group:

    $ sudo vgs

    VG #PV #LV #SN Attr VSize VFree
    ubuntu-vg 1 1 0 wz--n- <31.00g <27.00g

    $ sudo vgdisplay

    --- Volume group --- VG Name ubuntu-vg
    System ID
    Format lvm2
    Metadata Areas 1
    Metadata Sequence No 2
    VG Access read/write
    VG Status resizable
    MAX LV 0
    Cur LV 1
    Open LV 1
    Max PV 0
    Cur PV 1
    Act PV 1
    VG Size <31.00 GiB
    PE Size 4.00 MiB
    Total PE 7935
    Alloc PE / Size 1024 / 4.00 GiB
    Free PE / Size 6911 / <27.00 GiB
    VG UUID vBmSeb-VWR8-7A8n-CBSa-UnKd-FmJG-LTtMUG

    The output shows that the VG size is the same as the PV size (31GB), and that it has 27GB of unallocated free storage to grow the logical volume.

  4. Display information about the logical volume:

    $ sudo lvs

    LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
    ubuntu-lv ubuntu-vg -wi-ao---- 4.00g

    $ sudo lvdisplay

    --- Logical volume ---
    LV Path /dev/ubuntu-vg/ubuntu-lv
    LV Name ubuntu-lv
    VG Name ubuntu-vg
    LV UUID pnvBcu-FnfT-c3RY-cYCE-AuMX-f833-57WvYi
    LV Write Access read/write
    LV Creation host, time ubuntu-server, 2020-07-01 00:00:58 +0000
    LV Status available
    #open 1
    LV Size 4.00 GiB
    Current LE 1024
    Segments 1
    Allocation inherit
    Read ahead sectors auto
    -currently set to 256
    Block device 253:0

    The output shows that the LV size is 4GB. Since the VG size is 31GB, we can grow the LV by another 27GB.

7a. To grow the logical volume (ubuntu-lv) by using 50% (13GB) of the free unallocated space, first do:

$ sudo lvextend -l+50%free /dev/ubuntu-vg/ubuntu-lv

Size of logical volume ubuntu-vg/ubuntu-lv changed from 4.00 GiB (1024 extents) to 17.50 GiB (4480 extents).
Logical volume ubuntu-vg/ubuntu-lv successfully resized.


The output shows that the logical volume has grown from 4GB to 17.5GB (approximately 13GB).

7b. Finally, to let the EXT4 filesystem become aware of the expanded storage, run command:

$ sudo resize2fs /dev/ubuntu-vg/ubuntu-lv

resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/ubuntu-vg/ubuntu-lv is mounted on /; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 3
The filesystem on /dev/ubuntu-vg/ubuntu-lv is now 4587520 (4k) blocks long.
  1. Display information about allocated disk storage again to check the new disk storage space:

    $ df -h

    Filesystem Size Used Avail Use% Mounted on
    udev 966M 0 966M 0% /dev
    tmpfs 200M 1.1M 199M 1% /run
    /dev/mapper/ubuntu--vg-ubuntu--lv 18G 2.9G 14G 18% /
    tmpfs 997M 0 997M 0% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    tmpfs 997M 0 997M 0% /sys/fs/cgroup
    /dev/loop0 97M 97M 0 100% /snap/core/9436
    /dev/loop1 97M 97M 0 100% /snap/core/9665
    /dev/sda2 976M 212M 697M 24% /boot
    tmpfs 200M 0 200M 0% /run/user/1000

    The output shows that the size of the logical volume has now grown to 18GB (from its earlier 4GB)

| improve this answer | |
0

You can use this easy solution: In your Terminal type this command

VBoxManage.exe modifyhd "path-of-your-disk" --resize 20000

You can find the path of your disk under the configuration of your VM / storage / yourVM.vbi (path on the right)

| improve this answer | |
  • He probably made an partition in the VM, thus resizing the disk has only an influence on the host. – Dr_Bunsen Jun 20 '19 at 9:20
  • So it's not about the hypervisor ! he should modify the partition inside the VM...!! – omarhamdaoui Jun 21 '19 at 10:17
  • That is indeed what I meant. – Dr_Bunsen Jun 21 '19 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.