Getting the deleted partition back using TestDisk or Timeshift?

Sorry, my typo… it definitely has to be /dev/sda… I went back and corrected it

You are not using the --efi-directory= … parameter… you need it to tell grub-install where you mounted sda1

THIS REPLY HAS AN ERROR… YOU DONT SPECIFY DISK SDA
FOR A UEFI BOOT

sudo mount /dev/sda1 /mnt/boot/efi DONE

Have been reading that as well as --help and not sure I understand if you are saying I should be using and am not or that in this instance you are NOT to use that parameter. Could you explain?

grub-install /dev/sda
grub-install /dev/sda1

Both return cannot find EFI (uppercase)
/dev/sda1 is mounted to /efi (lowercase)

I tried this in using the parameter:
grub-install --efi-directory=/boot/efi --target=x86_64-efi /dev/sda

It returned error: failed to get canonical path of /boot/efi

But when I added /mnt before /boot/efi it started installing and gave
warning: disk does not exist so falling back to partition device dev/sda1
and 2 more lines of the same, then
error: disk ‘hostdisk//dev/sda1’ not found

How can it not be found?

OK… I just reread the grub manual
My mistake… for uefi boot, you dont specify a disk at all with grub install
so
grub-install --efi-directory= /mnt/boot/efi

it should write grub in sda1

Fingers crossed

it started installing and gave:

warning: disk does not exist so falling back to partition device dev/sda1
and 2 more lines of the same, then
error: disk ‘hostdisk//dev/sda1’ not found

1 Like

@Sheila_Flanagan
Is there perhaps an unwanted space in that
efi-directory=/mnt/boot/efi

My typo again… I am getting tired too, but lets get this going.

No, even though I now see you put a space, I knew not to when I read the --help and pointed to this target before.

Sorry. I read one person (on Arch, mind you) had this issue and was told they had to chroot, but I am guessing not here.

I even tried sudo, but that gave the error:
failed to get canonical path of /cow

Your mount of sda1 must be wrong
What does lsblk say

sda1 /mnt/boot/efi

1 Like

Not sure, but can you use Boot Repair from live session to reinstall grub for this restored OS? Or can we get a report from it maybe that might point out the issue?

I think it might need to be mounted to a mount point that is in the active linux… ie in the live system
So
umount /mnt/boot/efi
and mount it to /mnt in the live system

mount /dev/sda1 /mnt
then
grub-install --efi-directory=/mnt

That is simpler, it might be confused.

sudo umount /dev/sda1
sudo mount /dev/sda1 /mnt
grub-install --efi-directory=/mnt

Same warning 3x then
error: disk ‘hostdisk//dev/sda1’ not found

lsblk shows sda1 /mnt

Just consulted some examples in my PC
You need to mount /dev/sda2 as well
because grub needs to write stuff in /boot of the root filesystem
So
leave that mount you have
and add
mount /dev/sda2 /media
then
grub-install --efi-directory=/mnt --boot-directory=/media/boot
–target=x86_64-efi

You will be expert soon.

mounted /dev/sda2 /media

If we mounted sda2 to media, do we need sudo for /media/boot?

Cause error: failed to get canonical path of ‘/cow’

This copy-on-write seems to be a recent issue in live sessions, though I am not convinced yet it is our issue. They are saying trying to udpate grub throws it, but we are installing.

I printed a report from the live session Boot Repair and it shows no errors found in the Boot Parameter Block for sda1. It also shows no OS nor any boot files.

Whereas sda2 shows the correct version of LM (21.2) that we restored and boot files on:
/boot/grub/grub.cfg
/etc/fstab
/etc/default/grub

That is why I had just been thinking we needed to include sda2, but still it hasn’t helped.

At this point I guess we have two options:

  1. Use Boot Repair tool to install grub, but am not sure yet how that works on the non-running OS–needs research
  2. Install LM and then try restore again so that at least sda1 has what it needs. We would still need to edit fstab after restore. And fresh install should wipe the disk prior so nothing residual remains to mess things up.

Unless you have a different option, let’s see what we can find out and I will try again tomorrow (when my eyes are not crossed…lol)

Thanks so much for all of your help. I am learning so much and since I cannot copy/paste to my Linux notebook right now, I have LOTS of photos documenting this process.

Let me know.

Sheila

You mean do you need sudo to do the mount
Yes
You might need sudo for grub-install too

Well that was the first time I got that /cow error when I attempted sudo with grub-install. Is that relevant? I thought it always throws a Permission Denied if sudo is needed?

I always use sudo with mount/umount.

I need to understand that error… ie what is grub-install trying to do.?
Have your sleep. I will look into it. The error must come from using a live cd linux. What I gave you works for a linux running from an internal disk… you dont have one of those

Yes you might be able to use systemrescuecd to install grub, instead of the live cd. It is not much different.

@Sheila_Flanagan
This solves the problem

Only dont forget, yours is uefi boot… the examples there are
legacy boot.
You might have to use chroot, but try the sudo touch /cow idea first

I think we have the grub-install command right now, we just have to fix the environment

and
Check that the EFI system partition is formatted to fat32.

I keep a Rescatux CD with Super Grub2 handy, if there is a bootable vmlinuz somewhere, it will find it, it has saved me a few times. This CD was made in January of 2020 and still works quite well.