LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 10-19-2011, 02:07 PM   #16
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 347Reputation: 347Reputation: 347Reputation: 347

Quote:
Originally Posted by cliffd7 View Post
Thanks PT, I am comfortable with that but where is the editable file that has the lines which appear on the menu?
Cliff
That's the grub.gfg file. Look first for a symbolic link at /etc/grub.cfg or /etc/grub2.cfg If neither of those links are there, do a sudo find /boot -type f -name grub*cfg -ls to locate the actual file. On my Fedora 16 system, that shows this:
Code:
$ sudo find /boot -type f -name grub*cfg -ls
1519985    8 -r--------   1 root     root         5458 Oct  4 15:17 /boot/grub/grub.cfg
2084818    8 -r--------   1 root     root         5577 Oct 15 09:42 /boot/grub2/grub.cfg
Note that even "root" has only read permission to the file, so, in order to edit it, you need to do this:
Code:
$ sudo chmod u+w /boot/grub2/grub.cfg
$ sudo gedit /boot/grub/2/grub.cfg
Note that you can also tell the standard system to use your personally crafted configuration file by using this code in your /etc/grub.d/ directory:
Code:
$ cat /etc/grub.d/41_custom 
#!/bin/sh
cat <<EOF
if [ -f  \$prefix/custom.cfg ]; then
  source \$prefix/custom.cfg;
fi
EOF
and putting you customized configuration file, custom.cfg, in /boot/grub or /boot/grub2 depending on the location your version of Ubuntu is using. The problem is (unless you use the savedefault macro) you'll have your custom settings after the automatic stuff you wanted to skip. (Although naming the custom file 01_mycustom should insert it right after the header since the files in /etc/grub.d/ are processed in alphabetical order.
 
Old 10-20-2011, 03:26 AM   #17
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Thanks PT
First off;

*sudo find /boot -type f -name grub*cfg -ls*
No command '*sudo' found, did you mean:
Command 'sudo' from package 'sudo' (main)
Command 'sudo' from package 'sudo-ldap' (universe)
*sudo: command not found

So I then;

cliff@cliff-desktop:~$ sudo find /boot -type f -name grub*cfg -ls
[sudo] password for cliff:
9437394 8 -r--r--r-- 1 root root 4173 Oct 19 13:32 /boot/grub/grub.cfg
cliff@cliff-desktop:~$

You will see that this has only one line.
I don't see where I go from here
Cliff
Cliff
 
Old 10-20-2011, 11:50 AM   #18
hen770
Member
 
Registered: Oct 2010
Distribution: Arch
Posts: 136

Rep: Reputation: 7
Just try to do what EDDY1 wrote.
I don't like the idea of being edit my grub.cfg file every kernel update.
In general ubuntu should remove automaticly the entries ok the old kernels, try to remove the old kernels with synaptic then reboot ans see your grub menu.

Another easy solution is, to delete any file in the /boot that has the old kernel number, then run update-grub. Try to do so with the oldest kernel on your system, that you are sure you aren't boot your system with it.
 
Old 10-20-2011, 12:20 PM   #19
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 347Reputation: 347Reputation: 347Reputation: 347
That's strange. I thought that Ubuntu's security model required sudo to be available.

Anyhow, since you installed the missing command, the "one line" is what you needed to know. (I had more than one line because I was/am working on several different Fedora distributions, and GRUB 2 will not be standard on Fedora 'till Fedora 17 is released next year. so it gets installed in various different places.)

Anyhow, what the line tells you is that, on your Ubuntu distribution, GRUB 2 is installed in /boot/grub/, and that [/boot/grub/grub.cfg is the configuration file you want to edit.

What I'd suggest is that you add the file I posted above to your /etc/grub.d/ directory as 00_mycustom (or whatever name you want to use is long as it sorts to be between 00_header and 01_linux), do a sudo cp /boot/grub/grub.cfg /boot/grub/custom.cfg to create a custom copy of your current configuration file. (I'd also recommend you create a backup copy of your grub.cfg file with a sudo cp /boot/grub/grub.cfg /boot/grub/grub.cfg.old - See below for why you might need this.)

Then do a sudo gedit /boot/grub/custom.cfg and edit it. Since the custom.cfg file is inserted after the 00_header file is processed, you can (and should) delete the part of the custom.cfg file that precedes the first menuentry stanza. Then change the order of the stanzas you want to keep, and delete anything you don't want.

Save the modified custom.cfg file, run sudo grub-mkconfig -o /boot/grub/grub.cfg, reboot, and your stuff should be listed first with the whole automatically generate menu items following your stanzas.

If, for some reason, GRUB 2 can't boot with the custom.cfg file inserted, it should bump you into the GRUB mini editor with a GRUB> prompt. You can then boot from you backup configuration file by entering the command configfile /boot/grub/grub.cfg.old. (Note that, if the file isn't found, GRUB supports "tab completion," so you can, for example, do a configfile /<tab> to get a list of files (and directories) in GRUB's root directory (which is not necessarily the same as Ubuntu's root), and find the backup configuration file. Usually, if /boot/grub/grub.cfg.old doesn't work, /grub/grub.cfg.old will be the correct location. This is what happens when the boot partition is different from the root partition.)
 
Old 10-20-2011, 01:15 PM   #20
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Thanks PT,
That is beginning to make sense,although as "hen770" says I wouldn't want to do this every time I do an update.
I'll work on this tomorrow.
Cliff
 
Old 10-20-2011, 01:59 PM   #21
colorpurple21859
Senior Member
 
Registered: Jan 2008
Location: florida panhandle
Distribution: slackware64-current, puppy, ubuntu
Posts: 2,437

Rep: Reputation: 361Reputation: 361Reputation: 361Reputation: 361
You could also just rename the /etc/grub.d/40_custom to a number lower than 10_linux and copy the entries from your /boot/grub/grub.cfg to it that you want to be first on your grub menu
 
Old 10-20-2011, 06:22 PM   #22
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 347Reputation: 347Reputation: 347Reputation: 347
Quote:
Originally Posted by cliffd7 View Post
Thanks PT,
That is beginning to make sense,although as "hen770" says I wouldn't want to do this every time I do an update.
I'll work on this tomorrow.
Cliff
Well, that should be "a kernel update." If the kernel isn't changed, what you have in your custom.cfg file should work, and if, for some reason, you want to use some new option, all you'll need to do is scroll down to the automatically generated boot stanzas and use whichever one you want to use.

As far as I know, since Ubuntu releases new versions about every six months, they seldom release any new kernel versions unless they are made to fix security problems or serious bugs, so you probably won't need to update your custom configuration file too often.
 
Old 10-22-2011, 03:41 AM   #23
cliffd7
Member
 
Registered: Sep 2010
Posts: 33

Original Poster
Rep: Reputation: 0
Thanks PT, and all who have contributed to this thread.
It can now be close and considered Solved.
Cheers
Cliff
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delete Duplicate Lines in a file, leaving only the unique lines left xmrkite Linux - Software 6 01-14-2010 06:18 PM
to add Mandriva grub boot lines to the main menu.lst file, using 2 hard drives james2b Linux - Newbie 5 10-09-2008 06:20 PM
Why GRUB will not start the menu-interface? alpha1truth Fedora 1 09-26-2007 02:30 PM
Perl adding unwanted lines at EOF? ryedunn Programming 1 09-07-2006 09:35 AM
awk/gawk/sed - read lines from file1, comment out or delete matching lines in file2 rascal84 Linux - General 1 05-24-2006 09:19 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 11:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration