Peppermint | Linux OS Community Forum
 
It is currently Sat May 26, 2018 12:15 am

All times are UTC - 5 hours [ DST ]





Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [One][Ice][Two] Manually Editing Grub2
PostPosted: Tue Jun 15, 2010 5:37 pm 
Offline
User avatar

Joined: Wed May 19, 2010 5:11 pm
Posts: 958
Location: Asheville, North Carolina
Class: Bootloader configuration tutorial
Difficulty: Advanced: User's risk
Time: Ten to twenty minutes
Desirability: Necessary for custom scripts / kernel options etc.

This tutorial is for those users who want to manually edit their Grub2 menu by editing the /etc/default/grub file and creating custom scripts. WARNING!!! This tutorial is based on examples only so it may narf your Grub2 menu so use it at your own risk.

First off DO NOT EDIT THE GRUB.CFG FILE!!! Instead you can create scripts in the /etc/grub.d file and then you will need to make the script executable. The following is a sample custom script to add custom menus to your Grub2 menu.

Code:
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries.
# Simply type the menu entries you want to add after this comment.
# Be careful not to change the _exec tail_ line above.

echo "Adding RescueCD" >&2
menuentry "Peppermint Rescue CD" {
set root=(hd0,09)
linux /sysrcd/rescuecd subdir=sysrcd setkmaps=us
initrd /sysrcd.initram.igz
}


Now remember this is a script and needs to be made executable by running the following command.

Code:
sudo chmod +x /etc/grub.d/"filename"


Notice the "filename" at the end of the command and you may be asking yourself what file name I don't recall making a file I just made a script. Well here is the answer to that question, everything in Linux is a file no matter what it is. Lets look at this for a moment and figure out what is going on here. When you run the command update-grub, Grub2 will read /etc/default/grub and the files (scripts) that are in the /etc/grub.d folder. This sets how the Grub2 menu will look like visually (/etc/default/grub) and search for Linux kernels, other operating systems, and items that are setup by user-created scripts in /etc/grub.d.

The script files in this folder perform the following tasks and in this order.
1. 10_linux looks for installed Linux kernels
2. 30_os-prober looks for other operating systems
3. 40_custom and any other user-created files in the /etc/grub.d folder add menu items designated in the script files created by users. The name of the file determines the order in the menu like so, 30_os-pober entries will be placed before 40_custom entries, which will be placed before 50_my-custom ones. The file name should take the format XX_name, where XX is a number followed by an underscore and name.

If you want your custom entries to be placed at the top of the menu, create the file and name it 09_xxxx because the files in /etc/grub.d are read sequentially so those placed in 09_custom will be placed before those of 10_linux. Do not place any custom entries below 06_custom to ensure that any themes placed in 05_debian_theme runs before your custom menu is created. After you are done run this command.

Code:
sudo update-grub


Lastly check the value of Default in the /etc/default/grub. If it dose not point to the right menu change the value of DEFAULT to the correct value.

_________________
Support Team Leader
Co-Creator of Lubuntu x86_64

I'm on Twitter: @Asheguy
I'm on identi.ca: http://identi.ca/asheguy

Linux User #507486


Top
 Profile  
 
 

Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Powered by php B.B. © 2000, 2002, 2005, 2007 php B.B. Group
Template made by DEVPPL