Logo 
Search:

Unix / Linux / Ubuntu Forum

Ask Question   UnAnswered
Home » Forum » Unix / Linux / Ubuntu       RSS Feeds

adding entry on grub 2

  Date: Feb 11    Category: Unix / Linux / Ubuntu    Views: 438
  

I am trying to rename ubtuntu default name on grub. For that purpose, I created
a custom script name "09_custom_1" in directory /etc/grub.d/. The script
contained the following lines:
#!/bin/sh -eecho "Adding My OS, please wait..." >&2cat << EOFmenuentry "My OS"
{set root=(hd0,5)linux /boot/vmlinuzinitrd /boot/initrd.img}EOF

When I reboot my pc, I do see the "My OS" on top of the list, however, when I
select that "My OS", I get an error message saying "grub custom error you need
to load the kernel first". Can anyone please explain the reason for this error
and what can do to resolve this? Just to let you know that my boot and root
partitions are separate, if that helps.

Share: 

 

4 Answers Found

 
Answer #1    Answered On: Feb 11    

Your spacing in that script looks a mess. For example, what
is -eecho supposed to be? i am sure it should be -e echo. is that actuall
as the script is? There should be spaces after EOF (hd0,5) etc.

Past that, I am not going to be of much help. I saw grub2 was still in
beta back when Ubuntu tried to switch me to it back in 9.10. I reinstalled
Grub Legacy and that is still what I use. Much easier to maintain and
deal with, IMO. You should check the grub2 documentation on the Ubuntu
wiki though or other grud2 documentation.

Some things to remember: even if properly configured, the scritp must be
executable, and you must run the update grub command.

 
Answer #2    Answered On: Feb 11    


Spacing from the script got all messed up due to yahoo converting my message
into plain text. Apologies for that. I did execute upgrade-grub command, and
that is the reason (I think) I can see the "My OS" option when pc boots up. Its
just I cant figure out what this error means "grub custom error you need to load
the kernel first".
I can go back to legacy grub, but I thought Grub 2 seems like it will become a
future standard so might as well start learning it.

 
Answer #3    Answered On: Feb 11    


Ok, that makes sense. I believe the error message woulud indicate it
is not finding the kernel at the specified location. That should
probably happen on the "linux" line. there are a couple of
possiblities that seem reasonable to me:

1) you are pointing at the wrong partition. Did you consider grub2
starts naming partitions at hd0,1 instead of as in grub_legacy which
has first as hd0,0?

2) It may not need "/boot" in front of the direction, instead you could try:
linux /vmlinuz root=/dev/sd5
(i am also suggesting specify the root on this line, could do it with
UUID also ala root=UUID=bunch-of-numbers)

sudo blkid -c /dev/null
that command will give you uuids and show what partitions and lables a
booted OS is seeing

3) does it need full path to headers? like
/boot/vmlinuz-2.6.32.-generic? Or does it do that during update-grub
i wonder...

You proabable know as much or more than i do, but I was spacing and
commenting the script over lunch in case the info helped you. It is
always hard to guess experince level. So I was just adding what
little I understood about it to help before I saw your recent message.
Maybe the formatting will make it?? It would be good for me to
learn a little about grub2 one of these days also.

----- script starts below

#!/bin/sh -e

# lines starting with "#" are comments and not part of the code
# the -e flag up there has something to do with ignoring error, as per
"man bash"

# Message below should be shown while running "sudo update-grub"
# ">&2" redirects the echo to your stderr I think (i.e., your monitor)
# honestly, redirection always confuse me
echo "Adding My OS, please wait..." >&2

# This tells the program "cat" to start working and keep
# going until it sees the string "EOF"
cat << EOF

# The uncommented lines below specify what is gettng
# added to the menu

# obviously, the name that shows up in grub is first
menuentry "My OS" {

# Remember grub2 counts partitions starting from 1
# i.e., first is (hd0,1) instead of (hd0,0) as in grub-legacy
# so change the second number accordingly, or use uuid
set root=(hd0,5)

# Would probably be of benifit to try options like
# root=/dev/sdX ro
# to the end of the next line (but relplace the "X" as appropriate
# yours is sd5 if "hd0,5" is correct
linux /vmlinuz root=/dev/sd5 ro
# you could also do "root=UUID=" followed by uuid

# I REALLY THINK THIS OR SIMILAR IS WHAT IS NEEDED:
# linux /boot/vmlinuz-2.6.31-11-generic root=/dev/sd5 ro
# where you replace the numbers and path with the actual location and
name of the file
# but i'm not 100% sure. couldn't hurt though typle "ls" in /boot
and / to check what is available


# note I left out "/boot" above and below and maybe you need to add
# that back in

initrd /initrd.img
# OR:
# /boot/initrd.img-2.6.31-generic
}
EOF

 
Answer #4    Answered On: Feb 11    

I know its quite on old topic now, but I thought that since I found a solution,
I might just confirm it, so it may help in future.
c beck,Your suggestion "/boot/vmlinuz-2.6.32.-generic?" worked. It needed a full
path to the header. I dont understand why though. For future reference, however,
I would recommend that copy grub menuentry contents from the grub.cfg file and
paste into your custom file, and then you can edit your custom file as per your
wishes.
Hope it was useful. And thank you for your sharing your ideas.

 
Didn't find what you were looking for? Find more on adding entry on grub 2 Or get search suggestion and latest updates.




Tagged: