Ask Your Question
1

How to remove ubuntu grub2 and reinstall fedora grub2

asked 2018-01-13 23:41:13 -0500

christianbueno gravatar image

updated 2018-01-16 08:45:48 -0500

Operating Sytems:

  • windows 10
  • fedora 27 workstation
  • ubuntu 16.04 LTS

Drives:

  • SSD 223.6 GiB
  • HDD 1.8 TiB

EFI partition: /dev/sda2
Windows : /dev/sda1 , /dev/sda3 and /dev/sda4
Fedora : /dev/sda5
fedora-home: /dev/sdb2
fedora-swap: /dev/sdb3
Ubuntu: /dev/sdb4

image description


$ lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop1    7:1    0  83,8M  1 loop /snap/core/3748
sdb      8:16   0   1,8T  0 disk 
├─sdb4   8:20   0 238,4G  0 part /
├─sdb2   8:18   0 143,1G  0 part /media/peter/2964cede-91a5-4654-8961-6b4a2b6a220e
├─sdb3   8:19   0    24G  0 part [SWAP]
└─sdb1   8:17   0   839G  0 part /media/peter/New Volume
sda      8:0    0 223,6G  0 disk 
├─sda4   8:4    0 111,4G  0 part 
├─sda2   8:2    0   100M  0 part /boot/efi
├─sda5   8:5    0 111,6G  0 part /media/peter/eeb96e78-5af0-43b7-8e25-d1573ed1eb54
├─sda3   8:3    0    16M  0 part 
└─sda1   8:1    0   499M  0 part 

$ sudo fdisk -l Disk /dev/sda: 223,6 GiB, 240057409536 bytes, 468862128 sectors 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: FD4EF25D-3C83-4EF2-A7FC-C8538648BA0D Device Start End Sectors Size Type /dev/sda1 2048 1023999 1021952 499M Windows recovery environment /dev/sda2 1024000 1228799 204800 100M EFI System /dev/sda3 1228800 1261567 32768 16M Microsoft reserved /dev/sda4 1261568 234883071 233621504 111,4G Microsoft basic data /dev/sda5 234883072 468860927 233977856 111,6G Linux filesystem

Disk /dev/sdb: 1,8 TiB, 2000398934016 bytes, 3907029168 sectors 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: E2886901-06E2-4083-91D7-C94B85C05A98 Device Start End Sectors Size Type /dev/sdb1 2048 1759543295 1759541248 839G Microsoft basic data /dev/sdb2 1759543296 2059542527 299999232 143,1G Linux filesystem /dev/sdb3 2059542528 2109874175 50331648 24G Linux swap /dev/sdb4 2109874176 2609874943 500000768 238,4G Linux filesystem

Now Ubuntu grub shows entries for windows, fedora, and ubuntu.
But the problem is that now there is no entry for the latest kernel with fedora(4.14.13-300) in the fedora advance option, only show the following:

  • the penultimate kernel with fedora.(kernel 4.14.11-300)
  • the antepenultimate kernel with fedora.(kernel 4.14.8-300
  • Invalid entry(kernel 4.14.7-300), It was remove when fedora installed the latest kernel (4.14.13-300)
  • Secure mode of fedora


Here the output of efibootmgr


[bruce@localhost ~]$ efibootmgr -v
BootCurrent: 0001
Timeout: 1 seconds
BootOrder: 0001,0003,0008,0004,0005,0002,0006,0000,0007,000B,0009,000A
Boot0000* Windows Boot Manager  VenHw(99e275e7-75a0-4b37-a2e6-c5385e6c00cb)WINDOWS.........x...B.C.D.O.B.J.E.C.T.=.{.9.d.e.a.8.6.2.c.-.5.c.d.d.-.4.e.7.0.-.a.c.c.1.-.f.3.2.b.3.4.4.d.4.7.9.5.}...,................
Boot0001* ubuntu    HD(2,GPT,f82d3b42-ad4d-41ff-b99a-3a2b32609abd,0xfa000,0x32000)/File(\EFI\ubuntu\shimx64 ...

(more)
edit retag flag offensive close merge delete

Comments

Yeah so reboot now.

BootOrder: 0002,0001...

That points to 0002 first, and 0002 is

Boot0002* Fedora    HD(2,GPT,f82d3b42-ad4d-41ff-b99a-3a2b32609abd,0xfa000,0x32000)/File(\EFI\fedora\shim.efi)

It should work. If it doesn't work, you kinda need to tell us more about what does happen rather than what doesn't happen.

cmurf gravatar imagecmurf ( 2018-01-15 23:13:56 -0500 )edit

Yes , Now after reboot there is showed the fedora-grub and I am able to select any of the 3 kernel there, thank very much pal.

christianbueno gravatar imagechristianbueno ( 2018-01-16 08:32:44 -0500 )edit

3 Answers

Sort by » oldest newest most voted
3

answered 2018-01-15 22:15:28 -0500

cmurf gravatar image

The efibootmgr output shows entry 0002 is malformed, there is no path to the bootloader. Let's delete it

efibootmgr -b 0002 -B

And let's add a new entry

efibootmgr -c -w -L Fedora -d /dev/sda -p 2 -l \\EFI\\fedora\\shim.efi

Confirm its boot entry number, is first in the Boot Order list

efibootmgr -v

Pretty sure any newly added entry will be first in the Boot Order list (it might have an entry number of 0002 or maybe something else but that number should be listed first in Boot Order.)

edit flag offensive delete link more

Comments

no, the first is ubuntu after all.

christianbueno gravatar imagechristianbueno ( 2018-01-15 23:29:55 -0500 )edit

You just posted the result of all of this and very clearly BootOrder 0002, and menu entry 0002 is Fedora, so I don't understand this comment.

cmurf gravatar imagecmurf ( 2018-01-16 00:22:27 -0500 )edit

ohh sorry, I am seeing the list below. You are right , I realized of the BootOrder option there.

christianbueno gravatar imagechristianbueno ( 2018-01-16 08:29:28 -0500 )edit

I have questions, now Is Boot0001 Ubuntu malformed? I think you meant that ubuntu had the control to say it somehow, am i wrong? And now Boot0002 Fedora has the control. Must only one Boot have the loader( --loader) always or some Boots could have one each at the same time? What if someone want to come back to Boot0001 Ubuntu? There actually always need to create a new variable bootnum, because is imposible just switch to the desired bootnum I think.

christianbueno gravatar imagechristianbueno ( 2018-01-16 09:04:55 -0500 )edit

Boot 0001 is fine, you can use --bootnext for a one time change to ubuntu or --bootorder to make it permanent. Alternative: Use the firmware's boot manager to pick Ubuntu or Fedora, I can give no advice on the user interface, because it differs for each firmware implementation. You basically have to poke it with a stick. Alternative 2 is complicated...I can't describe it in this forum.

cmurf gravatar imagecmurf ( 2018-01-16 22:34:56 -0500 )edit
1

answered 2018-01-14 21:04:00 -0500

cmurf gravatar image

On UEFI you don't need to remove one GRUB and replace with another, they both coexist on the EFI System partition. Use efibootmgr to change the bootorder, so that the first one to boot is Fedora. You can also set a one time boot entry using --bootnext.

edit flag offensive delete link more
1

answered 2018-01-14 05:21:53 -0500

When a Linux-based system installs GRUB2 into a UEFI-based firmware platform, it places the GRUB software into the EFI partition available to the operating system (a FAT16-like file system typically established during the original installation of an operating system making use of the UEFI firmware to boot up). Fedora places its GRUB installation into an "EFI/Fedora" subdirectory. Ubuntu likely does something similar.

The point is: if I'm reading your question correctly, you don't need to make any modification to your Ubuntu GRUB installation (likely in 'EFI/Ubuntu' or somewhere thereabouts) to repair your Fedora GRUB installation. You can try to do that by using the following command from within your Fedora operating system:

sudo mv /boot/grub2/grub.cfg /boot/grub2/grub.cfg.bak && sudo grub2-mkconfig -o /boot/grub2/grub.cfg

(That will back up your current GRUB configuration in case the new configuration file is faulty for some reason).

That should rebuild the GRUB menu entries and present to you the latest Fedora kernel at boot. It's unclear why or how you lost that menu entry in the first place, but that should fix it if you didn't lose the menu entry due to a GRUB configuration error (in which case rebuilding the configuration file will likely simply rebuild with the same configuration error, resulting in the same problem).

edit flag offensive delete link more

Comments

According to this fedora guide /boot/grub2/grub.cfg is for classic mbr boot. /boot/efi/EFI/fedora/grub.cfg is for uefi boot.

Create a GRUB 2 configuration

Under EFI, GRUB 2 looks for its configuration in /boot/efi/EFI/fedora/grub.cfg. For newly installed kernels to work, grubby expects /etc/grub2-efi.cfg to be a symlink to the real grub.cfg (i.e. /boot/efi/EFI/fedora/grub.cfg).

   grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
villykruse gravatar imagevillykruse ( 2018-01-14 06:33:03 -0500 )edit

i think because the ubuntu grub2 doesn't see the change that fedora did, I means added a new kernel and removed the last for show only 3 entries. Thats why i got an entry invalid( fedora-kernel 4.14.7) , although fedora removed this entry and there is a new fedora-kernel 4.14.13 ubuntu grub2 doesn't update the fedora options and doesn't display the latest kernel in the first option.

christianbueno gravatar imagechristianbueno ( 2018-01-14 19:41:23 -0500 )edit

don't should I remove first the ubuntu grub2 ?, Ubuntu grub2 has the control now , Although I update the fedora-grub2 , It will not get the control think.

christianbueno gravatar imagechristianbueno ( 2018-01-14 20:09:18 -0500 )edit

this guide doesn't work in my case. None of the commands restored fedora-grub

christianbueno gravatar imagechristianbueno ( 2018-01-14 22:00:08 -0500 )edit

You need to use efibootmgr to tell the firmware to use Fedora GRUB. Post the output from efibootmgr -v

cmurf gravatar imagecmurf ( 2018-01-15 11:54:06 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2018-01-13 23:41:13 -0500

Seen: 793 times

Last updated: Jan 16 '18