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 Archlinux in Virtualbox 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 Virtualbox. 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 & Update my archlinux via pacman -Syu to install packages but failed. I did my research on how to get more disk space for my Archlinux and came across 3-steps. These steps include resizing the disk, resizing the partition, & finally resizing the filesystem. The resizing procedures vary between Virtualbox's Host/Guest. I got stuck after the first step to resize disk and the issue is that I am unable to have Archlinux see my HDD as 20GB as it's still showing 8GB. Why wouldn't my Guest OS see the increased size made by Virtualbox?

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 Archlinux using Virtualbox as a Guest.

PROBLEM

  • The modified disk size isn't recognized in Archlinux 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 Virtualbox?
      • 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 Virtualbox?
    • How did I verify disk size for my vm-guest in Archlinux?
      • 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 Virtualbox 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 & 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 Archlinux 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
  • So you are stuck on your second step, resizing the partitions? Try the GParted ISO and boot from that. Once you have extended your partitions you can extend filesystem using resize2fs while booted into Arch. – lx07 Feb 6 at 0:23
  • I thought extending partitions can be done while still in the Linux OS in-use without unmounting even. But besides that, why continue to extend partition if my drive still shows 8gb and not the 20gb that's supposedly increased? – fohrums Feb 6 at 0:30
  • 1
    It shows 8GB because that is what the partition table says. You could change it within Linux using gdisk. You'd want to disable swap, delete partitions table entries for partitions 2 and 3, then recreate sda2 starting at same block but make it bigger, then add sda3 again. – lx07 Feb 6 at 0:42
  • And you may also have to relocate the backup GPT partition table to the end of the disk. You can do this with gdisk (option x then e) or with sgdisk as descriped here wiki.archlinux.org/index.php/Gdisk#Expand_a_GPT_disk – lx07 Feb 6 at 0:50
  • 1
    stuck with same problem. – balki Mar 6 at 0:47
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.

  • I just realized the version I put was wrong. My Virtualbox isn't ver1.2 but it is v6.0.4 which I corrected in my post. I get permission denied when editing the rescan-file. I even went root via su and it's giving me no authorization to edit it (same for re-logging in didn't help). – fohrums Feb 11 at 3:40
  • Don't use an editor, just use the exact command I suggested, as root. – telcoM Feb 11 at 12:07
  • I've already tried and it's not working as root. Do I need to have to change any permissions via chown/chgrp/chmod? I'm concerned because this is under the /sys/ directory and it'll be hard to keep track of any permission changes from there. – fohrums Feb 12 at 0:09
  • chown/chgrp/chmod will often be ineffective in /sys, as the "permissions" are a reflection of what manipulations of the kernel's drivers and data structures are allowed. If the command is being rejected, then the storage driver is not accepting the rescan request for some reason. Is there any messages about it in dmesg output? – telcoM Feb 12 at 0:15
  • dmesg gives me no updates regarding my disk after running echo 1 > /sys/block/sda/device/rescan as root since sudo doesn't work for the sys-dir for me. The last lines isn't anything about disk so I went ahead and did dmesg | grep sda and from there it showed nothing. Is there a particular way to verify rescan through dmesg? – fohrums Feb 22 at 5:05

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.