Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Mini-HOWTO: QEMU and bare GRUB Boot CD
View unanswered posts
View posts from last 24 hours

Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks
View previous topic :: View next topic  
Author Message

Joined: 26 May 2004
Posts: 28

PostPosted: Thu Oct 28, 2004 7:09 am    Post subject: Mini-HOWTO: QEMU and bare GRUB Boot CD Reply with quote

I started out wanting to emulate windows XP on my Dell Laptop but once I discovered you needed an actual image of the installation lying around for you to use, it kind of took the wind out of my sails. I didn't want a fresh installation of windows, I wanted to use my already-installed version. Oh well.

I started playing around with bootsplashes for GRUB a little while ago and I hated having to reboot every time to check out the results, so devised this method instead to get everything working.

Using qemu and GRUB, we're going to construct an ISO image that basically creates a bootable CDROM with just GRUB installed. Using this, you can create a partition of whatever you want.

I'm going to assume you already installed qemu. If there's enough of a demand, I'll go through the installation steps for qemu but for right now, I'll leave that subject alone.

I'm also going to assume you have grub installed locally at /boot/grub. If you don't, all we're going to need is your grub.conf and a splash image if you want.

Here are the steps:

    Create a directory. The grub documentation calls it "iso", so let's call it that.
    mkdir iso

    Underneath that directory, create a set of subdirectories, boot/grub/

    cd iso
    mkdir boot/grub

    Your iso directory is now your root directory on your new CD. If you want to store any files on the root of the cd, place them here.

    Now, we need to get our boot configuration all set. I'd just copy the /boot/grub/grub.conf.sample file from /boot/grub/ and set it all up the way you like it.

    cp /boot/grub/grub.conf(.sample) iso/boot/grub

    Note that I put ( ) in there in case you're going to use the same grub.conf that you are now. I wasn't, so I made my own custom one.

    Now, you'll also need a map.lst file. This is in the same location as grub.conf usually. Just copy it over and any changes you make to grub.conf, make to map.lst.

     cp /boot/grub/map.lst iso/boot/grub

    I have also gotten the splash to work. This was most important for me. Copy your xpm.gz file into the boot/grub directory:

    cp /path/to/image.xpm.gz iso/boot/grub

    Now, we need the stage2 file, stage2_eltorito, for your grub image. By default, Gentoo installs this file in /lib/grub/i386-pc/. We need to copy that into our grub directory:

    cp /lib/grub/i386-pc/stage2_eltorito iso/boot/grub

    Finally, we're ready to create the ISO image. Run the following command to make it so:

    mkisofs -R -b boot/grub/stage2_eltorito \
    -no-emul-boot -boot-load-size 4 -boot-info-table \
    -o grub.iso iso

    You now have a file called grub.iso that contains a boot image for a CD. You could burn this to CD and it would boot, but you wouldn't get very far without a kernel to start. Now, let's run it in QEMU to get it working:

    qemu -cdrom grub.iso -boot d

    Up pops your nice new grub! With graphics too!

    There you have it! Your splash image should work fine and dandy.

I just kind of threw mine together really quickly because I didn't care about booting, I just wanted to see the image. You can see a screenshot of my results at my website.

References for this project:

Grub Manual - Installing on CDROM
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Documentation, Tips & Tricks All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum