LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   May I edit the file "grub.cfg" without causing harm to my system? (https://www.linuxquestions.org/questions/linux-newbie-8/may-i-edit-the-file-grub-cfg-without-causing-harm-to-my-system-812522/)

seamuscristo 06-06-2010 01:57 PM

May I edit the file "grub.cfg" without causing harm to my system?
 
I am brand new- and sorry to say rather poor at searching the forums for an answer to my first question. Having come up short on a way to clean up my grub menu, I started digging until I found the file "grub.cfg" which appears to list the instances of Linux available for me to boot.

Before I delete lines in the file such as:

}
menuentry "blah blah Ubuntu number.number-22" { ... etc

I want to know if it's ok.
I have updated Ubuntu twice since starting it up, and was surprised to find more options in GRUB each time.

Secondarily, I would like to know which program to use when editing this file (if it is the file I want to edit).
Before switching to Linux I was in the process of learning UNIX for a web company, and Learning to use the VI for my own regex interests. I'm a little sad to find that VIM is not equipped with the same commands (thank god for :q!) and would seek the advice of seasoned users in the matter of editing files.

In case you can't guess, I am extremely new and excited to be working with Linux and to be posting a thread on a forum. Advance thanks for your assistance-

brianL 06-06-2010 02:10 PM

If you're referring to entries for old kernels, and if you're certain that the latest kernel is working OK, then yes, you can delete the old entries.

lugoteehalt 06-06-2010 02:25 PM

Quote:

Originally Posted by seamuscristo (Post 3994558)
Before I delete lines in the file such as:

}
menuentry "blah blah Ubuntu number.number-22" { ... etc

I want to know if it's ok.
I have updated Ubuntu twice since starting it up, and was surprised to find more options in GRUB each time.

Secondarily, I would like to know which program to use when editing this file (if it is the file I want to edit).
Before switching to Linux I was in the process of learning UNIX for a web company, and Learning to use the VI for my own regex interests. I'm a little sad to find that VIM is not equipped with the same commands (thank god for :q!) and would seek the advice of seasoned users in the matter of editing files.

In case you can't guess, I am extremely new and excited to be working with Linux and to be posting a thread on a forum. Advance thanks for your assistance-

Not used to Grub 2 a lot but it says in big letters at the top of the file you mention DO NOT EDIT. Best possibly to take it at its word if you are new.

It wants you to edit /etc/default/grub instead. It says at the top to then run grub-update or something.

From the sound of it the grub menu is accurate. If you want to get rid of old kernels then uninstall them and then presumably run grub-update or whatever it is called and that will tidy up the Grub menu for you

Vim has all the commands of Vi and then some. It is well worth while to do the tutorial, /usr/share/vim/vim71/tutor/README.txt .

Bratmon 06-06-2010 02:27 PM

Read this:
https://help.ubuntu.com/community/Grub2

brianL 06-06-2010 02:45 PM

Ah, sorry, I was thinking of the old /boot/grub/menu.lst. Ignore my advice.

satwien 06-06-2010 02:46 PM

Quote:

Originally Posted by seamuscristo (Post 3994558)
I am brand new- and sorry to say rather poor at searching the forums for an answer to my first question. Having come up short on a way to clean up my grub menu, I started digging until I found the file "grub.cfg" which appears to list the instances of Linux available for me to boot.

Before I delete lines in the file such as:

}
menuentry "blah blah Ubuntu number.number-22" { ... etc

I want to know if it's ok.
I have updated Ubuntu twice since starting it up, and was surprised to find more options in GRUB each time.

Secondarily, I would like to know which program to use when editing this file (if it is the file I want to edit).
Before switching to Linux I was in the process of learning UNIX for a web company, and Learning to use the VI for my own regex interests. I'm a little sad to find that VIM is not equipped with the same commands (thank god for :q!) and would seek the advice of seasoned users in the matter of editing files.

In case you can't guess, I am extremely new and excited to be working with Linux and to be posting a thread on a forum. Advance thanks for your assistance-

That's not a good idea ... have a look here: http://www.dedoimedo.com/computers/grub-2.html

seamuscristo 06-06-2010 05:20 PM

I'm glad I asked.

Thanks for the links Bratmon and Satwien- they have proven to be very useful.

saikee 06-06-2010 05:29 PM

I normally edit it anyway I want, be it grub.cfg or menu.lst.

If you are nervous just put a # in front of the line you want to disable. Grub2 doesn't need grub.cfg to function and it gives you a Grub prompt if the configuration file is missing or totally trashed. I haven't found an installed OS that cannot be booted by manually by a Grub prompt. grub.cfg contains just the manual commands one would otherwise use manually.

Bratmon 06-06-2010 06:37 PM

Quote:

Originally Posted by saikee (Post 3994748)
I normally edit it anyway I want, be it grub.cfg or menu.lst.

If you are nervous just put a # in front of the line you want to disable. Grub2 doesn't need grub.cfg to function and it gives you a Grub prompt if the configuration file is missing or totally trashed. I haven't found an installed OS that cannot be booted by manually by a Grub prompt. grub.cfg contains just the manual commands one would otherwise use manually.

So you change it manually every time you update your kernel?

RockDoctor 06-06-2010 07:30 PM

What I do instead of changing my grub.conf file is point it at /vmlinuz and /initrd in the root partition of my distro. I manually run a little script that resets /vmlinuz and /initrd to point to the appropriate files in my distro's /boot directory, and sets up links /vmlinuz.old and /initrd.old to point to the old kernel's files. If the new kernel fails to boot, I just manually edit the kernel and initrd lines in grub.conf during the boot process to point to /vmlinuz.old and /initrd.old. Somewhat cumbersome, but it works for me.

chrism01 06-07-2010 01:50 AM

FYI: in some distros eg RHEL derived, menu.lst is a symlink to grub.conf...

brucehinrichs 06-07-2010 01:13 PM

Quote:

FYI: in some distros eg RHEL derived, menu.lst is a symlink to grub.conf...
This is true of sabayon as well.


All times are GMT -5. The time now is 01:59 AM.