0

I need an advice about a bad situation.

I was installing a new linux ditro by using my main PC. I booted with the ISO and then installed the distro on /dev/sdc, which was an external USB drive. My bad, I didn't realized when installing, that I didn't change the boot loader installation on the same drive, but I left on /dev/sda, which holds my main operating system (LUKS encrypted).

Obviuosly after this, the main operating system is not booting any more, and I see an errror message from GRUB saying:

error: no such cryptodisk found

Now, I have a clonezilla backup of my /dev/sda/, and in the file list, among other files, I see

12/04/2022  04:59 AM                10 parts
12/03/2022  11:41 PM                38 sda-chs.sf
12/03/2022  11:41 PM         1,048,064 sda-hidden-data-after-mbr
12/03/2022  11:41 PM               512 sda-mbr
12/03/2022  11:41 PM               391 sda-pt.parted
12/03/2022  11:41 PM               338 sda-pt.parted.compact
12/03/2022  11:41 PM               267 sda-pt.sf
12/03/2022  11:41 PM       118,196,482 sda1.ext4-ptcl-img.gz.aa
12/04/2022  04:59 AM               512 sda2-ebr

I hope some of these backups can help me in restore the situation (may be sda-mbr and sda-hidden-data-after-mbr?), but I'd like to ask your help before doing anything, in order to avoid more damage.

Anyone can advice how to recover the situation?

Thanks so much!!

2 Answers 2

0

UEFI or BIOS installs. Looks more like BIOS as you have MBR and maybe grub's core.img which is in the sectors after the MBR. Most systems now are UEFI and prefer gpt partitioning.

If you plug in external drive, does it boot? Update it to see encrypted install.

sudo apt-get update && sudo apt-get install lvm2 cryptsetup
sudo modprobe dm-crypt
sudo cryptsetup luksOpen /dev/sdXY my-crypt
sudo os-prober
sudo update-grub

And then install grub from external drive to external drive's MBR. And from encrypted install install grub to sda. So internal drive boots normally.

Also what version of grub? Nowadays GRUB (v2.06) allows to boot Linux from a LUKS-encrypted /boot partition (even one inside a LVM) with the GRUB_ENABLE_CRYPTODISK=y key and the appropriate LUKS or LUKS2 modules loaded.

Otherwise you can use live installer.

https://askubuntu.com/questions/63594/mount-encrypted-volumes-from-command-line

http://askubuntu.com/questions/719409/how-to-reinstall-grub-from-a-liveusb-if-the-partition-is-encrypted-and-there-i?rq=1

1
  • Thanks for your answer. Yes, it's a BIOS install. I can boot with a live distro. I'm taking a backup now, as soon as it finish I'll try one of the solution you linked. Thanks
    – cips
    Feb 25, 2023 at 15:38
0

OK, I was able to solve with the following commands:

sudo -i
apt-get update
apt-get install cryptsetup lvm2
fdisk -l
cryptsetup luksOpen /dev/sda? TAG           
vgchange -ay
vgscan
vgchange -ay [VOLUME GROUP NAME]           # From the above command
lvscan
mount /dev/[VOLUME GROUP NAME]/[LOGICAL VOLUME NAME] /mnt          # LOGICAL VOLUME NAME from above command

cd /mnt
mount /dev/sda1 /mnt/boot
for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo mount -B $i /mnt$i; done

chroot /mnt

grub-install /dev/sda
update-grub

for i in /dev /dev/pts /proc /sys /sys/firmware/efi/efivars /run; do sudo umount /mnt$i; done

umount /mnt
vgchange -an
cryptsetup luksClose TAG

Now I have to solve a kind of mixup with devices, but I'm able to boot up the system.

Thanks a lot for the help @oldfred

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .