0

I am running Ubuntu on VirtualBox. I've allocated around 100GB of disk space for the OS, yet whenever I try and download an application (i.e. VSCode), I get an error that my disk usage is high and I am out of memory. I've only downloaded a few things such as Chrome, and Nodejs so I'm not sure why it's saying I am out of memory.

Just a caveat, I am very new to Linux.

Edit: My native OS is Windows 11 if that matters.

This is my disk usage

The 100GB I allocated to the OS

 johnDoe@johnDoe-VirtualBox:~$ df -k
 Filesystem     1K-blocks    Used Available Use% Mounted on
 udev             4758972       0   4758972   0% /dev
 tmpfs             958488   49440    909048   6% /run
 /dev/sda5        9736500 9720116         0 100% /
 tmpfs            4792440   50140   4742300   2% /dev/shm
 tmpfs               5120       4      5116   1% /run/lock
 tmpfs            4792440       0   4792440   0% /sys/fs/cgroup
 /dev/loop0           128     128         0 100% /snap/bare/5
 /dev/loop1         55552   55552         0 100% /snap/snap-store/558
 /dev/loop2        224256  224256         0 100% /snap/gnome-3-34-1804/77
 /dev/loop4         52224   52224         0 100% /snap/snap-store/547
 /dev/loop6         66688   66688         0 100% /snap/gtk-common-themes/1515
 /dev/loop7        224256  224256         0 100% /snap/gnome-3-34-1804/72
 /dev/loop8         56960   56960         0 100% /snap/core18/2284
 /dev/loop9         66816   66816         0 100% /snap/gtk-common-themes/1519
 /dev/loop10        63488   63488         0 100% /snap/core20/1328
 /dev/loop11       253952  253952         0 100% /snap/gnome-3-38-2004/87
 /dev/loop12        56832   56832         0 100% /snap/core18/2128
 /dev/sda1         523248       4    523244   1% /boot/efi
 tmpfs             958488      12    958476   1% /run/user/125
 tmpfs             958488      48    958440   1% /run/user/1000
 /dev/loop13       254848  254848         0 100% /snap/gnome-3-38-2004/99
 /dev/loop14        44672   44672         0 100% /snap/snapd/14978
 /dev/loop3        113536  113536         0 100% /snap/core/12725
 /dev/loop5        217344  217344         0 100% /snap/code/88

2 Answers2

3

This question seems to have caused quite a bit of confusion. Perhaps the information provided has changed since it was originally posted. So what do we know?

  • The disk usage analyser shows the root partition at just under 10GB and virtually full.
  • The VB media manager shows the entire disk to be about 100GB and about 9GB used.
  • df -k shows only two partitions, sda1 and sda5. sda1 is mounted at /boot/efi and contains virtually nothing. sda5 is the root partition and it confirms that it is about 10GB and virtually full.

There are two possibilities here:

  1. That the 100GB disk has 90GB of unused space or other partitions
  2. That sda5 partition is actually about 100GB in size but the filesystem inside it is only 10GB

To fix the first possibility you need to boot into a live session and use GParted to add unused space to sda5

To fix the second possibility you simply need to resize the filesystem. Since you will be expanding it this can be done while the root partition is mounted

sudo resize2fs /dev/sda5

You can confirm which of these possibilities it is by running GParted and examining the sda device. If you are still not sure add the output of lsblk to your question

Good luck

PonJar
  • 1,973
0

Sorry, I just read your question, I will spare no effort to help you.

Just as your second photo shows, the Virtual Size 100GB is the size of your VM oobuntu's space, that you can set it via VirtualBox on your Host Windows 11 machine. the Actual Size 8.94GB is the size of your VM oobuntu's disk space, that you only need to set on your VM oobuntu via APP liking GParted or partition tools at terminal.

Just as your df -k outputs, the main/primary partition of your VM oobuntu's disk is /dev/sda1 which mounted at boot directory /boot/efi and partition files type is FAT32; the logical partition of your VM oobuntu's disk is /dev/sda5 which mounted at root directory / and partition file type is ext4; Also, I guess your extended partition of your VM oobuntu's disk is /dev/sda2, but I do not see that /dev/sda2 from your given photos or command output.

As I know,

Principle-A: Size(vm_disk) == Size(main partition) + Size(extended partition);

Principle-B: Size(extended partition) == All the Size(logical partition);

Principle-C: Size(logical partition) <= Size(extended partition);

So, if you want to expand your VM oobuntu's Disk size, you should expand logical partition /dev/sda5; but you should firstly enlarge your extended partition /dev/sda2 before you start to resize your logical partition /dev/sda5. And, I have a question: where is your extended partition /dev/sda2? I do not know.

This does not have any matter with your Host Windows 11 machine. Microsoft said it was innocent.

Just use sudo cfdisk to check the usage of your VM oobuntu's disk partitions, I guess you output based with your command df -kjust liking below :

Disk /dev/sda: 100 GiB, 122212254720 bytes, 182914560 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x40r3tr86

Device Boot Start End Sectors Size Id Type /dev/sda1 * 220M 732M 1096800 512M c W95 FAT32 (LBA) /dev/sda2 732M 10G 19968020 9.29G 5 Extended /dev/sda5 732M 10G 19968020 9.29G 83 Linux free space 10G 100G 90GB

And I think your needed disk partition likes this:

Disk /dev/sda: 100 GiB, 122212254720 bytes, 182914560 sectors
Disk model: VBOX HARDDISK
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x40r3tr86

Device Boot Start End Sectors Size Id Type /dev/sda1 * 220M 732M 1096800 512M c W95 FAT32 (LBA) /dev/sda2 732M 100G 19968020 90.29G 5 Extended /dev/sda5 732M 100G 19968020 90.29G 83 Linux

Also, I do highly recommend you use partition tool cfdisk instead of APP GParted or partition tool parted.

Solution:

1.just log in your VM;

2.use sudo cfdisk to enter the permission of cfdisk on your VM oobuntu's terminal;

Use up and down direction button to choose the partition, use right and left direction button to choose the operation, use enter button to make sure.

3.choose Resize button to expand the extended partition /dev/sda2, change default size into 90.29GB, and push enter, and again type yes, and push enter to ok;

4.choose Resize button to enlarge the logical partition /dev/sda5, also, change default size into 90.29GB, and push enter, and again type yes, and push enter to ok;

5.choose Write button to sync the new partition to the Disk, and use Quit button to quit cfdisk;

6.use sudo resize2fs /dev/sda5 on your VM oobuntu's terminal to set all the file types of logical partition /dev/sda5 into ext4;

7.Restart or reboot your virtual machine: sudo reboot.

Have fun!!!

OVER!