Update: In my case it was all about installers recognizing sizes in KB, MB, GB vs KiB MiB GiB (as you can tell by the bytesize parameter in the fdisk screenshots); But this process remains applicable in situations where the loss of space is caused by unallocated/unrecognized partitions due to disk errors and/or bad sectors.
Some years ago, I attempted to install OpenSUSE on my main machine... The machine had a Fedora installation at the time (with a LUKS partition on it) and because of the incapacity of the OpenSUSE installer to manage LUKS partitions well at the time, I ended with up to 20GB lost in HDD space after the installation finished. Not "unallocated" Not "unassigned", just gone (the machine had a 320GB HDD on it, but ended with roughly 300GB after that day):
When that happened, I just resigned myself and for the later years (until now) I've been living with 20GB less in HDD space. Today I was about to make a fresh install of Fedora again, and suddenly I opened GNOME Disks, tool which indeed, recognized the 320 GB available on the HDD (other tools like gparted, df, du, fdisk and such haven't been able to do so):
sudo swapoff --all) and then, you'll have to format the resulting full disk (as ext4 preferably) overwritting the existing data with zeroes:
This process will take time, so be patient. Then we have to scan/repair bad sectors on disk using the following commands (as root):
1. fsck.ext4 -cfyv /dev/sda
2. e2fsck -fy /dev/sda1
And finally we'll be able to use the HDD/SDD again at it's full capacity to perform a clean install of whatever we want to: