Script:
grub --device-map=/dev/null --no-floppy --no-config-file <<EOF
device (hd0) $RAWDISKIMG
geometry (hd0) DISKSIZE_CYLS 255 63
root (hd0,1)
setup --force-lba (hd0)
EOF
Output:
Attempting to setup GRUB
GNU GRUB version 0.97 (640K lower / 3072K upper memory)
[ Minimal BASH-like line editing is supported. For
the first word, TAB lists possible command
completions. Anywhere else TAB lists the possible
completions of a device/filename. ]
grub> device (hd0) ukvmlx4.rawdisk
grub> geometry (hd0) 2351 255 63
drive 0x80: C/H/S = 2351/255/63, The number of sectors = 37768815, ukvmlx4.rawdisk
Partition num: 0, Filesystem type unknown, partition type 0x82
Partition num: 1, Filesystem type is ext2fs, partition type 0x83
grub> root (hd0,1)
Filesystem type is ext2fs, partition type 0x83
grub> setup --force-lba (hd0)
Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/e2fs_stage1_5" exists... yes
Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... failed (this is not fatal)
Running "embed /boot/grub/e2fs_stage1_5 (hd0,1)"... failed (this is not fatal)
Running "install --force-lba /boot/grub/stage1 (hd0) /boot/grub/stage2 p /boot/grub/menu.lst "... succeeded
Done.
grub>