2
UPDATED-STATEMENT: 20190206@094017@WED Post created
UPDATED-STATEMENT: 20190208@153938@FRI Attempted to resize partition but unable to get more than 8GB for root or sda2 in my case
UPDATED-STATEMENT: 20190211@133954@MON Attempted to Rescan disk size, but get permission denied
Host: win7-x64-6.1.7601
Host-storage: 500gb with 250gb freespace
Virtualbox-version: 6.0.4.128413 [corrected]
Guest-os: Arch Linux x86_64
Guest-kernel: 4.20.5-arch1-1-ARCH
Guest-storage: (supposedly 20gb, but 8gb still shown and it's full at root partition)

Disk Size should never be underestimated as it's better to be safe than sorry

You'll learn to be more flexible if you can increase Virtualbox disk size

I've managed to install Arch Linux in Virtual Box as a guest and using Windows 7 as a host. It was good until I began to run out of space.

This is because I’ve chosen to use 8gb for my Virtual Size with everything else as typical setup through Virtual Box. So, this means I’m using the normal file.vdi type of Virtual Machine. The problem is I’m lacking space which began from me trying to refresh and update my Arch Linux via pacman -Syu to install packages but failed.

I did my research on how to get more disk space for my Arch Linux and came across 3-steps. These steps include resizing the disk, resizing the partition, and finally resizing the filesystem.

The resizing procedures vary between Virtual Box’s host/guest. I got stuck after the first step to resize disk and the issue is that I am unable to have Arch Linux see my HDD as 20GB as it's still showing 8GB. Why wouldn't my Guest OS see the increased size made by Virtual Box?

I'll explain what I’ve done so far and need to know the steps to continuing me through getting more disk space on my Arch Linux using Virtual Box as a Guest.

Problem

  • The modified disk size isn't recognized in Arch Linux after increasing disk size within Virtualbox as it still shows 8GB instead of the increased 20GB
    • How did I increase disk size for my vm-guest in Virtual Box?
      • use virtualboxmanager -> C:\Program Files\Oracle\VirtualBox\VBoxManage.exe modifyhd "path/to/archlinux.vdi" --resize 20000
    • How did I verify disk size for my vm-guest in Virtual Box?
    • How did I verify disk size for my vm-guest in Arch Linux?
      • Use archlinuxguest -> fdisk -l | grep sda.
      • Disk /dev/sda: 8 GiB, 8589934592 bytes, 16777216 sectors
        /dev/sda1      2048  1050623  1048576  512M EFI System
        /dev/sda2   1050624 12560383 11509760  5.5G Linux filesystem
        /dev/sda3  12560384 16777182  4216799    2G Linux swap
        
      • Use archlinuxguest -> df -Th to display root partition running out of space which is /dev/sda2.
      • Filesystem     Type      Size  Used Avail Use% Mounted on
        /dev/sda2      ext4      5.4G  5.0G  119M  98% /
        
  • The 2nd-step to increasing disk size in Virtual Box is to resize partition, another issue here is that I can't choose any size that exceeds 8GB limit.
    • Prepared to resize partition by disabling swap and deleted partitions sda2-root & sda3-swap while keeping boot partition which is EFI for sda1
      • root@archiso~# lsblk
            sda  8:0  0  8G  0 disk
              sda1  8:1  0  512M  0 disk
              sda2  8:2  0  5.5G  0 part
              sda3  8:3  0  2G    0 part
        
    • Attempted to enlarge sda2-root by removing sda2-root and sda3-swap then tried to create new partition for root but with a larger size this time, but unable to because 8GB is still the limit after resizing the disk
      • root@archiso~# gdisk /dev/sda
          (d 2 d 3)
          (n 2 FIRSTSECTOR blank LASTSECTOR 18G)
          Last sector (1050624-16777182, default = 16777182) or {+-}size{KMGTP}: _
        

Solution

  • None so far.

Note

  • How do you know that you don't have enough disk space for partitioning when using gdisk?
    • You'll be re-prompted without warning for inputting appropriate partition size regardless of first/last sectors.
  • When using Archlinux-boot-image for recovery or partitioning purposes; then, there's no need to be concerned for unmounting when working with your GPT partitioning scheme.
    • I used the archlinuxbootimage when working with hard-drives instead of doing it live on the PC I’m using and have to worry about unmounting and so forth
  • Why did you find out the HDD space in Arch Linux by grepping sda using fdisk -l?
    • The output is too much info at least now it's showing what drive I have, how much space is used up by each partition.
Giacomo1968
  • 58,727
fohrums
  • 540

1 Answers1

0

Before the partitioning tools can see the new disk size, you may need tell the disk controller driver to rescan the disk.

(If you use VMware or other "enterprise-grade" virtualization system with paravirtualized storage drivers, the host might be able to give the VM a hint that the disk size has been changed, and so it could be detected automatically. But apparently your version of VirtualBox does not do that.)

You could do this with:

echo 1 > /sys/block/sda/device/rescan

If successful, things like /proc/partitions or the lsblk command should already show the new size for the whole-disk device (your /dev/sda).

By the way, if you're really using VirtualBox 1.2, that's positively ancient: as of this writing, the current version of VirtualBox is 6.0.4.

telcoM
  • 5,167