Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: [EN] Grub/Bootmanager destroyed how to restore?  (Read 994 times)

Offline mash

  • User
  • Posts: 47
[EN] Grub/Bootmanager destroyed how to restore?
« on: 2022/05/29, 19:41:19 »
Hi,
yesterday I used my laptop on battery and unfortunately the battery went dead before I could plug it in again.
This happened before without causing any damage. Nevertheless this time the bootmanager was affected and the bootmanager shows only the option of booting windows.

I have a small windows 10 system installed on the laptop in question that I need from time to time but not very often.

Situation:
/dev/sda is a 256 GB ssd

/dev/sda1 [acer recovery for windows] 500 MB
/dev/sda2 EFI 100MB Including a folder for winboot and siduction_2018.3.0
/dev/sda4 Windows system Partition 110 GB
/dev/sda5 Linux system partition 125 GB

/dev/sdb is the hdd containing the actual data
-------------------------------------
How can I repair the bootmanagaer, so that siduction is shown again in bootmanager?
------
When I insert a USB pendrive with siduction 2021.3 (wintersky) the USB drive is shown in the bootmanager together with windows.
Siduction from USB now offers "detect EFI Bootloaders"
After selecting "detect EFI Bootloaders" I can select
Code: [Select]
/efi/siduction_2018.3.0/grubx64.efi(see image)
----
So, in fact I can start my previous siduction installation without any problems but going over the USB is a possible solution but not an option in the long run.

So I started wintersky and went to the installer in the hope that there is an option to fix the boot-system, but I only could find a new install.
So, please any advice on how to fix this?
thanks and sorry for the long explanation(s)
when it was hard to write it should be hard to read

Online Mister00X

  • User
  • Posts: 150
Re: Grub/Bootmanager destroyed how to restore?
« Reply #1 on: 2022/05/29, 20:49:31 »
Okay here is what you can do.
1. Boot into the siduction live iso.
2. Open the terminal and get root privileges
3.
Code: [Select]
lsblk -o +LABEL and identify your root- and your EFI-Partition
4.
Code: [Select]
mount /dev/<rootfs> /mnt
mount /dev/<efi-partition> /mnt/boot/efi
replace <rootfs> and <efi-partition> with the right devices
5.
Code: [Select]
for dir in /dev /dev/pts /proc /sys /run ; do mount --bind $dir /mnt$dir ; done 6.
Code: [Select]
chroot /mnt /bin/bashNow you should have successfully chrooted into your system.


You can try two different things now. The easy one is issuing a simple
Code: [Select]
update-grub but if you want to be sure that grub is reinstalled you first find out if linux device naming has changed in the meantime (using lsblk again) and after that you do
Code: [Select]
grub-install /dev/sdX # where X is the right device letter
# or for nvme drives
grub-install /dev/nvmeXnY # where X and Y are the right device numbers
Note: In both cases don't pass a partition to this command e.g. no /dev/sda1 you need to provide it with just the device.

After that you can exit the chroot using
Code: [Select]
exit unmount the bind mounted directories using
Code: [Select]
for dir in /run /sys /proc /dev/pts /dev ; do umount /mnt$dir ; done unmount your partitions
Code: [Select]
umount /mnt/boot/efi
umount /mnt
and reboot afterwards.


Note that if you want to be carefull you should do a backup of your system (if you don't already have one) before doing this.
Arguing that you don't care about the right to privacy because you have nothing to hide is no different than saying you don't care about free speech because you have nothing to say. – Edward Snowden

Offline mash

  • User
  • Posts: 47
Re: Grub/Bootmanager destroyed how to restore?
« Reply #2 on: 2022/05/29, 20:57:02 »
Thanks for this invaluable hint.
I will try that tomorrow. (After a day of seven hours seminars I am just blank in my mind).
Question: do I really have to do that from the live ISO or is this even possible from the siduction already installed?
when it was hard to write it should be hard to read

Online Mister00X

  • User
  • Posts: 150
Re: Grub/Bootmanager destroyed how to restore?
« Reply #3 on: 2022/05/29, 21:09:35 »
So, in fact I can start my previous siduction installation without any problems but going over the USB is a possible solution but not an option in the long run.

Ah I missed that bit.

Of course you can install it from the already installed system. In that case
Code: [Select]
update-grub might be sufficient. If that fails find out the drive your bootloader resides on and do the
Code: [Select]
grub-install /dev/sdX if that also fails try what's described here https://forum.siduction.org/index.php?topic=8250.msg66572#msg66572

EDIT: Just for clarification you can skip the entire chroot part i.e. the part with mounting and chrooting and unmounting

EDIT2: Considering you lost power, your filesystem could be corrupted. It could therefore be wide to run fsck on your filesystems either by using the live system (find out the right disks first then run as root)
Code: [Select]
fsck /dev/<rootfs> /dev/<efi-partition>
or by appending
Code: [Select]
fsck.mode=force to line starting with linux in grub. You can do this by pressing e in grub of your installed system.

If everything I told you fails it may be that for some reason the boot order in your UEFI changed and windows is now on the first place, in this case you need to change the bootorder either in your UEFI settings or using efibootmgr
« Last Edit: 2022/05/29, 21:40:34 by Mister00X »
Arguing that you don't care about the right to privacy because you have nothing to hide is no different than saying you don't care about free speech because you have nothing to say. – Edward Snowden

Offline mash

  • User
  • Posts: 47
Re: Grub/Bootmanager destroyed how to restore?
« Reply #4 on: 2022/05/29, 21:43:08 »
Quote
Of course you can install it from the already installed system. In that case
Code: [Select]
update-grub
That did not do the trick
Quote
If that fails find out the drive your bootloader resides on and do the
Code: [Select]
grub-install /dev/sdX
if that also fails try what's described here https://forum.siduction.org/index.php?topic=8250.msg66572#msg66572
where /dev/sdX is /dev/sda or an explicit /dev/sda#  and # is the number of the partition (in my case 2)???
when it was hard to write it should be hard to read

Online Mister00X

  • User
  • Posts: 150
Re: Grub/Bootmanager destroyed how to restore?
« Reply #5 on: 2022/05/29, 21:48:10 »
/dev/sdX is just the device e.g. /dev/sda
Arguing that you don't care about the right to privacy because you have nothing to hide is no different than saying you don't care about free speech because you have nothing to say. – Edward Snowden

Offline towo

  • Administrator
  • User
  • *****
  • Posts: 2.702
Re: Grub/Bootmanager destroyed how to restore?
« Reply #6 on: 2022/05/30, 08:07:49 »
On EFI systems there is much simplier.

Code: [Select]
grub-install
is all you need, from a bootet siduction (no chroot).
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

Offline mash

  • User
  • Posts: 47
Re: Grub/Bootmanager destroyed how to restore?
« Reply #7 on: 2022/05/30, 11:46:46 »
Quote
On EFI systems there is much simplier.

Code: [Select]
grub-install

is all you need, from a bootet siduction (no chroot).

No that gives me:
Code: [Select]
grub-install
Installing for x86_64-efi platform.
grub-install: error: cannot find EFI directory.
Same for grub-install /dev/sdX
when it was hard to write it should be hard to read

Offline towo

  • Administrator
  • User
  • *****
  • Posts: 2.702
Re: Grub/Bootmanager destroyed how to restore?
« Reply #8 on: 2022/05/30, 12:02:33 »
Is the system booted from live system, or is the install booted?

Code: [Select]
fdisk -l
mount | egrep -i "/dev/sd|/dev/nv"
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

Offline mash

  • User
  • Posts: 47
Re: Grub/Bootmanager destroyed how to restore?
« Reply #9 on: 2022/05/30, 13:45:55 »
Hi towo this is (part of) the result:
Code: [Select]
Disk /dev/sdb: 238,47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: KINGSTON RBU-SNS
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 6DD228F8-BABB-4316-A9D4-70EBF5BDF927

Device         Start       End   Sectors   Size Type
/dev/sdb1       2048   1023999   1021952   499M Windows recovery environment
/dev/sdb2    1024000   1228799    204800   100M EFI System
/dev/sdb3    1228800   1261567     32768    16M Microsoft reserved
/dev/sdb4    1261568 233877503 232615936 110,9G Microsoft basic data
/dev/sdb5  233877504 500117503 266240000   127G Linux filesystem


Disk /dev/sda: 1,82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000LM003 HN-M
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 45768881-4C8D-436F-87F3-B469538E2B2A

Device          Start        End    Sectors   Size Type
/dev/sda1        2048 2457602047 2457600000   1,1T Linux filesystem
/dev/sda2  2457602048 3292628991  835026944 398,2G Microsoft basic data
/dev/sda3  3292628992 3804678143  512049152 244,2G Linux filesystem
/dev/sda4  3804678144 3907028991  102350848  48,8G Linux filesystem
GPT PMBR size mismatch (6066815 != 15155199) will be corrected by write.

I am aware that sometimes /dev/sdb and /dev/sda are switched after a reboot.
Strange is the last line
when it was hard to write it should be hard to read

Offline towo

  • Administrator
  • User
  • *****
  • Posts: 2.702
Re: Grub/Bootmanager destroyed how to restore?
« Reply #10 on: 2022/05/30, 14:17:55 »
Code: [Select]
mount | egrep -i "/dev/sd|/dev/nv"
is missing in your post above.
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

Offline mash

  • User
  • Posts: 47
Re: Grub/Bootmanager destroyed how to restore?
« Reply #11 on: 2022/05/30, 18:21:15 »
Code: [Select]
mount | egrep -i "/dev/sd|/dev/nv"

/dev/sdb5 on / type ext4 (rw,relatime,errors=remount-ro)
/dev/sda4 on /home type ext4 (rw,nosuid,nodev,relatime)
/dev/sda1 on /media/work type ext4 (rw,nosuid,nodev,relatime)
/dev/sda2 on /media/workwin type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096)
when it was hard to write it should be hard to read

Offline towo

  • Administrator
  • User
  • *****
  • Posts: 2.702
Re: Grub/Bootmanager destroyed how to restore?
« Reply #12 on: 2022/05/30, 18:24:13 »
You have to mount /dev/sdb2 as /boot/efi, it is missing in your post!
paste your /etc/fstab!
Ich gehe nicht zum Karneval, ich verleihe nur manchmal mein Gesicht.

Offline mash

  • User
  • Posts: 47
Re: Grub/Bootmanager destroyed how to restore?
« Reply #13 on: 2022/05/30, 18:49:59 »
/etc/fstab
Code: [Select]
UUID=43af36f7-ba98-4253-8043-dd7b1cbf39f9     /                    ext4         defaults,relatime,errors=remount-ro           0    1   
zonzamas://volume1/picopartido /media/picopartido  nfs noauto,users 0 0 vers=3
zonzamas://volume1/fotowandern /media/fotowandern  nfs noauto,users  0 0 vers=3
UUID=29feb48c-ead8-4133-b541-a1c4ac134d26 /media/work ext4  auto,users,rw,exec,relatime 0       0
UUID=68E58EFC253FF11E /media/workwin ntfs auto,users,rw,exec,relatime 0 0
UUID=efedc021-0618-412f-8f84-5e0a43391e30  /home  ext4 auto,users,rw,exec,relatime  0 0

Code: [Select]
# mount /dev/sdb2  /boot/efi
# grub-install /dev/sdb
Installing for x86_64-efi platform.
Installation finished. No error reported.
when it was hard to write it should be hard to read

Offline mash

  • User
  • Posts: 47
Re: Grub/Bootmanager destroyed how to restore?
« Reply #14 on: 2022/05/30, 19:03:41 »
Hi towo, this did not really work.

After a restart the bootmanager has an entry to boot siduction but it results in grub konsole after selecting it
see image 1

When booting from USB and selecting  "detect EFI Bootloaders"
Then I select

/efi/siduction_2018.3.0/grubx64.efi
I also end up in the grub_rescue mode with error:
Code: [Select]
error: symbol 'grub_is_lockdown' not found(see image 2)
----
Edit:
the command
Code: [Select]
ls in grub_rescue results in
(hd0) (hd0,gpt3) (hd0,gpt2) (hd0,gpt1) (hd1) (hd1,gpt5) (hd1,gpt4) (hd1,gpt3) (hd1,gpt2) (hd1,gpt1) (hd2) (hd2,gpt4) (hd2,gpt3) (hd2,gpt2) (hd2,gpt1) (cd0)
I think that hd0 is the USB stick which is still inserted. hd1 is the ssd and hd2 is the data disk.
But
Code: [Select]
ls (hd1,gpt2) (or any other disk) results in Filesystem is unknown
« Last Edit: 2022/05/30, 19:25:07 by mash »
when it was hard to write it should be hard to read