LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux From Scratch (http://www.linuxquestions.org/questions/linux-from-scratch-13/)
-   -   LFS 7.1 First Boot, grub error (http://www.linuxquestions.org/questions/linux-from-scratch-13/lfs-7-1-first-boot-grub-error-4175444890/)

engineer 01-09-2013 09:02 PM

LFS 7.1 First Boot, grub error
 
I just tried booting my LFS system for the first time, and encountered an error when booting. GRUB loads the OS name, but when it comes time to boot, it says "error: file not found".

Below is the grub.cfg file that I created right before I rebooted (my root partition is mounted on /dev/sda3, so I used that, like the book suggested.

Code:

cat > /boot/grub/grub.cfg << "EOF"
# Begin /boot/grub/grub.cfg
set default=0
set timeout=5
insmod ext2
set root=(hd0,2)
menuentry "GNU/Linux, Linux 3.5.2-lfs-7.1" {
        linux  /boot/vmlinuz-3.5.2-lfs-7.1 root=/dev/sda3 ro
}
EOF

What have I missed?

stoat 01-09-2013 09:17 PM

If you have a separate boot partition as the set root command suggests, then you should not include "/boot" in the path of that linux command. On the other hand, if you do not have a separate boot partition, then the set root command should specify (hd0,3).

engineer 01-09-2013 10:07 PM

Is there a way to change the configuration file now that I am not able to boot? What is the meaning of the (hd0,3) option? Why not use the "sda" nomenclature?

stoat 01-09-2013 10:29 PM

Quote:

Originally Posted by engineer

Is there a way to change the configuration file now that I am not able to boot?

In the same terminal you have been working in, open the file /boot/grub/grub.cfg that you just created and fix it one way or the other for the situation. Then save it and move on.

Quote:

Originally Posted by engineer

What is the meaning of the (hd0,3) option?

GRUB uses and understands that (hdX,X) syntax. In GRUB 2, (hd0,3) would indicate the first drive and its third partition (the device name equivalent of /dev/sda3, usually). The set root=(hd0,3) command line indicates to GRUB the location of the boot files. The paths in the subsequent commands, such as the linux command, are relative to it.

Quote:

Originally Posted by engineer

Why not use the "sda" nomenclature?

That /dev/sda3 thing is a device name used by the operating system. GRUB is not using it. The root=/dev/sda3 in the linux command is merely a parameter being passed to the kernel which needs it. As for the pure question of why it is that way, who knows. It's been that way since the beginning of legacy GRUB when we all were throwing rocks and sticks at each other and howling at the moon.

engineer 01-09-2013 10:51 PM

Quote:

Originally Posted by stoat (Post 4866647)
In the same terminal you have been working in, open the file /boot/grub/grub.cfg that you just created and fix it one way or the other for the situation. Then save it and move on.

GRUB uses and understands that (hdX,X) syntax. In GRUB 2, (hd0,3) would indicate the first drive and its third partition (the device name equivalent of /dev/sda3, usually).

That /dev/sda3 thing is a device name used by the operating system. GRUB is not using it. In the grub.cfg file, the root=/dev/sda3 in the linux command is not serving the same purpose as the set root=(hd0,3) command line which GRUB uses to find the boot files. In the linux command, root=/dev/sda3 is merely a parameter being passed to the kernel which needs it. As for the pure question of why it is that way, who knows. It's been like then since the beginning of legacy GRUB when we all were throwing rocks and sticks at each other and howling at the moon.

I would just modify the file, but I'm not able to get to a command prompt, other than the basic grub one. I can't get into the system at the moment. I also think I tried hd0,3 as well as removing the /boot parameter, to no avail. I was able to do that by modifying the line within the basic grub edit window where you select the OS you want to boot.

stoat 01-09-2013 11:20 PM

Quote:

Originally Posted by engineer

I would just modify the file, but I'm not able to get to a command prompt, other than the basic grub one.

If it's still stopping with that "file not found" message, then try having GRUB search for the boot partition with the search command at the boot menu's grub> prompt. Like this...
Code:

grub> search -f /boot/grub/grub.cfg
grub> search -f /grub/grub.cfg

Try both. One should give results that can be used to settle what to put in the set root command (and the root= kernel parameter if they're the same partition). Anyway, edit the lines as you did before, boot, hope. If it boots, then fix the grub.cfg file.

P.S.: The search command that gives results also will be the clue as to whether or not to use "/boot" in the path of the linux command.

stoat 01-09-2013 11:51 PM

Another thing I forgot about is if you find out some partition numbers in the grub.cfg were wrong and fix them, it may boot farther along and stop again if your /etc/fstab also contains partition errors. Anyway, it happens all the time. Be prepared to fix that, too.

Keith Hedger 01-10-2013 10:49 AM

Quote:

Originally Posted by stoat (Post 4866647)
...As for the pure question of why it is that way, who knows. It's been that way since the beginning of legacy GRUB when we all were throwing rocks and sticks at each other and howling at the moon.

LOL! I still use Grub legacy ( I find it easier to set up and reinstall when I inevitably fubar my system )!

spiky0011 01-10-2013 03:16 PM

Hi

What file system did you use to build lfs, did you make it ext3 or ext4?

engineer 01-10-2013 06:42 PM

So I tried this:

Code:

grub> search -f /boot/grub/grub.cfg
And the output was

Code:

grub> hd0 msdos6
I'm having trouble remembering exactly how I setup the partitions, I had originally wrote it down, but then I started over, and changed one or two things... From what I remember, I used the /boot partition that already existed, and created a new Swap partition, / partition, and the lfs partition itself. If memory serves, all (but the swap) were ext3 FS type.

I've tried:

Code:

set root=(hd0,3)
and:

Code:

set root=(hd0,2)
And then tried to boot, but neither of these worked. I also tried modifying the lines with the 'e' for edit command at the GRUB menu, and removing the /boot prefix on the /vmlinuz line. I think I'm not understanding something here when it comes to modifying this file. Thank you for all the help so far.

engineer 01-10-2013 06:50 PM

Quote:

Originally Posted by stoat (Post 4866647)
. As for the pure question of why it is that way, who knows. It's been that way since the beginning of legacy GRUB when we all were throwing rocks and sticks at each other and howling at the moon.

Now, THAT, is funny!

stoat 01-10-2013 10:05 PM

Quote:

Originally Posted by engineer

I'm having trouble remembering exactly how I setup the partitions

Uh, I think that right there is the problem. Anyway the search commands found a single grub.cfg file in the second logical partition of an extended partition. And since the command that produced that result had "/boot" in its path, that is not a separate boot partition but a partition with a directory named "boot" in its filesystem (such as in a root partition). So a reasonable thing to try at the grub> prompt is this...
Code:

grub> linux (hd0,6)/boot/vmlinuz-3.5.2-lfs-7.1 root=/dev/sda6 ro
grub> boot

And see what happens.

If that doesn't at least attempt to boot the LFS system, then boot with a live CD and post some more information to show the partition layout better such as the fdisk output for /dev/sda. I'm wondering where is or what happened to the host system, for example.

P.S.: Some other grub> searches that might help untangle this might be searching specifically for the LFS kernel and the lfs-release file (if you created it)...
Code:

grub> search -f /vmlinuz-3.5.2-lfs-7.1
grub> search -f /boot/vmlinuz-3.5.2-lfs-7.1
grub> search -f /etc/lfs-release

If you find those, then all that is necessary to boot the system will be known with certainty.

engineer 01-12-2013 12:00 PM

Quote:

Originally Posted by stoat (Post 4867456)
Uh, I think that right there is the problem. Anyway the search commands found a single grub.cfg file in the second logical partition of an extended partition. And since the command that produced that result had "/boot" in its path, that is not a separate boot partition but a partition with a directory named "boot" in its filesystem (such as in a root partition). So a reasonable thing to try at the grub> prompt is this...
Code:

grub> linux (hd0,6)/boot/vmlinuz-3.5.2-lfs-7.1 root=/dev/sda6 ro
grub> boot

And see what happens.

If that doesn't at least attempt to boot the LFS system, then boot with a live CD and post some more information to show the partition layout better such as the fdisk output for /dev/sda. I'm wondering where is or what happened to the host system, for example.

P.S.: Some other grub> searches that might help untangle this might be searching specifically for the LFS kernel and the lfs-release file (if you created it)...
Code:

grub> search -f /vmlinuz-3.5.2-lfs-7.1
grub> search -f /boot/vmlinuz-3.5.2-lfs-7.1
grub> search -f /etc/lfs-release

If you find those, then all that is necessary to boot the system will be known with certainty.

Ok, I've tried several permutations of the search command, with no luck beyond the previous output. None of the last three commands you posted yielded any results. Also, in my infinite wisdom, the version is 3.2.6, not 3.5.2 as I erroneously posted above--I did try the searches with the correct information.

Now, this begs the question, where is the original boot file that the base system uses? How can I roll back to that? Also, what does it actually mean when we search for:

Code:

grub> search -f /boot/grub/grub.cfg
and get output:

Code:

grub> hd0 msdos6
??

I'm sorry for my ignorance, but I've never spent any time messing around with GRUB, so I'm really in the dark here.

spiky0011 01-12-2013 12:57 PM

Hi

Can you boot a live cd and post the output of fdisk -l, to see partition layout

engineer 01-12-2013 03:40 PM

Code:

fdisk -l
Code:

  Device Boot      Start        End      Blocks  Id  System
/dev/sda1  *        2048    1026047      512000  83  Linux
/dev/sda2        1026048  154626047    76800000  83  Linux
/dev/sda3      154626048  175106047    10240000  83  Linux
/dev/sda4      175106048  976773119  400833536    5  Extended
/dev/sda5      175110144  185350143    5120000  82  Linux swap / Solaris
/dev/sda6      185352192  292968447    53808128  83  Linux

The LFS system is on /dev/sda6, and the FS type is ext3.


All times are GMT -5. The time now is 05:41 AM.