SGD findf

From Super Grub Disk Wiki
Jump to: navigation, search

The findf command

Contents

Purpose

This command can be used to determine which drive and partition a file is located on.

The result is stored in the variable out_device, which can be used by subsequent commands.

The find command stops after the first match is found.

Usage

findf filename1 [filename2...]

When specifying the file name include the path. See the example below.

Example

Assume a system with the following hard drives:

  • hd0 partition 0: Windows
  • hd0 partition 3: Linux
  • hd1 partition 0: Linux


The command

findf /boot/grub/menu.lst /boot/menu.lst

will search the hard drives and when finding the /boot/grub/menu.lst on hd0,3 will set the out_device accordingly.

The result can be examined as follows:

echo $(out_device)
(hd0,3)

Technical details

Not only out_device is being set. These other variables are also set:


Problems that can be solved with this option

The findf command can be used to determine the drive designation of a USB drive programatically at runtime. See Samples of custom Boot Scripts for a working example on how to create a boot CD, which will determine the location of the USB drive automatically and boot the linux located on the drive.