TransWikia.com

Accidentally deleted all partition data, how do I recover?

Super User Asked by juwi on November 3, 2021

I accidentally ran sgdisk -o /dev/sda instead of sgdisk -O /dev/sda and deleted all partition data.

My computer is still running and I have the output of fdisk and lsblk.
How can I use this information to restore the previous state as close as possible?

fdisk

Disk /dev/sda: 238.5 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SAMSUNG SSD 830 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: E19883E7-FC5D-4850-805A-CF22ABBC2074

Device         Start       End   Sectors  Size Type
/dev/sda1       4097    618497    614401  300M EFI System
/dev/sda2     618498  63533055  62914558   30G Linux filesystem
/dev/sda3   63533056  97087487  33554432   16G Linux swap
/dev/sda4   97087488 139030527  41943040   20G Linux filesystem
/dev/sda5  139030528 248078335 109047808   52G Linux filesystem
/dev/sda6  248078336 329732095  81653760   39G Linux filesystem
/dev/sda7  329732096 393066495  63334400 30.2G Linux filesystem

lsblk

NAME   FSTYPE         SIZE UUID                                 PARTUUID                             MOUNTPOINT                                             PARTTYPE
sda           256060514304
├─sda1 vfat      314573312 5123-3127                            19e1fb7a-7221-426d-a26c-ff4f7f3de0cc /boot/efi                                              c12a7328-f81f-11d2-ba4b-00a0c93ec93b
├─sda2 ext4    32212253696 5b9b0319-da3c-41b0-bd8f-117cfefb731b 2031b940-3903-324a-9e9d-296528b9ef50 /run/media/xxxxxx/5b9b0319-da3c-41b0-bd8f-117cfefb731b 0fc63daf-8483-4772-8e79-3d69d8477de4
├─sda3 swap    17179869184 b3ade29f-a36a-43ee-8394-d1306ec6fcb8 fe10d42d-948b-594e-bee5-bc113a9c5314 [SWAP]                                                 0657fd6d-a4ab-43c4-84e5-0933c84b4f4f
├─sda4 ext4    21474836480 30dbddd8-d4ad-42b9-9fcc-da575eababc0 9e8ef543-2c98-484d-8edf-5e54600f29fe /run/media/xxxxxx/30dbddd8-d4ad-42b9-9fcc-da575eababc0 0fc63daf-8483-4772-8e79-3d69d8477de4
├─sda5 ext4    55832477696 5005fa04-406a-4ec8-891a-11a2d9058daf 500ff476-35de-436f-b829-e719989455da /run/media/xxxxxx/5005fa04-406a-4ec8-891a-11a2d9058daf 0fc63daf-8483-4772-8e79-3d69d8477de4
├─sda6 ext4    41806725120 8bcc5a7e-31f5-41fe-8a4c-093bd1e70a66 6fc10074-76bc-496c-8465-4ec87aa3cd60 /run/media/xxxxxx/8bcc5a7e-31f5-41fe-8a4c-093bd1e70a66 0fc63daf-8483-4772-8e79-3d69d8477de4
└─sda7 ext4    32427212800 0afbcdd0-4bc2-4322-9d6d-46b2cf68238e df5fe961-585d-48b9-9a60-4ffb32e73819 /                                                      0fc63daf-8483-4772-8e79-3d69d8477de4

One Answer

As the sgdisk manual does not state anything about possible deletion of the backup GPT in the documentation of the "-o" parameter you could use a hex editor to search for the backup table using "EFI PART". When you find it duplicate it to a postion starting with the 2nd sector on your disc. When your hex editor starts with sector 0, it is the sector labeled 1.

Answered by r2d3 on November 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP