Choose style:

Author Topic: Strange grub2 results after a power outage.  (Read 412 times)

0 Members and 1 Guest are viewing this topic.

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 887
  • Karma: 43
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9 (64bit), P 9 R
Strange grub2 results after a power outage.
« on: February 08, 2019, 09:25:29 pm »
Hello Peppermint people. Today I experienced something that has never happened before. Usually after a power outage, we get a lot of those here, I never had a problem restarting my computer. Normally I would get a couple of lines of checking something or other and then the sda1 or more recently, sda2 is clean report followed by bootup. This includes power outages with the new UEFI boot system on my new SSD. Well today, I got a screen that was completely new to me and I had no clue as to how to proceed. So I thought I might try reinstalling grub from a usb live session but the instructions I have are for BIOS mode and didn't work. I couldn't find anything here about how to reinstall grub with UEFI so I googled it and found this solution from LinuxSuperuser

Code: [Select]
sudo mount /dev/sda2 /mnt
sudo mount /dev/sda1 /mnt/boot/efi
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
sudo chroot /mnt
grub-install /dev/sda
update-grub

This worked great! I only hope I don't have to bootup a live session every time I have a power outage.  :)
What was I thinking?

Online VinDSL

  • Global Moderator
  • Hero
  • *****
  • Posts: 4803
  • Karma: 880
  • Peppermint Mod
    • View Profile
  • Peppermint version(s): Developmental Builds
Re: Strange grub2 results after a power outage.
« Reply #1 on: February 08, 2019, 10:45:52 pm »
Congratulations! You're a member of the chroot club  ;D

Chroot is your friend. It's saved my butt a zillion times...

Online PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 23916
  • Karma: 2650
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Strange grub2 results after a power outage.
« Reply #2 on: February 09, 2019, 04:49:50 am »
Yeah, EVERYONE  should know and understand chroot .. it's as if it were sent by god himself for the benefit of us mere mortals :)

Did I just call Bell Labs god ? .. so be it :)
(I didn't realise Morgan Freeman was married to Ma Bell)

Micro fact:-
chroot was first introduced to Version 7 UNIX in 1979 when it was owned by Bell Labs, according to Wikipedia:
https://en.wikipedia.org/wiki/Chroot
I find this stuff fascinating
(how sad am I ?)

PS. How the heck did they fix UNIX when it broke prior to 79 :-\
(I guess like Windows .. reinstall)

If they were in World War Two they'd call them spitfire .. because you know that they can.
« Last Edit: February 09, 2019, 05:15:14 am by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 887
  • Karma: 43
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9 (64bit), P 9 R
Re: Strange grub2 results after a power outage.
« Reply #3 on: February 09, 2019, 11:04:06 pm »
Yeah, EVERYONE  should know and understand chroot .. it's as if it were sent by god himself for the benefit of us mere mortals :)

Did I just call Bell Labs god ? .. so be it :)
(I didn't realise Morgan Freeman was married to Ma Bell)

Micro fact:-
chroot was first introduced to Version 7 UNIX in 1979 when it was owned by Bell Labs, according to Wikipedia:
https://en.wikipedia.org/wiki/Chroot
I find this stuff fascinating
(how sad am I ?)

PS. How the heck did they fix UNIX when it broke prior to 79 :-\
(I guess like Windows .. reinstall)

If they were in World War Two they'd call them spitfire .. because you know that they can.

Okay, so where can I find some good explanations of how and when to use chroot?
What was I thinking?

Online VinDSL

  • Global Moderator
  • Hero
  • *****
  • Posts: 4803
  • Karma: 880
  • Peppermint Mod
    • View Profile
  • Peppermint version(s): Developmental Builds
Re: Strange grub2 results after a power outage.
« Reply #4 on: February 10, 2019, 12:39:26 am »

Online PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 23916
  • Karma: 2650
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Strange grub2 results after a power outage.
« Reply #5 on: February 10, 2019, 09:00:00 am »
Basically once you understand what chroot does, it'll become obvious when/where it can be used.

It was a (broken) GRUB reinstall that first opened my eyes to it .. so try to understand what it's doing here (though it tells you in the first line):
https://help.ubuntu.com/community/Grub2/Installing#via_ChRoot
and you'll quickly think of ideas where it could be used.
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 887
  • Karma: 43
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9 (64bit), P 9 R
Re: Strange grub2 results after a power outage.
« Reply #6 on: February 10, 2019, 09:03:44 am »
Thanks VinDSL, from the looks of it, I don't think I'll be using chroot very much on my own, looks more like something you guys that know what you're doing would use often. I like the warning at the end of the second site about not emptying trash though.  :)
What was I thinking?

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 887
  • Karma: 43
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9 (64bit), P 9 R
Re: Strange grub2 results after a power outage.
« Reply #7 on: February 10, 2019, 09:45:36 am »
Basically once you understand what chroot does, it'll become obvious when/where it can be used.

It was a (broken) GRUB reinstall that first opened my eyes to it .. so try to understand what it's doing here (though it tells you in the first line):
https://help.ubuntu.com/community/Grub2/Installing#via_ChRoot
and you'll quickly think of ideas where it could be used.
,

Okay PCNetSpec, if I understand this correctly, and say I wanted to swap out lets say lubuntu with Xubuntu on my other than Peppermint partition, after completing the install, I would boot up into Peppermint and perform a grub2 purge and reinstall? I think this answers a future question I would have had with the new UEFI harddrive.  :-\
What was I thinking?

Offline murraymint

  • Trusted User
  • Veteran
  • *****
  • Posts: 1852
  • Karma: 314
  • soft boiled with a yolk of gold
    • View Profile
  • Peppermint version(s): 7, 8, 9
Re: Strange grub2 results after a power outage.
« Reply #8 on: February 10, 2019, 09:51:25 am »
That's not really it. If your Peppermint broke and you couldn't get it to update or fix itself using apt, you could chroot into it from another Linux and hopefully apt would work.

Online PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 23916
  • Karma: 2650
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Strange grub2 results after a power outage.
« Reply #9 on: February 10, 2019, 03:30:36 pm »
What murraymint said

Imagine you have a broken system for whatever reason .. you can:-

i) boot from a fully working system (such as a LiveUSB)
ii) mount the broken system somewhere in the working one
iii) use chroot so that any commands that you run in the working system are actually APPLIED to the broken system.

So for example, you went to install some updates one of which was say the graphics drivers or maybe grub, etc. .. but you have a power outage in the middle of the update. You now have a system with only half installed graphics drivers or grub .. you could boot a LiveUSB, mount your Peppermint partition at say /mnt of the Live session, then 'chroot /mnt' .. now if you say reinstall the graphics drivers or grub from the command line in the Live environment, the changes are ACTUALLY being applied to the broken system you chroot(ed) into

So you were able to fix a non-bootable broken system from within a working one .. by effectively saying "apply the changes elsewhere".

The name says it all .. chroot = change root.



There are uses for chroot other than 'fixing' a broken system .. for example,  running unknown/untrusted software firewalled inside a chroot environment to protect the rest of your system.

But fixing broken systems are likely its most common use, and the one I meant when I said "everyone should know and understand chroot" :)
« Last Edit: February 10, 2019, 03:40:36 pm by PCNetSpec »
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 887
  • Karma: 43
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9 (64bit), P 9 R
Re: Strange grub2 results after a power outage.
« Reply #10 on: February 12, 2019, 09:59:32 am »
Okay, so what happens to the efi entry for the os I delete from my ssd say by reformatting the partition it was on, or even deleting the partition?
What was I thinking?

Offline murraymint

  • Trusted User
  • Veteran
  • *****
  • Posts: 1852
  • Karma: 314
  • soft boiled with a yolk of gold
    • View Profile
  • Peppermint version(s): 7, 8, 9
Re: Strange grub2 results after a power outage.
« Reply #11 on: February 12, 2019, 11:00:22 am »
I think it gets left behind, orphaned until you delete it using EFI boot manager.

Offline alynur

  • Trusted User
  • Member
  • *****
  • Posts: 887
  • Karma: 43
  • Habitual Forum Browser
    • View Profile
  • Peppermint version(s): P 9 (64bit), P 9 R
Re: Strange grub2 results after a power outage.
« Reply #12 on: February 12, 2019, 02:14:57 pm »
Thanks murraymint, I think this site http://manpages.ubuntu.com/manpages/bionic/man8/efibootmgr.8.html
 explains it well enough for me to understand. Once again you guys gave me the push I needed to investigate what was puzzling me.   :)
What was I thinking?

Online PCNetSpec

  • Administrator
  • Hero
  • *****
  • Posts: 23916
  • Karma: 2650
  • "-rw-rw-rw-" .. The Number Of The Beast
    • View Profile
    • PCNetSpec
  • Peppermint version(s): Peppermint 8R, 9, and 9R
Re: Strange grub2 results after a power outage.
« Reply #13 on: February 12, 2019, 06:40:15 pm »
Yeah the UEFI bootloader will get left behind on the ESP partition, but it's pretty small and won't hurt anything

If you want, you can always delete it with efibootmgr.
(or manually by mounting the ESP partition)
WARNING: You are logged into reality as 'root' .. logging in as 'insane' is the only safe option.

Team Peppermint
PCNetSpec