/ proxmox

How to repair "No MBR magic, treating disk as raw" error

This is a problem that I regularly encountered with my Proxmox Gitlab instance. After a few months, it gets non-responsive and just does not react to anything anymore.
The console doesn't open, and connecting through the web interface just gives me a black screen, all the while using a high amount of CPU.

The instance fails to shutdown and resetting it results in the following error message; "WARN: No MBR magic, treating disk as raw".

If you set GParted as your boot disk (which can be downloaded here), then you will be met with a screen telling you that your lovely data is on an unallocated hard drive.
Luckily, there is no cause for panic, since there is a semi-fast way to get back to all of your data.

First, open a shell with administrator privileges in GParted. Next use a tool like lsblk or fdisk -l to know what disk you need to handle.
Use sudo gpart /dev/sdX to open the corrupted disk with gpart.
You can see that it's scanning for partitions and (oh the joy) that it should find a couple of partitions on our disk.

Now to recover those lost babies back to their prior state. Make sure you write down the start and end of every partition (it's the last thing on the size line, in the format s(start-end)).

To recover the actual partition table we need to launch parted with sudo parted. Because gpart works in sectors, we need to also put parted in sectors to correctly allocate the beginning and ending of our partitions. To do this, we use the command unit s.

Next up type rescue to begin the actual rescue of the partitions. If you get an error that reads unrecognised disk label, type mklabel followed by msdos as the new label type. Now you should be able to enter the rescue mode.

parted now asks what the starting sector is of the first partition you want to restore. Look back at the numbers you wrote down earlier and enter the lowest starting sector number for your first partition. Next up, it asks for the end sector number.
It should now search for file systems in the sector range that you provided. If it is successful, it should ask if you want to add the found partition to the partition table (yay!).

You can rescue the other partitions in the same way, by typing rescue and giving start and end sector numbers for the remaining partitions.
Once you're done with all the partitions, you can just type quit to exit parted.

If you refresh the GParted application, it should now change from unallocated to the partitions that you've just added to the partition table.

Provided that your GRUB installation hasn't gone corrupt, you should now be able to restart and launch back into the OS.

For now this is an okay way of repairing the corrupt machine. It's just odd that it's only happening to that one machine and that log files are not reporting anything out of the ordinary at the moment of the freeze.