How can I edit my Grub bootloader entries (Hide, Rename, Remove)?
So basically I have a pretty flooded Grub bootloader, with older linux versions, 3 operating systems and memtests. What I want is to leave the operating systems only. I need to know how to do it manually, and I need someone to tell me what should I be aware of when a new kernel is released. Thanks in advance.
Solution 1:
The blog post GRUB2 revisited will provide you with a blow-by-blow set of instructions on how to manually edit GRUB2's configuration files. If you check the other postings in the series (by filtering on Category = GRUB) you will also find information on removing old kernels and what happens when a new kernel arrives as an update. The postings include references to a number of related web sites.
Solution 2:
Use grub-customizer: https://launchpad.net/grub-customizer
sudo apt install grub-customizer
This is a GUI that will allow you to hide unwanted grub entries.
This is how the grub-customizer
looks like
Solution 3:
Rather than edit the grub file directly, you should clean up the kernels you don't want.
Start with this:
dpkg -l | grep linux-image
The update-grub
script just makes entries for everything it finds in /boot
, as far as I'm aware, so removing old linux-image (and linux-headers) packages via apt-get remove
will clean up /boot and therefore clean up your grub config.
This is the "proper" way to do it and hence will require no special action when newer kernels are released in the future, you'll just have to clean up again at some point probably :)
Solution 4:
Configuring GRUB v2
The configuration file is /boot/grub/grub.cfg, but you shouldn't edit it directly. This file is generated by grub v2's update-grub(8), based on:
The script snippets in /etc/grub.d/
The configuration file /etc/default/grub
To configure grub "v2", you should edit /etc/default/grub, then run update-grub. Advanced configuration are achieved by modifying the snippets in /etc/grub.d/.
taken from Debian configuration.
Solution 5:
Run sudo update-grub
in terminal so as to include any "forgotten" boot options.
If you don't like command lines, you can open terminal, run sudo nautilus
and use your file explorer as root. ;)
Then, still in terminal, goto the folder where the grub configuration file is stored. Usually sudo cd /boot/grub
should do the trick, otherwise find your grub configuration file by searching for grub.cfg
and change the folder.
GUI: click on DEVICES->COMPUTER->boot->grub or search DEVICES->COMPUTER for file.
Once you have located the folder and opened it, run sudo cp grub.cfg grubOldXX.cfg
where XX is a serial numeral of your choice.
GUI: copy paste grub.cfg
Then, run sudo gedit grub.cfg
GUI: right click grub.cfg
and choose EDIT
Edit out the entries that you don't want and change your boot order and default boot option as desired (it is straightforward enough). Every menu entry is conveniently preceded by the term menuentry
. Delete everything from menuentry
all the way up to and including the first closing curly bracket }
.
SAVE YOUR FILE and EXIT GEDIT.
IMPORTANT: Messing with grub is an activity which has an enormous possibility of going catastrophically wrong. If your configuration file is messed up your computer simply might not boot.
Always have a DVD with a version of Ubuntu handy (no matter what version). You can always boot from your DVD or other removable media in case you run into problems and, since you saved a copy of your original (working) version, you rename your files reinstating grubOldXX.cfg
as grub.cfg
.