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
  • 1
    You are mixing up ram with hard disk space. Memory is ram. – David Feb 21 '22 at 15:46
  • @David thanks for the response. However, how would I go about adding addition memory? I'm quite new to Linux so still quite confused. – BubbleLover2000 Feb 21 '22 at 15:55
  • 1
    @BubbleLover2000 It looks that you allocated only 1 GB of memory to your virtual machine in VirtualBox. You should allocate more. Did you enable swapping in your system and created a swap file or swap partition while installing? Swapping is essential if you have little RAM available. – raj Feb 21 '22 at 15:56
  • You are still confused the error says you are out of HARD DISK space if you can not install. – David Feb 21 '22 at 15:59
  • Please [edit] your question and copy&paste the exact error message and the output of df -k as text. – Bodo Feb 21 '22 at 16:00
  • 2
    Was the virtual disk expanded to 100GB after installing Ubuntu? If so, you’ll need to resize the disk in order to get access to all 100GB – matigo Feb 21 '22 at 16:07
  • @matigo thanks for the response! And yes, I did allocate the memory after installing Ubuntu. I clicked the link you linked, and I'm having some trouble understanding the command: "VBoxManage modifyhd YOUR_HARD_DISK.vdi --resize SIZE_IN_MB".

    The commentor says to replace the "YOUR_HARD_DISK" part of the command "with your image". I'm not exactly sure what that means.

    – BubbleLover2000 Feb 21 '22 at 16:15
  • @Bodo, I've updated the post with the output of the df -k message output. I've also shown what happens when I input the commend: "sudo apt update". I get failed messages due to no space left on device – BubbleLover2000 Feb 21 '22 at 16:29
  • @BubbleLover2000 Please don't post images of text. Copy&paste source code, error messages, commands and output etc. to your question as text and format it as a code block. According to df -k your root file system is less than 10 GByte and it is 100% full. This corresponds to the graphical representation. – Bodo Feb 21 '22 at 17:02
  • 1
    @BubbleLover2000 If you resized the virtual disk after installing Linux, you need to resize the partition as well. Boot the VM from a Linux live ISO image, run gparted and change the size. Note that this is a dangerous operation which can result in losing all the data of the (virtual) disk if something goes wrong. – Bodo Feb 21 '22 at 17:13
  • @Bodo Apologies for uploading an image of text. So I found out that I did indeed allocate additional memory (100GB), however, I needed to resize my Filesystem partition. I tried doing that an came across the error: Error resizing partition. The error is called "(udisks-error-quark, 3)" The description of the error says I am not authorized to perform this operation.

    Should I try and resolve that issue, or should I do the solution you suggested of booting the VM from a Linux live ISO? If the latter, would you be able to walk me through or direct me on how to perform that? Much appreciated.

    – BubbleLover2000 Feb 21 '22 at 17:25
  • @Bodo Would the video linked below be an example of what you are in reference to? https://www.youtube.com/watch?v=mXDjhUyHrWM – BubbleLover2000 Feb 21 '22 at 17:31
  • @BubbleLover2000 Don't apologize, fix your question instead. Please add all your background information or additional questions to your question, don't use comments for this purpose. The video is not exactly what you need, but similar. (I did not watch the full video.) You have to resize the root (/) partition, not a swap partition. Depending on your current partitioning you might have to move a swap partition if there is one after your root partition. – Bodo Feb 21 '22 at 17:36
  • @Bodo I've updated the question with the df -k text output. Is there anyway else I should update my question? Also, another commentor linked me to the following post: (https://askubuntu.com/questions/88647/how-do-i-increase-the-hard-disk-size-of-the-virtual-machine/88651#88651). Would you say this is pertaining to the issue I am facing? – BubbleLover2000 Feb 21 '22 at 18:01
  • The question and answer contain further references, e.g. https://askubuntu.com/a/558215/1186757 leads to https://tinyapps.org/blog/201204120700_virtualbox_increase_disk_space.html which might help for your use case. Note that you must not resize a mounted partition (a partition from which you are running your system). That's why boot from a live Linux image to run gparted. – Bodo Feb 21 '22 at 18:07
  • 4
    The df -k shows that partition /dev/sdb1, mounted as /, is 100% full. You've only allocated around 10GB for the system. You probably need around 40GB disk space for Ubuntu – waltinator Feb 21 '22 at 19:59
  • It is a lack of memory ( RAM ) not a lack a harddisk space. – HomerSimpson Feb 22 '22 at 08:34

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,868
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!