help-grub
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Building a bootable disc image with grub-mkimage


From: Matthew Bloch
Subject: Building a bootable disc image with grub-mkimage
Date: Thu, 13 Jan 2011 01:06:08 +0000
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hiya,

I'm struggling to build a small bootable hard disc image using
grub-mkimage, which is rather outside the current documentation.  It's
pretty handy that grub is this flexible, but I'm struggling with two
problems.

(I'm using grub-1.98 downloaded from the GNU FTP site last night.)

Here's my script which builds a file 'testhd' based on an already-built
ext3 filesystem image 'root.img'.

- -----8<----------------------------------------------------------------
# reasonable list of modules?
#
MODULES="acpi biosdisk boot cat configfile cpuid datetime drivemap echo
elf ext2 fat fshelp halt hdparm hello help linux loadenv ls msdospart
multiboot normal part_msdos pci probe read reboot scsi search serial
sleep terminal sh usb vga video"

# Start our test image with the MBR
#
cp ./grub-1.98/boot.img testhd

# Write our grub.cfg
#
echo 'set root=(hd0,1)
linux /boot/vmlinuz-2.6.36.2 console=ttyS0,115200
boot' >grub.cfg

# Build the main part of the image, baking in our grub.cfg and
# modules
#
./grub-1.98/grub-mkimage -p grub-1.98 -d grub-1.98 -c grub.cfg \
  $MODULES >>testhd

# Add our filesystem image
#
dd status=noxfer if=root.img of=testhd bs=8225280 seek=1

# Correct the partition table
#
echo '1 - 83 *' | sfdisk -q testhd
- -----8<----------------------------------------------------------------

I can boot this image with:

  kvm -hdc testhd

and it *almost* works - except for two problems:

1) the last command "boot" in my baked-in grub.cfg seems to be ignored.
 grub comes up with a prompt, and I have to type "boot" to make it go.
I know it is reading the rest of the file because it sets the root
device fine, and it knows which kernel to boot.  Also adding hello/sleep
1 has the expected effect, though it's annoying it clears the screen to
show me the prompt, even if there were errors in my script before that.

How do I make it boot automatically, without a prompt?

2) What should I put in the grub.cfg to make it output over COM1 at
115200 baud?  I can find about three different answers and still haven't
got it to work (I've managed to disable the console, but not seen
anything output), so I'd like to know how it ought to work.

Any help appreciated.

- -- 
Matthew
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0uUAAACgkQT2rVDg8aLXTGVACeN6doRRZzNGZesqnJrUSW/zt6
hOUAn3kE3BxlCBtrUdkfB8zatGhqsLQf
=G3Wu
-----END PGP SIGNATURE-----



reply via email to

[Prev in Thread] Current Thread [Next in Thread]