Explanation about grub's search command in chapter 8.4 of lfs book is wrong

linux fan linuxscratch at gmail.com
Tue Jul 6 08:55:17 PDT 2010


A possible search usefulness:
Or, other search methods to deduce the root filesystem for the
kernel's "root=" parameter, or where the kernel is.

* Suppose that the grub directory is a subdirectory of boot
* Suppose that the boot directory is a subdirectory of root /
* Suppose that the kernel name is vmlinux-2.6.33 and it is located in boot
* This search command will find which (grub syntax) partitions contain
that file:
 search -n -f /boot/vmlinux-2.6.33
* The result may show a list if it exist on multiple partitions as:
(hd2,9) (hd4,10)
* You may be clever and deduce that (hd4,10) is what you want.
* You may find out which (kernel syntax) that drive is with:
 cat (hd4,10)/boot/grub/device.map
* Cat may return information such as:
(fd0)   /dev/fd0
(hd0)   /dev/hda
(hd1)   /dev/sda
(hd2)   /dev/sdb
(hd3)   /dev/sdc
(hd4)   /dev/sdd
* It can then be deduced that the (kernel syntax) root partition is:
* So the linux line can have the parameter:
* The full linux line can then be:
  linux (hd4,10)/boot/vmlinux-2.6.33 root=/dev/sdd10
* boot

* If boot is on a separate partition, omit the "/boot" component when
searching for the partition that holds the kernel.
* If boot is on a separate partition, you might also search for a
distinct filename, that is known to be on the system's root /
filesystem, in order to determine the "root=" parameter. At least it
can narrow down the choices.

This can be useful when struggling to boot from the grub2 command line
while struggling to producing a working grub.cfg. I have struggled
many times and I always appreciate the existence of a tool that can
help sort things out. Search is not limited to searching for UUID.

What I might be trying to say is that grub2 has a command that can
operate like the grub legacy command "find" and the name of that
command is "search".

To find what partition(s) a filename exist on, the search command is useful:
  search -n -f filename

In long-param-notation that is:
  search --no-floppy --file=filename

Thus it is technically incorrect to imply that "[ ... the search ...]
command only sets an internal GRUB variable used to find the kernel

It might be more precise to say something like:
* The above search lines set the GRUB variable "root" by searching
--fs-uuid, which is not considered standard practice for LFS systems.
The above set root commands are sufficient to establish the GRUB
variable "root".

Just reporting the discovery.
But, whatever you think.

More information about the lfs-dev mailing list