2

I'm facing a problem with my virtual disk in VirtualBox, on a Linux CentOS Guest. I don't use snapshots on it.

It was initially a 8GB disk, which I expanded to 16GB using VBoxManage modifyhd command within the host. I then used a GParted live image to resize the partition within the guest. The disk and VM changed host (but same version of VirtualBox).

Now I have filled up my disk and have no space left.

Looking at GParted: /boot (/dev/sda1) has a size of 1GB, and / (/dev/sda2) has a size of 15GB: GParted live

But looking at df:

[ted@localhost ~]$ df -Th
Filesystem          Type       Size    Used Avail Use% Mounted on
/dev/mapper/cl-root xfs        6,0G    5,9G  106M  99% /
devtmpfs            devtmpfs   986M       0  986M   0% /dev
tmpfs               tmpfs     1001M    100K 1001M   1% /dev/shm
tmpfs               tmpfs     1001M    8,8M  992M   1% /run
tmpfs               tmpfs     1001M       0 1001M   0% /sys/fs/cgroup
tmpfs               tmpfs     1001M     32K 1001M   1% /tmp
/dev/sda1           xfs       1014M    235M  780M  24% /boot
tmpfs               tmpfs      201M    8,0K  201M   1% /run/user/1000

The size of root is 6GB, confirmed by fdisk -l. But the size of disk is indeed 16+GB:

[ted@localhost ~]$ sudo fdisk -l

Disk /dev/sda: 17.2 GB, 17179869184 bytes, 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000140ff

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    33554431    15727616   8e  Linux LVM

Disk /dev/mapper/cl-root: 6442 MB, 6442450944 bytes, 12582912 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk /dev/mapper/cl-swap: 1069 MB, 1069547520 bytes, 2088960 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

Just to clear that out, tmpfs partitions are mounted in the RAM, right? There's no way those files use disk space, is there?

Also, I have plenty of space on host disk.

I saw this post Make Linux VirtualBox Guest use all Virtual Disk Available (no snapshots) but my situation seems a bit different, since I resized the partition and the space is seen in pvdisplay:

[tnodet@localhost ~]$ sudo pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               cl
  PV Size               15,00 GiB / not usable 2,00 MiB
  Allocatable           yes 
  PE Size               4,00 MiB
  Total PE              3839
  Free PE               2048
  Allocated PE          1791
  PV UUID               rrG0JE-i1MB-IeA0-Ce5c-dpj7-Fwm2-RMjyYb

On Windows 10 host:

D:\Profiles\ted\VirtualBox VMs\CentOS-CKAN>VBoxManage showhdinfo CentOS-CKAN.vdi
UUID:           76d3524e-803c-4d1e-816d-5bc705e26aac
Parent UUID:    base
State:          locked write
Type:           writethrough
Location:       d:\Profiles\ted\VirtualBox VMs\CentOS-CKAN\CentOS-CKAN.vdi
Storage format: VDI
Format variant: dynamic default
Capacity:       16384 MBytes
Size on disk:   6413 MBytes
Encryption:     disabled
In use by VMs:  CentOS-CKAN (UUID: 1e96120c-17a3-4892-8d98-dd88eed429db)

I'm lost and quiet confused right now, I can't even figure out if the problem comes from the Windows host / VirtualBox, or from the Linux guest...

Any ideas? Thanks in advance!


Other commands:

[ted@localhost ~]$ ll /dev/disk/by-id
total 0
lrwxrwxrwx. 1 root root  9 20 sept. 12:16 ata-VBOX_CD-ROM_VB2-01700376 -> ../../sr0
lrwxrwxrwx. 1 root root  9 20 sept. 12:16 ata-VBOX_HARDDISK_VB76d3524e-ac6ae205 -> ../../sda
lrwxrwxrwx. 1 root root 10 20 sept. 12:16 ata-VBOX_HARDDISK_VB76d3524e-ac6ae205-part1 -> ../../sda1
lrwxrwxrwx. 1 root root 10 20 sept. 12:16 ata-VBOX_HARDDISK_VB76d3524e-ac6ae205-part2 -> ../../sda2
lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-name-cl-root -> ../../dm-0
lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-name-cl-swap -> ../../dm-1
lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-uuid-LVM-AFXgxjJZSLDRCWckAVMMKzthSc5hNl6cbrtdWs4fPXZIoe1O6Wy0qh2xoreIY8tw -> ../../dm-1
lrwxrwxrwx. 1 root root 10 20 sept. 12:16 dm-uuid-LVM-AFXgxjJZSLDRCWckAVMMKzthSc5hNl6cmYPaZX60S5aAvfejEltFs2vMPmIlRkuV -> ../../dm-0
lrwxrwxrwx. 1 root root 10 20 sept. 12:16 lvm-pv-uuid-rrG0JE-i1MB-IeA0-Ce5c-dpj7-Fwm2-RMjyYb -> ../../sda2
2

I figured it out; it had to do with Logical Volumes, with which I am not very at ease.

As you could guess from fdisk -l, physical partition sda2 was divided in two logical volumes, /dev/cl/root and /dev/cl/swap, grouped in a volume group cl:

[root@localhost ted]# vgscan
  Reading volume groups from cache.
  Found volume group "cl" using metadata type lvm2

[root@localhost ted]# lvscan
  ACTIVE            '/dev/cl/root' [6,00 GiB] inherit
  ACTIVE            '/dev/cl/swap' [1020,00 MiB] inherit
  1. So what I did was first removing swap logical volume (5.3.2. Removing an LVM2 Logical Volume for Swap)

    [root@localhost ted]# swapoff -v /dev/cl/swap
    swapoff /dev/cl/swap
    
    [root@localhost ted]# lvremove /dev/cl/swap
    Do you really want to remove active logical volume cl/swap? [y/n]: y
      Logical volume "swap" successfully removed
    

    Commented line in /etc/fstab:

    #/dev/cl/swap swap swap defaults 0 0
    
  2. Then I had to resize the root logical volume:

    [root@localhost ted]# lvextend -L+8G /dev/cl/root
    
  3. Finally I had to resize the root filesystem. I run into problems trying to use resize2fs command (because XFS is not supported, see resize2fs: Bad magic number in super-block while trying to open), but xfs_growfs did the trick:

    [root@localhost ted]# xfs_growfs /dev/cl/root
    meta-data=/dev/mapper/cl-root    isize=512    agcount=4, agsize=393216 blks
             =                       sectsz=512   attr=2, projid32bit=1
             =                       crc=1        finobt=0 spinodes=0
    data     =                       bsize=4096   blocks=1572864, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
    log      =internal               bsize=4096   blocks=2560, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    data blocks changed from 1572864 to 3670016
    

I have now 14GB of space on /dev/mapper/cl-root :)

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.