The findf command
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.
findf filename1 [filename2...]
When specifying the file name include the path. See the example below.
Assume a system with the following hard drives:
- hd0 partition 0: Windows
- hd0 partition 3: Linux
- hd1 partition 0: Linux
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)
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.