Ask Your Question

Howto rescue Fedora 22 LXDE x86_64 system with LUKS with corrupt boot sector?

asked 2015-09-18 12:46:30 -0500

zimon gravatar image

The PC has Fedora 22 LXDE x86_64 installed from F22 LXDE Live usb-stick. The system was installed with LUKS encryption enabled. Otherwise the installation was automatic by the LXDE Live system install.

Needed to upgrade BIOS. Only way to do it was from Windows. Windows was now installed on extra partition. It overwrote MBR.

After this only Windows 7 boot.

How to rescue the Fedora 22 LXDE system now?

Booting with the install media, F22 LXDE Live-usb stick doesn't seem to have any rescue mode or selection.

Doing just "grub2-install /dev/sda" on the Live-usb system does not rescue the F22 system on the local hard drive. Now when booted from the hard drive: ". error: no such device: 05xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx. Entering rescue mode... grub rescue>"

I thought the install media, in this case F22 LXDE x86_64 Live usb-stick, would have tools and methods to easily rescue installs. It should have.

The /dev/sda1 has /boot (ext2) the /dev/sda6 has swap and /, but it is with LVM and LUKS-encryption. The system does not use UEFI.

edit retag flag offensive close merge delete



So, did you have only Linux on the system before installing Windows in a dual-boot (?) arrangement in an attempt to address your motherboard BIOS update?

If we're sure Windows simply wrecked GRUB, you can can reinstall GRUB, but you'll need to configure it to chainload the Windows bootloader if you intend to keep dual-booting (as I presume you are?). I've always wanted to write up instructions to do that, but I haven't gotten around to it. If that's what needs to happen, I can at least point you at some helpful documentation.

bitwiseoperator gravatar imagebitwiseoperator ( 2015-09-18 21:39:09 -0500 )edit

Yes. It was an empty SSD (500G). II only intended to have and use Linux in it. But just in case, I had reserved 50 GB partition if I ever need to install something else. Then later, I wanted to upgrade RAM to this laptop, and because of that BIOS needed to be upgraded and HP provided only an .exe program which needed Windows underneath, so I then installed Windows. Yes, stupid me not to preserve MBR before that. I wrongly assumed Fedora22 install media would know how to rescue the system.

zimon gravatar imagezimon ( 2015-09-19 14:19:29 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2015-09-19 14:35:30 -0500

zimon gravatar image

What I did to get the F22 system booted:

Boot with USB-stick, which had F22 LXDE Live. Open Command Window.

su -
fdisk -l /dev/sda
# Noticed the LUKS partition was /dev/sda6 and /boot partition /dev/sda1
cryptsetup luksOpen /dev/sda6 fedora
password: <gave the LUKS password>
mkdir /mnt/root
mount /dev/mapper/fedora_hostname-root /mnt/root
mount /dev/sda1 /mnt/root/boot/
mount -o bind /dev /mnt/root/dev
mount -o bind /proc /mnt/root/proc
mount -o bind /sys /mnt/root/sys
mount -o bind /run /mnt/root/run
chroot /mnt/root
grub2-install --no-floppy --recheck /dev/sda
# Complained, there should be GRUB_ENABLE_CRYPTOSYSTEM=y in /etc/default/grub
echo "GRUB_ENABLE_CRYPTOSYSTEM=y" >>/etc/default/grub
grub2-install --no-floppy --recheck /dev/sda
grub2-mkconfig -o /boot/grub2/grub.cfg
/sbin/shutdown -r now
# Booted (But not to the Fedora system, but just to Grub prompt.)
# Asked LUKS password already in this stage.
# Went to the GRUB2 normal prompt. (not just Grub2 rescue prompt anymore)
grub> ls
# shows also LVM partitions inside LUKS-partition
set root=(hd0,msdos1)
configfile /grub2/grub.cfg

Now I got the normal Grub boot menu, where also were Linux kernels, Linux-rescue kernel and Windows 7.

edit flag offensive delete link more



Perfect! Your post will be good help to others in the same situation. I guess, what happened to you happens a lot.

florian gravatar imageflorian ( 2015-09-19 20:13:11 -0500 )edit

Excellent work, excellent write-up. Way to go.

bitwiseoperator gravatar imagebitwiseoperator ( 2015-09-19 21:25:47 -0500 )edit

After upgrading new kernel and rebooting, the system still asks LUKS password in GRUB stage and won't show the menu. So needed to remove "GRUB_ENABLE_CRYPTOSYSTEM=y" from /etc/default/grub and then

grub2-install --no-floppy --recheck /dev/sda
grub2-mkconfig -o /boot/grub2/grub.cfg

Now it shows Grub menu nicely when rebooted. I cannot guess why when fixing it in chroot environment it needed that GRUB_ENABLE_CRYPTOSYSTEM then.

zimon gravatar imagezimon ( 2015-09-22 11:43:38 -0500 )edit

answered 2015-09-18 13:45:33 -0500

florian gravatar image

updated 2015-09-18 13:55:47 -0500

The best would be to follow these instructions here.

Another option is that you create a live system based on the LIVE DVD that has an automated rescue system that will recover your grub (and also detect win7 partition).

edit flag offensive delete link more



This is a good reference post, but your process will be a bit different in that you'll need to use cryptsetup to mount the LUKS-encrypted device. Scroll down to "How do I mount or remount encrypted partition?" for a good and quick explanation of the commands you'll need to run. I can help you piece together a more detailed process if you need it.

bitwiseoperator gravatar imagebitwiseoperator ( 2015-09-18 21:50:31 -0500 )edit

Thanks. Those helped. I've fiddled with Grub and Grub2 and ALOT with Grub-EFI before, but it seems always a fresh new ball game when something goes broken.

Also, before Fedora used LUKS so first was LVM and undernearth were possible LUKS-partitions. Now it was one big LUKS-partition and under that were LVM-system.

zimon gravatar imagezimon ( 2015-09-19 14:23:42 -0500 )edit

Question Tools



Asked: 2015-09-18 12:46:30 -0500

Seen: 2,886 times

Last updated: Sep 19 '15