1

I've made a small mistake, I've removed my boot partition by mistake. Using testdisk I was able to recover the boot partition without problem but I either misused it or did not understand and only write partition table with my boot partition.
So now my / and swap partition are missing from my system.
I've found this answer from the great Gilles however,
my system is using EFI and my partition is encrypted, does the same solution apply to restore my partition table and what partition format should I use with an encrypted ext4 and swap partition ?

Also in the same question from SuperUser, I've come accross the fact that I should use gdisk and substract 1 to sector size is all those informations accurate and up-to-date ?

Edit 1:

testdisk find those partition with a deep search:

Disk /dev/nvme0n1 - 512 GB / 476 GiB - CHS 488386 64 32
     Partition               Start        End    Size in sectors
 P EFI System                  2048    1619967    1617920 [EFI System Partition] [ESP]
 D MS Data                     2054    1619973    1617920 [NO NAME]
 D EFI System                  4096     618495     614400 [EFI System Partition]
 D MS Data                     4102     618501     614400
 D MS Data                    37699      43872       6174
 D MS Data                    43872      50045       6174 [Boot]
 D Linux filesys. data       618494 1000206893  999588400
 D Linux filesys. data       618496     622591       4096
 D Linux filesys. data       618496 1000206895  999588400
 D MS Data                374180459  374183338       2880 [NO NAME]
 D MS Data                374180483  374183362       2880 [NO NAME]
 D MS Data                374181379  374184258       2880 [NO NAME]
>D Linux filesys. data    965039160  965043255       4096

2 of them (the one with 4096 block size) as LUKS.

howerver with "bad structue" and from this mess I've know Idea what I could or should restore.
My orginal disk had a gpt boot partiton, one main encrypted partition and a encrypted swap partition in the end.

My computer is still on and I've been able to backup LUKS header and I have access to all data and relevant informations, I just don't know how to exploit it.

1
  • If not rebooted recover partition: ubuntuforums.org/showpost.php?p=10364557&postcount=34 Do not know LVM, but most installs use ESP, /boot & a large partition that then contains the LVM volumes. Some now do not use /boot as it can be inside the LVM with newest systems. – oldfred Dec 21 '20 at 14:38
2

Finally I've used testdisk to solve the issue I've identify my other partition :

#main partition
/sys/class/block/nvme0n1p2/start                                                                                                                                                                      
618496
/sys/class/block/nvme0n1p2/size                                                                                                                                                                       
964420664
#Swap partition
/sys/class/block/nvme0n1p3/start                                                                                                                                                                      
965039160
/sys/class/block/nvme0n1p3/size                                                                                                                                                                       
35167740

So with that in mind I needed to identify my boot drive properly in testdisk and it was this one :

 D EFI System                  4096     618495     614400 [EFI System Partition]

I selected this selection and add two other partition corresponding to the value found in /sys/class/block.
testdisk uses start and end sector not start sector and count. So to find end sector you need to add comute start+count-1.

As partition type I chooses Luks partition in linux subcategorie. Et voilà.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.