LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 03-13-2010, 06:58 AM   #1
Breagha
LQ Newbie
 
Registered: Mar 2010
Posts: 7

Rep: Reputation: 0
Grub can't find grub.cfg when booting - error: no such device


When I boot I briefly see 'Grub loading...' then I get dumped in 'sh:grub>'.

I can then boot up manually:

linux (hd0,1)/vmlinuz root=/dev/sda1
initrd (hd0,1)/initrd.img
boot


I'm very new at this, so all my attempts at correcting it has been through reading posts turned up by google searches.

Previously, I was dumped at the grub_rescue> prompt (have another thread about that, but I think this is a new issue, so I'm hoping making a new thread won't bring any mod's wrath down on my head), but that seemed to solve itself through no influence of mine...


What I've tried to solve the 'sh:grub>' issue:

In /etc/default/grub:
I tried disabling quiet splash, in hopes there would be some lines that would give me a clue as to what is going on, but it jumps directly from Grub loading to sh:grub>

I tried commenting out Grub_Hidden_Timeout and setting it to a positive integer

I tried uncommenting GRUB_DISABLE_LINUX_UUID=true


In /etc/grub.d/10_linux:
I tried commenting out 'if [ -n \${have_grubenv} ]; then save_env recordfail; fi'


Then I tried typing 'search -f /boot/grub/grub.cfg' at the sh:grub> prompt and got 'error: no such device: /boot/grub/grub.cfg' which I guess meant all my previous attempts were void as grub couldn't even find grub.cfg


I've tried to reinstall grub with 'grub-install --recheck /dev/sda'.

Then I found this thread and tried out "grub-setup -r '(hd0,1)' /dev/sda", hoping it would point to my grub.cfg as well. No such luck.


I'm pretty much in over my head here, and I don't know what to do. Any help would be very much appreciated.

Last edited by Breagha; 03-14-2010 at 01:01 PM.
 
Old 03-13-2010, 08:58 AM   #2
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
Can you give us a general idea of what your file system layout was like? For example mine I always make a boot partition first /boot = /dev/sda1. This may help us first.

When you boot up manually can you post what your menu.lst file shows?
 
Old 03-13-2010, 09:59 AM   #3
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
When you boot up manually can you post what your menu.lst file shows?
He is using grub2 (grub1.97-beta) and the equivalent file is /boot/grub/grub.cfg
Quote:
In /etc/default/grub:
I tried disabling quiet splash, in hopes there would be some lines that would give me a clue as to what is going on, but it jumps directly from Grub loading to sh:grub>
Those entries affect what you see when the kernel boots, not grub. Make sure you have not accidentally introduced a trailing space on any of the lines in /etc/default/grub (see below).

Quote:
In /etc/grub.d/10_linux:
I tried commenting out 'if [ -n \${have_grubenv} ]; then save_env recordfail; fi'
Please put that back as it was.
Please be aware that any trailing spaces on any of the lines in any of the scripts in /etc/grub.d/ will cause grub2 to fail, silently, with no error message, and grub.cfg will not be updated.

Once you have done all that, please do sudo update-grub

Now check the date/time on grub.cfg - Was it updated? If not re-check the scripts in /etc/grub.d/ for spaces and syntax. Once you have been able to update grub.cfg then
Reboot
If it still doesn't work, please post your /boot/grub/grub.cfg file.

I expect you have seen this: http://www.dedoimedo.com/computers/grub-2.html

I hate grub2
 
Old 03-13-2010, 10:07 AM   #4
jstephens84
Senior Member
 
Registered: Sep 2004
Distribution: (Home)Opensolaris, Ubuntu, CentOS, (Work - AIX, HP-UX, Red Hat)
Posts: 2,056

Rep: Reputation: 94
Quote:
Originally Posted by tredegar View Post
He is using grub2 (grub1.97-beta) and the equivalent file is /boot/grub/grub.cfg

Those entries affect what you see when the kernel boots, not grub. Make sure you have not accidentally introduced a trailing space on any of the lines in /etc/default/grub (see below).


Please put that back as it was.
Please be aware that any trailing spaces on any of the lines in any of the scripts in /etc/grub.d/ will cause grub2 to fail, silently, with no error message, and grub.cfg will not be updated.

Once you have done all that, please do sudo update-grub

Now check the date/time on grub.cfg - Was it updated? If not re-check the scripts in /etc/grub.d/ for spaces and syntax. Once you have been able to update grub.cfg then
Reboot
If it still doesn't work, please post your /boot/grub/grub.cfg file.

I expect you have seen this: http://www.dedoimedo.com/computers/grub-2.html

I hate grub2
Hmmm.... I did not know that. Looks like I need to check out grub2. Thanks for the Info.
 
Old 03-13-2010, 10:36 AM   #5
Breagha
LQ Newbie
 
Registered: Mar 2010
Posts: 7

Original Poster
Rep: Reputation: 0
I'm sorry, I should have said it was Grub2

I put everything back the way they were when they didn't work.

Checked the files, and I can't find any trailing spaces. That is, if trailing spaces are at the end of a line? I didn't check at the beginning. Will space instead of tab make a difference? Should I go over them again?

My grub.cfg updated as it should - and according to the time stamp, did so previously as well - when I ran update-grub. No change on boot, though

My grub.cfg file:

Code:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
  have_grubenv=true
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  saved_entry=${prev_saved_entry}
  save_env saved_entry
  prev_saved_entry=
  save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,1)
search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=-1
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/white
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-20-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	set quiet=1
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-20-generic root=UUID=0a8f45e2-ab04-4d60-a1a5-33754e25d9ce ro   
	initrd	/boot/initrd.img-2.6.31-20-generic
}
menuentry "Ubuntu, Linux 2.6.31-20-generic (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-20-generic root=UUID=0a8f45e2-ab04-4d60-a1a5-33754e25d9ce ro single 
	initrd	/boot/initrd.img-2.6.31-20-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	set quiet=1
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-14-generic root=UUID=0a8f45e2-ab04-4d60-a1a5-33754e25d9ce ro   
	initrd	/boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-14-generic root=UUID=0a8f45e2-ab04-4d60-a1a5-33754e25d9ce ro single 
	initrd	/boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	linux16	/boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	linux16	/boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### 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 ###

Oh... and I'm a she...
 
Old 03-14-2010, 01:20 AM   #6
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
If your grub.cfg is being updated, the scripts in /etc/grub.d/ have to be OK.

Yes, "trailing spaces" are spaces at the end of a line, after the last printable character.

Your grub.cfg looks OK, but obviously isn't working.

Try sudo grub-install /dev/sda

Any errors reported?
If not, try a reboot now.

If that fails, here are some things to think about:

1]
grub.cfg is referring to disk partitions by UUID, you should check these are correct (as root) with
fdisk -l
and
vol_id --uuid /dev/sda1

If they are not right, (or even if they are) you could try setting grub's default not to use UUIDs by editing /etc/default/grub and uncommenting GRUB_DISABLE_LINUX_UUID=true
Then re-run update-grub
Your grub.cfg should now refer to your root partition as root=/dev/sda1 and not root=UUID=...

2]
Check the /boot/grub/device.map file. Yours should probably look like this:

(hd0) /dev/sda

[I am guessing that you just have one HDD with root and swap partitions, if not please post the output of fdisk -l and tell us what the partitions are.]

If all this fails, there's a HOWTO for re-installing grub2 in the link I gave you in post #3
But I'd prefer we found and fixed the problem rather than blindly reinstalled grub.

Quote:
Oh... and I'm a she...
Sorry

Good luck, please let us know how you get on.
 
1 members found this post helpful.
Old 03-14-2010, 07:09 AM   #7
Breagha
LQ Newbie
 
Registered: Mar 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Yay! 'sudo grub-install /dev/sda' did the trick! Now I get the grub menu ^^

Ofcourse, when I click one of the entries, I just get 'press any key to continue' >.<

If it's not one thing, it's another <.<

My current grub.cfg (I disabled UUID):
Code:
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by /usr/sbin/grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s /boot/grub/grubenv ]; then
  have_grubenv=true
  load_env
fi
set default="0"
if [ ${prev_saved_entry} ]; then
  saved_entry=${prev_saved_entry}
  save_env saved_entry
  prev_saved_entry=
  save_env prev_saved_entry
fi
insmod ext2
set root=(hd0,1)
search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
if loadfont /usr/share/grub/unicode.pf2 ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  if terminal_output gfxterm ; then true ; else
    # For backward compatibility with versions of terminal.mod that don't
    # understand terminal_output
    terminal gfxterm
  fi
fi
if [ ${recordfail} = 1 ]; then
  set timeout=-1
else
  set timeout=-1
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/white
### END /etc/grub.d/05_debian_theme ###

### BEGIN /etc/grub.d/10_linux ###
menuentry "Ubuntu, Linux 2.6.31-20-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	set quiet=1
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-20-generic root=/dev/sda1 ro   
	initrd	/boot/initrd.img-2.6.31-20-generic
}
menuentry "Ubuntu, Linux 2.6.31-20-generic (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-20-generic root=/dev/sda1 ro single 
	initrd	/boot/initrd.img-2.6.31-20-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	set quiet=1
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-14-generic root=/dev/sda1 ro   
	initrd	/boot/initrd.img-2.6.31-14-generic
}
menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" {
        recordfail=1
        if [ -n ${have_grubenv} ]; then save_env recordfail; fi
	insmod ext2
	set root=(hd0,1)
	search --no-floppy --fs-uuid --set 0a8f45e2-ab04-4d60-a1a5-33754e25d9ce
	linux	/boot/vmlinuz-2.6.31-14-generic root=/dev/sda1 ro single 
	initrd	/boot/initrd.img-2.6.31-14-generic
}
### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###
menuentry "Memory test (memtest86+)" {
	linux16	/boot/memtest86+.bin
}
menuentry "Memory test (memtest86+, serial console 115200)" {
	linux16	/boot/memtest86+.bin console=ttyS0,115200n8
}
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### 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 ###
When I hit e to edit the start up commands, it'll start up when I delete the search line. How do I ask it to not do a search? Or to search for the right things... It still seems to be searching for the UUID.


Oh... and... should I start panicking if fdisk -l returns nothing?
vol_id returns 'command not found' (I'm on Ubuntu 64-bit... Another thing I forgot to tell... Not making it easy, am I? )

The contents of my device.map is:
(hd0) /dev/sda
(hd1) /dev/sdb

And while fdisk -l didn't return anything, I checked the contents of my /dev folder, and all my disks and partitions are there:

sda, sda 1 (linux), sda 2 (I don't remember off the top of my head), sda 5 (swap)
sdb, sdb1 (my files and random stuff), sdb2 (a failed Windows installation from before Ubuntu)
 
Old 03-14-2010, 09:50 AM   #8
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,017

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Yay! 'sudo grub-install /dev/sda' did the trick!
At least it boots properly now.

Quote:
My current grub.cfg (I disabled UUID)
Looks fine. I don't like UUID either, but it is helpful if you move your disks around, because if you refer to them as /dev/sda1 they might end up being /dev/sdc1 and therefore become "lost".
It's up to you.

Quote:
Ofcourse, when I click one of the entries, I just get 'press any key to continue'
Grub doesn't use the mouse. The mouse can only work when the kernel is loaded, and grub hasn't done that yet. So use the arrow keys on your keyboard, then press Enter to boot the selected entry.
Quote:
When I hit e to edit the start up commands, it'll start up when I delete the search line. How do I ask it to not do a search? Or to search for the right things... It still seems to be searching for the UUID.
You need to explain this better. I reverted to "grub legacy" where I just press 'e' to edit the highlighted choice, then cursor up/down to select the line to edit, then 'e' again to edit that line, and so on.

Quote:
Oh... and... should I start panicking if fdisk -l returns nothing?
vol_id returns 'command not found'
Both fdisk and vol_id need to be run as root.

Your device.map looks fine.

Last edited by tredegar; 03-14-2010 at 09:54 AM. Reason: Pasting went horribly wrong!, Fixed now, I think.
 
Old 03-14-2010, 12:40 PM   #9
Breagha
LQ Newbie
 
Registered: Mar 2010
Posts: 7

Original Poster
Rep: Reputation: 0
Yeah, not click, pick any entries... just getting my methods mixed up :P

Anyways, thanks a lot of all your help, I think I can maybe figure it out now... possibly...
 
  


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
grub-probe: error: cannot find a device for /. (in chroot) luxianos Linux - Software 5 02-21-2013 03:46 AM
[SOLVED] How does Grub2 find the grub.cfg file? LenW Linux - Software 8 03-15-2010 03:28 AM
Grub, device string replaced with 32 digit hexadecimal number. Caused Grub "error 11" VipX1 Linux - Newbie 3 10-19-2009 05:27 PM
Booting my new ubuntu install = "GRUB GRUB GRUB GRUB GRUB" etc. dissolved soul Ubuntu 2 01-13-2007 12:55 PM
UL 1.0 GRUB: could not find device for /boot: not found or not a block device cma Linux - General 4 12-12-2005 03:35 AM


All times are GMT -5. The time now is 11:51 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration