Getting the deleted partition back using TestDisk or Timeshift?

Topic Summary - restore a deleted partition using Timeshift

This summary is a joint effort by @nevj and @Sheila_Flanagan

and

This topic started with an accidental deletion of a Linux Mint partiton. Mint happened to
be the Linux which controlled grub in a multiboot setup.

After numerous attempts at restoring a Timeshift snapshot post fresh install of Linux Mint, it was decided to wipe the drive and create the needed partitions, for a Mint-only system :

sda1 boot/efi   EFI System Partition
sda2 root/ext4  Linux Mint root filesystem
sda3 swap       Swap space

This would eliminate any residual elements that might prevent a successful restore of the snapshot.
Some previous attempts at restoring onto a remaining Kubuntu partition or onto a fresh Mint install had failed, and it was felt that the presence of Linux files not backed up by Timeshift was interfering with the restore attempts.

Recover Mint with Timeshift

Use a live USB flash drive of LM to start Timeshift.
Restore the Nov 23 snapshot to partition sda2
More recent snapshots were avoided as they had given trouble
This resulted in a Mint filesystem on /dev/sda2 , but not bootable because /etc/fstab was wrong
and there was no grub.

Fix /etc/fstab in the sda2 filesystem

Mount sda2 from the live USB LM
cd to the mount and into its etc subdirectory
edit the file fstab… change the UUID’s of all entries to those shown by
blkid for sda2 and sda3
also remove or hide the file boot/grub/grub.cfg

Install grub on disk sda

Attempts to install grub from a live LM session failed
The remedy involves a chroot into the recovered LM

Mount /dev/sda2 to /mnt

 mount /dev/sda2 /mnt

Do some bind mounts

sudo mount --bind /dev /mnt/dev &&
sudo mount --bind /dev/pts /mnt/dev/pts &&
sudo mount --bind /proc /mnt/proc &&
sudo mount --bind /sys /mnt/sys

Chroot into /mnt

sudo chroot /mnt

That puts us in a situation that treats /mnt as /

Update grub

sudo update-grub

That makes a new /boot/grub/grub.cfg file, using various files from /etc/default/grub.d
and the configuration file /etc/default/grub.

Mount the EFI system and install grub

sudo mount /dev/sda1 /mnt2
sudo grub-install --efi-directory=/mnt2 –target=x86_64-efi

That writes grub in the EFI System directory

Exit the chroot and reboot

The result

It boots LM from /dev/sda2, without a grub menu, going straight to the login screen.
One can force a grub menu by editing the file /etc/default/grub

The lesson learnt

From this exercise we have confirmed that while Timeshift might work for rolling back to recover from errors in a currently bootable system, it is not to be counted on for a complete backup to restore the entire state of the system. In particular, if grub is damaged, Timeshift can not help restore it.

For that, Clonezilla images are needed and should be updated as often as you want to be able to return to a desired state of your system.

3 Likes