BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Discussions related to using VirtualBox on Linux hosts.
Post Reply
Guideloom
Posts: 29
Joined: 5. Sep 2018, 18:42

BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Post by Guideloom »

Summary : Using modifymedium to increase the capacity of a VDI file, does not change the reported size by showmediuminfo.
Version : 5.2.12r122591

Also note: there are no snapshots on this system, and yes the guest was powered off during the modifymedium command.

Details : Want to increase the capacity of a dynamicly sized VDI disk from 256GB to 1TB.

Run showmediuminfo on the drive to show information. You can see it is 256GB.
vbox@devops01:~$ VBoxManage showmediuminfo 40df678e-7fa6-49d9-84e2-e3cf81ffd72e
UUID: 40df678e-7fa6-49d9-84e2-e3cf81ffd72e
Parent UUID: base
State: locked write
Type: normal (base)
Location: /mnt/scqn001/vbox/vms/scvl003/scvl003-02.vdi
Storage format: VDI
Format variant: dynamic default
Capacity: 256000 MBytes
Size on disk: 181761 MBytes
Encryption: disabled
In use by VMs: scvl003 (UUID: 2ce1ff48-ce99-4e6e-8416-53b82e70652f)
Run modifymedium to increase the size to 1TB.
vbox@devops01:~$ VBoxManage modifymedium 40df678e-7fa6-49d9-84e2-e3cf81ffd72e --resize 1048576
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
As you can see, the command ran fine. Let's do an fdisk to show the new drive capacity, according to Linux (in bold below).
[2002 root@scvl003 ~]$ fdisk -l
Disk /dev/sda: 64 GiB, 68719476736 bytes, 134217728 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
Disklabel type: dos
Disk identifier: 0x2e047c51

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 132216831 132214784 63G 83 Linux
/dev/sda2 132218878 134215679 1996802 975M 5 Extended
/dev/sda5 132218880 134215679 1996800 975M 82 Linux swap / Solaris

Disk /dev/sdb: 1 TiB, 1099511627776 bytes, 2147483648 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
Disklabel type: dos
Disk identifier: 0xbdd71e19

Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 524287999 524285952 250G 83 Linux
So Linux sees the new drive capacity at 1TB, which is good. And the original partition is still intact, which is also good. Now we run parted to increase the partition to use the newly expanded drive.
2008 root@scvl003 ~]$ parted
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) select /dev/sdb
Using /dev/sdb
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 1100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 268GB 268GB primary ext4

(parted) resizepart
Partition number? 1
Warning: Partition /dev/sdb1 is being used. Are you sure you want to continue?
Yes/No? yes
End? [268GB]? 1100GB
(parted) print
Model: ATA VBOX HARDDISK (scsi)
Disk /dev/sdb: 1100GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number Start End Size Type File system Flags
1 1049kB 1100GB 1100GB primary ext4

(parted) quit
Information: You may need to update /etc/fstab.
As you can see, the partition has been resizeed to be the new entire drive. Now we run resize2fs to expand the partition.
[2011 root@scvl003 ~]$ resize2fs /dev/sdb1
resize2fs 1.42.13 (17-May-2015)
Filesystem at /dev/sdb1 is mounted on /mnt/data01; on-line resizing required
old_desc_blocks = 16, new_desc_blocks = 64
The filesystem on /dev/sdb1 is now 268435200 (4k) blocks long.
Let's confirm the size by doing a df. As shown below, the drive is now 1TB.

Code: Select all

[2012 root@scvl003 ~]$ df -k
Filesystem      1K-blocks      Used Available Use% Mounted on
udev              1002868         0   1002868   0% /dev
tmpfs              204804      6020    198784   3% /run
/dev/sda1        64937780   4369728  57246300   8% /
tmpfs             1024008         0   1024008   0% /dev/shm
tmpfs                5120         0      5120   0% /run/lock
tmpfs             1024008         0   1024008   0% /sys/fs/cgroup
/dev/sdb1      1056762036 186673648 824501788  19% /mnt/data01
However, here is the problem.
Even after using modifymedium to increase the size, showmediuminfo doesn't think it's been resized, even though Linux does. It still shows the original capity of 256GB.
vbox@devops01:~$ VBoxManage showmediuminfo 40df678e-7fa6-49d9-84e2-e3cf81ffd72e
UUID: 40df678e-7fa6-49d9-84e2-e3cf81ffd72e
Parent UUID: base
State: locked write
Type: normal (base)
Location: /mnt/scqn001/vbox/vms/scvl003/scvl003-02.vdi
Storage format: VDI
Format variant: dynamic default
Capacity: 256000 MBytes
Size on disk: 181761 MBytes
Encryption: disabled
In use by VMs: scvl003 (UUID: 2ce1ff48-ce99-4e6e-8416-53b82e70652f)
So what's going to happen when I hit the VDI "capacity" of 256GB on a system tht Linux thinks is 1TB?
Can anyone else confirm these results? or am I missing something?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Post by mpack »

Looks like a minor caching problem somewhere. When I've seen this sort of thing before it was because some part of VirtualBox was kept running while you made all those changes, so the media stats have not been refreshed. It would not affect actual operations on the media.
Guideloom
Posts: 29
Joined: 5. Sep 2018, 18:42

Re: BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Post by Guideloom »

So how do I get the cache "flushed"?
Why would this information even be cached?
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Post by mpack »

VirtualBox caches it in memory when it is running. Since the information is scattered all over I don't know what else it could do. Just make sure VirtualBox is fully shut down before doing this stuff.
Guideloom
Posts: 29
Joined: 5. Sep 2018, 18:42

Re: BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Post by Guideloom »

So to resize the disk of "one" server and have it display it's stats correctly, you're telling me I have to poweroff "all" other servers as well as the server I'm increasing the disk on, and shutdown the virtualbox service?
Really?
Guideloom
Posts: 29
Joined: 5. Sep 2018, 18:42

Re: BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Post by Guideloom »

Well.. yup it's a caching issue. After restarting the host, the capacity shows the correct amount of disk.

IMHO, this is a bug. The capacity of a disk shouldn't be cached in some unknown process. modifymedium updates should immediately be viewable by showmediuminfo without a service restart.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: BUG: showmediuminfo showing incorrect VDI capacity after resizing by modifymedium

Post by mpack »

By all means raise a BugTracker ticket for it.
Post Reply