Drives and partitions: converting from Linux to GRUB naming convention

Dan Nicholson dbn.lists at gmail.com
Mon Aug 14 13:23:07 PDT 2006


On 8/14/06, Angel Tsankov <fn42551 at fmi.uni-sofia.bg> wrote:
> Can someone suggest how to convert (in a shell script) from Linux naming convention for drives and partitions (hdxy) to GRUB naming
> convention ((hdn,m)), taking into account that, in contrast to Linux, GRUB does not consider CD-ROM drives to be hard drives? For
> more information, refer to section 8.4 in the LFS book, version 6.1.1.

Look at the shell script /usr/sbin/grub-install. Or, you can download
the stripped down version I use in my scripts.

http://www.linuxfromscratch.org/~dnicholson/grub-devices.sh

Source that file, then use the convert_grub_device function:

$ convert_grub_device /dev/hda2
(hd0,1)

Careful, though. I use it in scripts, so it will exit from your
session. Maybe you'll want to change the "exit 1" to "return 1".

--
Dan



More information about the lfs-support mailing list