I installed a new hard drive in my home server today, went to format it in gdisk (larger than 2 TB), set the changes and wrote them. Then I noticed that I had selected the wrong disk, in fact I just overwrote the partition table on my startup disk instead.
The partition table changes will be written as soon as I reboot the system, and I'm relatively certain that it won't be bootable unless I can restore the partition table to what it was before.
Is there any way I can restore the old partition table, or at least enough of it to safely reboot?
I have the 'p' output from gdisk, from before I overwrote the table:
Command (? for help): p Disk /dev/sdh: 125045424 sectors, 59.6 GiB Logical sector size: 512 bytes Disk identifier (GUID): D0127C61-1349-42D1-A03F-46F604F3DD6C Partition table holds up to 128 entries First usable sector is 34, last usable sector is 125045390 Partitions will be aligned on 2048-sector boundaries Total free space is 4717 sectors (2.3 MiB) Number Start (sector) End (sector) Size Code Name 1 2048 119883775 57.2 GiB 8300 Linux filesystem 5 119885824 125044735 2.5 GiB 8200 Linux swap
The disk was formerly partitioned in MBR, and - without checking for sure - I don't think that this particular PC supports UEFI/booting from GPT.
I'm not sure that this printout includes all the information I would need to reconstruct the partition table. Is it possible that some partitions are hidden here? Or that other vital information would be missing? I know - for example - that because gdisk/GPT doesn't have a "bootable" flag, this printout doesn't include it.
I already tried writing these partitions back with fdisk, but I can't figure out how to get fdisk to create a partition numbered '5'. I imagine that, if my swap partition "moved" from sdh5 to sdh2, this wouldn't just magically work.
I found a similar issue, Recover Partition-Table still present in running system regarding overwriting the partition table using
dd. But in my case, since I used gdisk (+ fdisk) to write a new table, I'm not certain that the information in /sys/block is completely accurate anymore.