Solved gpart: size '31457274': Invalid argument when trying to resize.

I am trying to to grow the root partition slice in a 13.1 VHD image with gpart resize -i 4 -s 15G -a 4k ada0 but I get gpart: size '31457274': Invalid argument. I get this same error in single user mode and using livedvd installer. The virtual disk image has been resized to be bigger than 15G (the virtual disk size doesn't seem to matter in this case as I get the same error when I try to resize sizes smaller than 15G. I'm following https://marcocetica.com/posts/grow_partitions_freebsd/. I don't know if this is a bug or not.
 
The partition table is backed up on predetermined locations relative to the end of the disk. When you grow the virtual disk size the backup table cannot be found at the expected place and the tools (for example, gpart show) display this as a "CORRUPT" partition table, which is normal. As SirDice explained, by calling gpart recover you create a new partition table backup in the right place and then you can proceed with further modifications.
 
This is the output of gpart show on the installation and not in single user mode or in livecd/dvd:
Code:
=>       3  10552747  ada0  GPT  (5.0G)
         3       123     1  freebsd-boot  (62K)
       126     66584     2  efi  (33M)
     66710   2097152     3  freebsd-swap  (1.0G)
   2163862   8388888     4  freebsd-ufs  (4.0G)

Output of uname -a:
Code:
FreeBSD freebsd 13.1-RELEASE FreeBSD 13.1-RELEASE releng/13.1-n250148-fc952ac2212 GENERIC amd64

Output of gpart recover:
Code:
ada0 recovering is not needed

The image is from https://download.freebsd.org/releas...md64/Latest/FreeBSD-13.1-RELEASE-amd64.vhd.xz . VirtualBox says it's Dynamically allocated differencing storage as opposed to Dynamically allocated storage that I see on my other VMs. I'm not sure if this is configured this way or me creating a snapshot before initially doing the vm size increase and gpart resize causing this. And yes, I am sure I have resized the vm storage as it says the virtual size is 15.03 GB right above the aforementioned storage allocation detail.
 
Code:
=>       3  10552747  ada0  GPT  (5.0G)
         3       123     1  freebsd-boot  (62K)
       126     66584     2  efi  (33M)
     66710   2097152     3  freebsd-swap  (1.0G)
   2163862   8388888     4  freebsd-ufs  (4.0G)
You can't grow that image with gpart(8). There is no space to grow on the *.vhd image. The image needs to be extended in size first by other means first.

On which virtualizer is this image running?
 
T-Daemon As I said, I have increased the size of the vm storage externally. I'm using VirtualBox. VirtualBox says the image is Dynamically allocated differencing storage as opposed to Dynamically allocated storage that I see on my other VMs. I don't know what's causing this difference.
 
T-Daemon I fixed it, I had to delete the snapshot I created and then the detail for storage changed back to Dynamically allocated storage and I was able to resize with sudo service growfs onestart.
 
Back
Top