PDA

View Full Version : [kubuntu] How to edit the grub file in Kubuntu to attach Fedora Core



Gins
March 10th, 2012, 04:01 PM
Hi

I have another small problem with my Kubuntu.
My hard drive is 'sda'

I have made several partitions and installed Kubuntu on sda1.
This is the primary partition. My Kubuntu works fine.

On sda5 partition I have installed Fedora Core Linux.
Now I have to configure grub folder and write the stanza for Fedora Core.
I want to see Fedora Core.

This is very easy in Mandriva Linux. You just go to grub folder and edit the 'menu.lst' file.
I am new to Ubuntu. This is a tall order for me.
Please help me.


nissanka@nissanka-desktop:~$ sudo su
[sudo] password for nissanka:
root@nissanka-desktop:/home/nissanka# ls /
bin cdrom etc initrd.img lib64 media opt root sbin srv tmp var
boot dev home lib lost+found mnt proc run selinux sys usr vmlinuz


In the following, you will read the words 'DO NOT EDIT THIS FILE'. So I need your expert help.

oot@nissanka-desktop:/boot/grub# cat grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}

function recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=auto
load_video
insmod gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
set locale_dir=($root)/boot/grub/locale
set lang=en_US
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ]; then
set timeout=-1
else
set timeout=10
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 0,71,115; then
clear
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
if [ ${recordfail} != 1 ]; then
if [ -e ${prefix}/gfxblacklist.txt ]; then
if hwmatch ${prefix}/gfxblacklist.txt 3; then
if [ ${match} = 0 ]; then
set linux_gfx_mode=keep
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=keep
fi
else
set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "$linux_gfx_mode" != "text" ]; then load_video; fi
menuentry 'Ubuntu, with Linux 3.0.0-12-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
set gfxpayload=$linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
linux /boot/vmlinuz-3.0.0-12-generic root=UUID=b65630be-e5e6-4152-8904-6bab385f9534 ro quiet splash vt.handoff=7
initrd /boot/initrd.img-3.0.0-12-generic
}
menuentry 'Ubuntu, with Linux 3.0.0-12-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
echo 'Loading Linux 3.0.0-12-generic ...'
linux /boot/vmlinuz-3.0.0-12-generic root=UUID=b65630be-e5e6-4152-8904-6bab385f9534 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.0.0-12-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
if [ "x${timeout}" != "x-1" ]; then
if keystatus; then
if keystatus --shift; then
set timeout=-1
else
set timeout=0
fi
else
if sleep --interruptible 3 ; then
set timeout=0
fi
fi
fi
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# 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.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
root@nissanka-desktop:/boot/grub#

oldfred
March 10th, 2012, 04:05 PM
Are you booting with Ubuntu or Fedora. Usually the second to install takes over the MBR and controls booting.

Have you tried?


sudo update-grub

That runs the os-prober and updates the menu.

If not found then you may have to add a manual entry to 40_custom and run the update-grub to rewrite menu with manual command.

Gins
March 10th, 2012, 06:40 PM
Thanks oldfred for taking time to reply me.

I start with Kubuntu. That is my default operating system.
So no problems with Kubuntu.
I installed FC in 'sda5'.
I must get the GRUB menu to select FC.
So I need help to fix FC
------------------------------------------------------------
Now I got another big problem with Kubuntu.
I can't use the key board. It has gone to hell.
When I press the key 'p', the 'r' is coming to the screen.
When I pres the'n' key, 'l' comes to the screen.
Please help me to solve the problem. I tried in vain to fix the problem. I am new to Ubunutu. It seems Ubuntu gives more problems for lay people.
I can't use Kubuntu at all.

PS
I am writing to you using one of my Windows based portable computer.

oldfred
March 10th, 2012, 07:31 PM
I do not know about keyboard issue. You may want to search forum or post another thread just on that.

Download from liveCD or if you can boot into your Ubuntu, and run boot info script so we can see the details of what is installed where:

Boot Repair:
https://help.ubuntu.com/community/Boot-Repair
You can repair many boot issues with this or post the link to a run of boot info script so we can see your exact configuration.

Gorky
March 10th, 2012, 08:14 PM
Thanks oldfred
I will start a new thread.
The computer or rather Kubuntu is not working; because the keyboard is not working.
I must fix the problem before correcting other issues.

Gins
March 18th, 2012, 06:45 PM
Now I see Grub Menu at the startup.
I haven't done anything special.
If I don't do anything Kubuntu comes to the screen. In other words, Kubuntu is my default operating system.

I can go down in the menu and select Fedora Core.
It works fine and FC comes to the screen.
It gives me only 7 seconds to change the operating system.
I must edit the Grub Menu and change the 7 seconds to 15 seconds.

I have tried in vain to locate the Grub Menu. If I can edit the Grub Menu, I can change it to 15 seconds.

However, when I see the Grub Menu at the beginnig it is possible to edit by pressing 'e'. It doesn't have any leeway to change the number of seconds.

Your help is needed to change the number of seconds.
I must install Open SuSE and Mandriva too.

oldfred
March 18th, 2012, 07:58 PM
Easy way if making a lot of changes is grub customizer.

HOWTO: Grub Customizer Updated for grub 1.99
http://www.ubuntugeek.com/grub-customizer-2-2-released-and-installation-instructions-included.html
http://ubuntuforums.org/showthread.php?t=1664134
The Grub 2 Guide (formerly Grub 2 Basics) manual way
http://ubuntuforums.org/showthread.php?t=1195275

But you only need to change one small setting.

gksu gedit /etc/default/grub

Change this setting:
GRUB_TIMEOUT=10

Then update:
sudo update-grub

Gins
March 19th, 2012, 06:13 PM
Thanks Oldfred
I have done the following, which was in your URL.
--------------
sudo add-apt-repository ppa:danielrichter2007/grub-customizer
sudo apt-get update
sudo apt-get install grub-customizer
---------------
It worked fine. It created a place called ‘Grub Customizer’.
It doesn’t work. When I clicked, it asked the password. I wrote the password and it accepted.
However, no program appears. There is a minor problem.
Your thoughts are welcome.

oldfred
March 19th, 2012, 07:01 PM
I have not tried Customizer in Kubuntu, it may required some bits & pieces from Ubuntu, but I do not know.

Then you can just do the change the old fashioned way - manually edit file.

Gins
March 19th, 2012, 08:24 PM
Thanks oldfred for the reply.
How do I do manually in Kubuntu?
I did it in Mandriva. It is very simple in Mandriva.
There is a file by the name 'menu.lst' in Mandriva.
You just edit it as a root user.

In Kubuntu, you find a file by the name 'grub.cfg'.
You can just open it using the command 'cat grub.cfg'
It tells you not to edit.
So I don't want to go into uncharted territories.
Every thing can go to hell.

You find this file in /boot/grub.
Please tell me how to do this in manually in Kubuntu.


nissanka@nissanka-desktop:/boot/grub$ cat grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
set default="0"
if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}

function recordfail {
set recordfail=1
if [ -n "${have_grubenv}" ]; then if [ -z "${boot_once}" ]; then save_env recordfail; fi; fi
}

function load_video {
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
}

insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
if loadfont /usr/share/grub/unicode.pf2 ; then
set gfxmode=auto
load_video
insmod gfxterm
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
set locale_dir=($root)/boot/grub/locale
set lang=en_US
insmod gettext
fi
terminal_output gfxterm
if [ "${recordfail}" = 1 ]; then
set timeout=-1
else
set timeout=15
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###
set menu_color_normal=white/black
set menu_color_highlight=black/light-gray
if background_color 0,71,115; then
clear
fi
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
if [ ${recordfail} != 1 ]; then
if [ -e ${prefix}/gfxblacklist.txt ]; then
if hwmatch ${prefix}/gfxblacklist.txt 3; then
if [ ${match} = 0 ]; then
set linux_gfx_mode=keep
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=text
fi
else
set linux_gfx_mode=keep
fi
else
set linux_gfx_mode=text
fi
export linux_gfx_mode
if [ "$linux_gfx_mode" != "text" ]; then load_video; fi
menuentry 'Ubuntu, with Linux 3.0.0-16-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
set gfxpayload=$linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
linux /boot/vmlinuz-3.0.0-16-generic root=UUID=b65630be-e5e6-4152-8904-6bab385f9534 ro quiet splash vt.handoff=7
initrd /boot/initrd.img-3.0.0-16-generic
}
menuentry 'Ubuntu, with Linux 3.0.0-16-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
echo 'Loading Linux 3.0.0-16-generic ...'
linux /boot/vmlinuz-3.0.0-16-generic root=UUID=b65630be-e5e6-4152-8904-6bab385f9534 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.0.0-16-generic
}
submenu "Previous Linux versions" {
menuentry 'Ubuntu, with Linux 3.0.0-12-generic' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
set gfxpayload=$linux_gfx_mode
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
linux /boot/vmlinuz-3.0.0-12-generic root=UUID=b65630be-e5e6-4152-8904-6bab385f9534 ro quiet splash vt.handoff=7
initrd /boot/initrd.img-3.0.0-12-generic
}
menuentry 'Ubuntu, with Linux 3.0.0-12-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {
recordfail
insmod gzio
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
echo 'Loading Linux 3.0.0-12-generic ...'
linux /boot/vmlinuz-3.0.0-12-generic root=UUID=b65630be-e5e6-4152-8904-6bab385f9534 ro recovery nomodeset
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-3.0.0-12-generic
}
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
linux16 /boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
insmod part_msdos
insmod ext2
set root='(hd0,msdos1)'
search --no-floppy --fs-uuid --set=root b65630be-e5e6-4152-8904-6bab385f9534
linux16 /boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
menuentry "Fedora release 16 (Verne) (on /dev/sda5)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos5)'
search --no-floppy --fs-uuid --set=root 1c449cd2-a915-42ef-9278-fec410a65e13
linux /boot/vmlinuz-3.1.0-7.fc16.x86_64 root=/dev/sda5
initrd /boot/initramfs-3.1.0-7.fc16.x86_64.img
}
menuentry "Fedora release 16 (Verne) (on /dev/sda5)" --class gnu-linux --class gnu --class os {
insmod part_msdos
insmod ext2
set root='(hd0,msdos5)'
search --no-floppy --fs-uuid --set=root 1c449cd2-a915-42ef-9278-fec410a65e13
linux /boot/vmlinuz-3.2.9-2.fc16.x86_64 root=/dev/sda5
initrd /boot/initramfs-3.2.9-2.fc16.x86_64.img
}
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# 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.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###
nissanka@nissanka-desktop:/boot/grub$

SeijiSensei
March 19th, 2012, 09:02 PM
But you only need to change one small setting.

gksu gedit /etc/default/grub

Change this setting:
GRUB_TIMEOUT=10

Then update:
sudo update-grub

Did you try this?

Editing grub.cfg is discouraged in Ubuntu. You'll notice that write privileges for the file are disabled for all users including root. Use /etc/default/grub and update-grub instead.

Gins
March 19th, 2012, 10:12 PM
Thanks for the reply.

----------------
Use /etc/default/grub and update-grub instead.
----------------
Could you please write the command to upgrade?
It should be something like 'sudo apt-get ...

oldfred
March 20th, 2012, 12:45 AM
Again I missed the kbuntu. You probably do not have gedit. It probably is kate for screen editing. Or you can use nano for a terminal editor.

sudo nano /etc/default/grub

oldos2er
March 20th, 2012, 07:12 PM
See http://kde-apps.org/content/show.php?content=139643&forumpage=2&PHPSESSID=0752361c941a862b11d379edc37b65c1

It's a graphical grub2 editor for KDE.