VF QEMU Disk Resizing Failure - Debian

By Darren Nathanael on Sat, Apr 13, 2024 / Updated at Sun, Apr 14, 2024

Preface,

I have a VM with Debian 11 installed on it. Long story short, I’ve reached the maximum amount of storage. I increased the disk size resources in the VirtFusion admin panel and restarted the VM, but the change doesn’t seem to be applied. So what happened?, well apparently running fdisk -l shows me this

1root@git:~# fdisk -l
2GPT PMBR size mismatch (83886079 != 268435455) will be corrected by write.
3The backup GPT table is not on the end of the device.

Ouch something terrible happened.

Chapter 1

Lets look at the full output of fdisk -l

 1Disk /dev/vda: 128 GiB, 137438953472 bytes, 268435456 sectors
 2Units: sectors of 1 * 512 = 512 bytes
 3Sector size (logical/physical): 512 bytes / 512 bytes
 4I/O size (minimum/optimal): 512 bytes / 512 bytes
 5Disklabel type: gpt
 6Disk identifier: 4B476DA3-A9DF-4327-A2D2-7E14E01CB37E
 7
 8Device      Start      End  Sectors  Size Type
 9/dev/vda1    2048     4095     2048    1M BIOS boot
10/dev/vda2    4096   253951   249856  122M EFI System
11/dev/vda3  253952 83886046 83632095 39.9G Linux filesystem

Alright, we can see that the total disk size is indeed 128GB, but the partition /dev/vda3 is only 40GB.

After some searching on Stack Overflow, I discovered that to solve the initial issue, I needed to run parted. Unfortunately, I ran out of storage space entirely, so I had to remove some log files before installing parted.

Following the Stack Overflow suggestion, I should run parted -l to fix the partition.

 1root@git:~# parted -l
 2Warning: Unable to open /dev/sda read-write (Read-only file system).  /dev/sda
 3has been opened read-only.
 4Error: /dev/sda: unrecognised disk label
 5Model: QEMU QEMU HARDDISK (scsi)                                           
 6Disk /dev/sda: 377kB
 7Sector size (logical/physical): 512B/512B
 8Partition Table: unknown
 9Disk Flags:  
10
11Model: Virtio Block Device (virtblk)
12Disk /dev/vda: 137GB
13Sector size (logical/physical): 512B/512B
14Partition Table: gpt
15Disk Flags:  
16
17Number  Start   End     Size    File system  Name  Flags
181      1049kB  2097kB  1049kB                     bios_grub
192      2097kB  130MB   128MB   fat32              boot, esp
203      130MB   42.9GB  42.8GB  xfs

When I ran that it informed me that the partition table didn’t cover the full disk (duh), so it asked me Fix/Cancel to which I responded with Fix.

I then ran lsblk again, and there are even more errors! This is frustrating -_-

 1root@git:~# fdisk /dev/vda3
 2
 3Welcome to fdisk (util-linux 2.38.1).
 4Changes will remain in memory only, until you decide to write them.
 5Be careful before using the write command.
 6
 7This disk is currently in use - repartitioning is probably a bad idea.
 8It's recommended to umount all file systems, and swapoff all swap
 9partitions on this disk.
10
11The device contains 'xfs' signature and it will be removed by a write command. See fdisk(8) man page and --wipe option for more details.

Chapter 2

So, what did I do? Throw my whole PC away? Absolutely not. I simply rebooted, and that solved the issue.

 1root@git:~# lsblk
 2NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
 3sda      8:0    0  368K  1 disk  
 4sr0     11:0    1 1024M  0 rom   
 5vda    254:0    0  128G  0 disk  
 6├─vda1 254:1    0    1M  0 part  
 7├─vda2 254:2    0  122M  0 part /boot/efi
 8└─vda3 254:3    0 39.9G  0 part /
 9root@git:~# reboot
10root@git:~# Connection to git.dpaste.org closed by remote host.
11Connection to git.dpaste.org closed.

And I SSH back in, and lo and behold

 1[~/G/] : ssh -p [redacted] [email protected] -6                                                                                                                            23:05:47
 2Enter passphrase for key '/home/[redacted]/.ssh/[redacted]:  
 3Linux git.dpaste.org 6.1.0-18-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.76-1 (2024-02-01) x86_64
 4
 5The programs included with the Debian GNU/Linux system are free software;
 6the exact distribution terms for each program are described in the
 7individual files in /usr/share/doc/*/copyright.
 8
 9Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
10permitted by applicable law.
11Last login: Sat Apr 13 23:30:53 2024 from 2a09:[redacted]
12root@git:~# lsblk
13NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINTS
14sda      8:0    0   368K  1 disk  
15sr0     11:0    1  1024M  0 rom   
16vda    254:0    0   128G  0 disk  
17├─vda1 254:1    0     1M  0 part  
18├─vda2 254:2    0   122M  0 part /boot/efi
19└─vda3 254:3    0 127.9G  0 part /
20root@git:~# ls

It fixed itself! Thank goodness.

Summary

  • Free up some space.
  • Install parted.
  • Run parted -l.
  • Type Fix on the prompt from parted
  • Reboot.

Epilogue

Thank you for reading! If this has helped you, then I’m glad. How did I discover that the disk was full? Well, when I was about to create another blog post, I went to git.dpaste.org and encountered this error message. It only took me five seconds to SSH in and identify the root cause.

Forgejo Failing to Load CSS & JS
Forgejo Failing to Load CSS & JS
Forgejo Failing to Load CSS & JS