PDA

View Full Version : [ubuntu] help wth giving permission to edit grub.cfg



bmesta
February 22nd, 2010, 10:03 PM
Hello,

Im tryin to give permission to modify the grub.cfg by the following command chmod 755 /boot/grub/grub.cfg but unfortunately i get the following error.
chmod: changing permissions of `/boot/grub/grub.cfg': Operation not permitted

How do you fix this? am i executing the wrong command? I just want to be able to modify the text Windows Vista (boot loader) to Windows Vista in the grub.cfg file.

snowpine
February 22nd, 2010, 10:27 PM
No no no! Don't chmod important system files. :)

Assuming gedit is your favorite text editor:


gksu gedit /boot/grub/grub.cfg

HOWEVER, according to the Ubuntu wiki (https://wiki.ubuntu.com/Grub2):


DO NOT EDIT THIS FILE This is the main Grub 2 file. It "replaces" Grub Legacy's /boot/grub/menu.lst. This file contains the Grub menu instructions. Unlike Grub Legacy's menu.lst file, grub.cfg is NOT MEANT TO BE EDITED!!!

So please, please, please read the instructions before messing with any system files. The permission is restricted for a reason. :)

darkod
February 22nd, 2010, 10:52 PM
No no no! Don't chmod important system files. :)

Assuming gedit is your favorite text editor:


gksu gedit /boot/grub/grub.cfgHOWEVER, according to the Ubuntu wiki (https://wiki.ubuntu.com/Grub2):



So please, please, please read the instructions before messing with any system files. The permission is restricted for a reason. :)

Not only that. Any change you make directly in grub.cfg will be gone next time you run update-grub.

For what you want to do, it would be best to simply copy the current entry for windows you have in grub.cfg into the file /etc/grub.d/40_custom and change what you want to change in the title that appears.

Then disable the /etc/grub.d/30_os-prober file so it doesn't use the automatically detected entry for vista and it uses your entry from 40_custom instead.

ajgreeny
February 22nd, 2010, 10:58 PM
It's no longer as simple as it was, and if you edit the grub.cfg file by changing its permissions, it will just cahnge back next time you run update-grub.

Here's how to do it:-

/etc/grub.d/30_os-prober - Changing Windows or Other Detected OS Titles (including Linux)

This file is divided into sections for various types of operating systems. The first section is for Windows (OS), the second Linux (linux), the third OSX (macosx), and finally Hurd (hurd).

Code:
gksu gedit /etc/grub.d/30_os-prober
A. Changing Windows Entries

Changes made via this method are best done to OS or kernels which the user does not expect to change. If the system detects a title change the entry in #3 may no longer be correct.

Original Menu Entry: Microsoft Windows XP Home Edition (on /dev/sda1)

1. Run this command to get the current Grub 2 menu entries:
Code:
sudo cat /boot/grub/grub.cfg | grep "menuentry" | cut -d '"' -f 2
New Format: Whatever (on /dev/sda7)
2. This section appears around line 83 of the file. Replace the section in red with the content in #4.
Code:
for OS in ${OSPROBED} ; do
DEVICE="`echo ${OS} | cut -d ':' -f 1`"
LONGNAME="`echo ${OS} | cut -d ':' -f 2 | tr '^' ' '`"
LABEL="`echo ${OS} | cut -d ':' -f 3 | tr '^' ' '`"
BOOT="`echo ${OS} | cut -d ':' -f 4`"

if [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi
3. Copy the exact title you wish to change (Example: Microsoft Windows XP Home Edition ) and place it between the quotes in the first line below.
4. Enter the desired title between the quotes in the second line below - in this example, "Windows XP" would replace "Enter Desired New Title Here".
Code:
# Original
# if [ -z "${LONGNAME}" ] ; then
# LONGNAME="${LABEL}"
# fi

if [ "${LONGNAME}" = "Enter Exact Title You Just Copied" ] ; then
LONGNAME="Enter Desired New Title Here"
elif [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi
5. Multiple entries can be made in the same section:
Code:
if [ "${LONGNAME}" = "Enter Exact Title You Just Copied" ] ; then
LONGNAME="Enter Desired New Title Here"
elif [ "${LONGNAME}" = "Enter Second Title You Copied" ] ; then
LONGNAME="Enter Desired Second Title Here"
elif [ -z "${LONGNAME}" ] ; then
LONGNAME="${LABEL}"
fi

bmesta
February 23rd, 2010, 04:29 AM
thanks but whats the command that will allow me to modfity grub.cfg and save the changes.. It doesnt matter if the permissions are going to be gone once grub is updated. I forgot the command.

darkod
February 23rd, 2010, 10:13 AM
thanks but whats the command that will allow me to modfity grub.cfg and save the changes.. It doesnt matter if the permissions are going to be gone once grub is updated. I forgot the command.

I don't know the command but just to remind you that it's not the permissions that will be gone, YOUR CHANGES will be gone.
After the next update-grub the title will again be Windows Vista bootloader on .....

grub.cfg is created from the config files and the only way to make the changes permanent is as I said, use a custom made entry for vista and disable the automatic os-prober.

JALINDAR
April 23rd, 2010, 11:04 AM
with the help of the cammand
gksu gedit /boot/grub/grub.cfg

i am able to edit it but when i try to save it. it shows error massge called

could not save the file /boot/grub/grub.cfg
you r trying to save the file on a read-only disk. please check that you typed the location correctly and try again.

how i can save the changes in this file.

Thank you well in advance

coffeecat
April 23rd, 2010, 11:23 AM
how i can save the changes in this file.

If you look at the first three lines of /boot/grub/grub.cfg, it says:


#
# DO NOT EDIT THIS FILE
#That is there for a purpose and this has already been explained in this thread. If you really know what you are doing, you can edit grub.cfg temporarily for a specific reason, but - and I do mean this kindly - if you do not already know how to make it writeable, you do not have the experience to be messing with it.

So - why do you think you need to edit grub.cfg? What problem do you have? Rather than reply here, I suggest you start your own support thread explaining what you are trying to do, and someone will help.

In the meantime, here is a link for your bookmarks:

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