Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello to the forums,
I want to completely purge and reinstall grub and I want to know the correct procedure.
The system is giving me a problem; it does not let me boot from USB anymore. Too many entries (more than 100) of the Debian system. Deleting the entries with efibootmgr does not correct this as the entries keep coming back.
aris@hp2Debian:~$ sudo ls -hl /boot/
drwx------ 3 root root 4.0K Jan 1 1970 efi
drwxr-xr-x 5 root root 4.0K Nov 2 18:11 grub
My questions
Should I delete these two directories (/boot/efi, /boot/grub)? Are they going to be recreated?
Do I need to delete the directory /etc/grub.d or any directories or files in there? Are they going to be recreated?
Do I need to delete anything else?
And I need an explanation on grub-install. Is there any case that you install grub on dev/sda1? Or you always install grub on /dev/sda?
I want to completely purge and reinstall grub and I want to know the correct procedure.
And you know this is something that anyone would be in the habit of doing, and so know "the correct procedure"? I'm guessing few, if any know "the" correct procedure. Most likely complete includes:
remove the Grub-related packages that installation includes:
Code:
# Dq grub
dpkg-query -l
rc grub-common 2.02+dfsg1-4 amd64 GRand Unified Bootloader (common files)
rc grub-efi-amd64 2.02+dfsg1-4 amd64 GRand Unified Bootloader, version 2 (EFI-AMD64 version)
# apt install grub-efi-amd64
Reading package lists
....
The following additional packages will be installed:
grub-common grub-efi-amd64-bin grub2-common
Suggested packages:
multiboot-doc grub-emu mtools xorriso desktop-base
Recommended packages:
os-prober grub-efi-amd64-signed
The following NEW packages will be installed:
grub-common grub-efi-amd64 grub-efi-amd64-bin grub2-common
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,124 kB of archives.
After this operation, 28.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] n
You may or may not want os-prober, depending on whether this is to be a primary Grub intended to automatically include installations other than Bookworm (I shouldn't have needed to dig through your prior thread to discover this is your current Debian version), or have them included via custom.cfg, or customization in /etc/grub.d/.
Remove all disks that have Grub installed anywhere on them
Clear BIOS, so that all UEFI boot entries are removed from NVRAM
Boot with no bootable media attached, to ensure NVRAM is clear of obsolete entries
At this point, for some definition of "completely purge", the completed activity might constitute success.
Quote:
My questions
Should I delete these two directories (/boot/efi, /boot/grub)?
On UEFI systems, grub-install -v /dev/sda is definitely not appropriate. Grub works differently prior to actually presenting a boot menu on UEFI. It's ESP-based, nothing to do directly with any MBR or boot track.
if you have too many entries you need to clean up the config file, do not need to reinstall it.
From the other hand if grub created that huge config file it will do next time again, because it automatically detects things. Most probably you need to solve the real issue, why do you have more than 100 entries?
Oh yes, probably you know that, without grub you will not able to boot your system at all, so removing grub may cause additional troubles too.
Your other thread you linked to in your first post indicates that you use Debian and the other installs are simply for testing, it would seem far simpler to install Grub to a USB drive and copy the various iso files to the USB drive and manually create entries in the grub.cfg file. This would eliminate the extraordinary number of boot entries you currently have. If you are not familiar with Grub and manually creating entries this won't help but it isn't really that difficult. Lots of links explaining how to do it. I do this to test and have 25 Linux iso files which boot Legacy and EFI on a 64GB flash drive.
Purging the grub package will not fix the problem. Is there more than one drive on the system with an efi partition? With the usb not plugged in at boot-up do the mutiple boot entries go away when f9 is pressed?
On a side-note when a system is booted in uefi mode it is just "grub-install" , sda or sda1 is not needed and will be ignored by grub-install. The grub boot loader code will be intalled to the efi partition that is mounted to /boot/efi.
Last edited by colorpurple21859; 11-06-2022 at 08:05 AM.
According to this command I think that most grub related packages will be removed. And of course I do not know what all these packages are but they should be all grub related.
Code:
aptitude purge -s grub-common
The following 15 packages will be REMOVED:
efibootmgr{u} grub-common{p} grub-efi-amd64{a} grub-efi-amd64-bin{a} grub-efi-amd64-signed{a} grub2-common{a} libefiboot1{u} libefivar1{u} libfuse2{u} mokutil{u} os-prober{u}
shim-helpers-amd64-signed{u} shim-signed{a} shim-signed-common{u} shim-unsigned{u}
I do not know the files of /etc/grub.d and I do not configure anything there. I just let update-grub do it's own thing.
I should have mentioned that I had purged grub from six of the eight distros, I just left grub on the Debian and MX distros. I did delete the MX directory and all other distros apart from Debian from /boot/efi/EFI (I think they were there). The command used to purge grub was "apt purge grub-common" in the other six distros.
I have two disks in the laptop. The main disk which has grub and the distributions, and the second disk which is just used for backups. Shoud I remove the main disk? And is that for clearing the BIOS?
Is this a neccessary step (both removing the main disk and clearing BIOS)? Removing the disk and clearing the BIOS will involve removing the bottom panel which is a painful process.
In /boot/efi/EFI/debian there is a file "shimx64.efi" (I think) which from what I have read in a Debian's users forum thread, is responsible for the many entries. According to that thread you can delete it but the entries will most likely come back.
(I did quite some searching before posting this, as I usually do. When I come to a dead end I just post a question.)
Are you talking about the file I mentioned in the paragraph above (last paragraph of mrmazda)?
I did remove some entries with efibootmgr but they do come back. As I read somewhere in my searches it could be a bug on multiboot systems.
Before I purge grub I will remove some entries until I see that I can boot my USB installation which can boot all eight distributions in the laptop. That is possible until grub is updated on the Debian system (by updates). After that it is blocked (edit: the USB entry; /edit) and it is not shown as a boot option in the laptop BIOS.
Last edited by Debian6to11; 11-06-2022 at 01:32 PM.
I am not so familiar with grub. I did read about it (in grub's manual and LFS) and the manual entries look just very simple compared to the distributions grub. Maybe I will try it sometime?
Actually the whole laptop is used for testing/fun/learning but when I do something with it I mostly use the Debian distro. That laptop has a twin in which I will put another eight distros most likely, when I have time to spare. I will only install grub in one distro though when I do that.
That is the reason why I asked about deleting those directories.
There is only one real disk and the second disk is only used for backups.
On the laptops boot menu I have about a dozen debian entries and a couple of network entries. When I remove some entries with efibootmgr, the USB entry comes back (for a while). Read what I wrote for pan64.
Also I have removed some lines because the post was too long for the forums.
And I do not know from where "Boot0010* Ubuntu" entry comes from as I do not have such a directory in /boot/efi/EFI. I believe that is the Bodhi distro.
I have two disks in the laptop. The main disk which has grub and the distributions, and the second disk which is just used for backups. Shoud I remove the main disk? And is that for clearing the BIOS?
Is this a neccessary step (both removing the main disk and clearing BIOS)? Removing the disk and clearing the BIOS will involve removing the bottom panel which is a painful process.
You may be able to accomplish NVRAM cleanup doing less. Some BIOS just don't manage housekeeping very well, if at all. The proof is in your post #10.
I have a Clonezilla image of the EFI partition on the second disk. It was done when I finished installing the eight distributions. It will include all distributions grub inside though. Since then I also switched (actually reinstalled) partitions 5 and 9, Freespire with Kali, because Kali is using a bit of space. Gained 4GB for Kali. I will Clonezilla the first disk again if all goes well.
I will try deleting (/boot/efi, /boot/grub) these directories, after making a backup, and purging and reinstalling grub-common later on (probably today). I will be posting back how it went.
It was not difficult and everything is looking good.
First I manually deleted the 100 plus entries from /sys/firmware/efi/efivars so I could boot from a USB in case of problems. This is way faster than using efibootmgr (thanks to a post from arch bbs).
Then I deleted /boot/efi/EFI and /boot/grub, and purged grub-common (15 packages). I had to install two packages (grub-common and grub-efi-amd64) to pull those 15 packages back.
After a simple grub-install (thanks colorpurple21859), I had to uncomment a line in /etc/default/grub (GRUB_DISABLE_OS_PROBER=false) for os-prober to work with update-grub.
And a reboot showed that everything went fine. Also loaded two distros and is looking good.
The output of efibootmgr now is normal, let's hope it stays like that.
Code:
aris@hp2Debian:~$ efibootmgr -v
BootCurrent: 0001
Timeout: 0 seconds
BootOrder: 3001,000F,000E,2001,2002,2003
Boot0001* debian HD(1,GPT,a13692c0-aa2c-4bec-8669-a98f290251d6,0x800,0x200000)/File(\EFI\debian\shimx64.efi)
Boot000E* Network Adapter (IPv6 UEFI) PciRoot(0x0)/Pci(0x1c,0x0)/Pci(0x0,0x0)/MAC(28924a28302c,0)/IPv6([::]:<->[::]:,0,0)RC
Boot000F* Network Adapter (IPv4 UEFI) PciRoot(0x0)/Pci(0x1c,0x0)/Pci(0x0,0x0)/MAC(28924a28302c,0)/IPv4(0.0.0.00.0.0.0,0,0)RC
Boot2001* USB Drive (UEFI) RC
Boot2002* Internal CD/DVD ROM Drive (UEFI) RC
Boot3001* Internal Hard Disk or Solid State Disk RC
@ pan64
I saw your post but decided to go all the way.
Thanks to all that replied, you have been helpful.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.