QEMU not booting my image


 
Thread Tools Search this Thread
Special Forums Hardware Filesystems, Disks and Memory QEMU not booting my image
# 15  
Old 01-04-2011
There's so many fiddly things in any boot process that it's best to start from a working example than build your own from scratch, I think. When your own goes wrong, it can't tell you why. When modifying an existing one, you can keep making changes until you do something that breaks it, then undo what you did and learn.

I'm making a script that builds one out of files I borrowed from a gentoo disk, with some basic files to boot into. when it works I'll tar it up and upload somewhere.
# 16  
Old 01-04-2011
Here is a basic script which builds a small image with just GRUB Legacy on it and uses QEMU to test if the image boots. It is for Fedora 14 X64. All you need to do is change GRUBFILEDIR to point to the directory containing your GRUB stage{1,2} files.
Code:
#!/bin/bash
#
#  Create a bootable image containing just Legacy Grub
#  and use QEMU to test boot it if requested
#

if (( $(id -u) != 0 ))
then
    echo "ERROR: This script must be run as root" 1>&2
    exit 1
fi

GRUBFILEDIR=/usr/share/grub/x86_64-redhat
IMAGE=myimage
LOOPDEV=$(/sbin/losetup -f)

dd if=/dev/zero of=${IMAGE}.img bs=512 count=2880

if [[ -d ${IMAGE} ]]
then
    rm -rf ${IMAGE}
fi
mkdir -p ${IMAGE}/boot/grub

cp ${GRUBFILEDIR}/stage1 ${IMAGE}/boot/grub
cp ${GRUBFILEDIR}/stage2 ${IMAGE}/boot/grub

/sbin/losetup ${LOOPDEV} ${IMAGE}.img
/sbin/mke2fs ${LOOPDEV}
mount ${LOOPDEV} -o loop /mnt
chmod 777 /mnt
cp -aR ${IMAGE}/* /mnt
umount /mnt
cat <<EOF | /sbin/grub --batch --device-map=/dev/null
device (fd0) ${LOOPDEV}
root (fd0)
setup (fd0)
quit
EOF

/sbin/losetup -d ${LOOPDEV}

read -n1 -p "Use QEMU to boot the image (Y/N) "
echo
if [[ $REPLY = [yY] ]]
then
    qemu  -fda ${IMAGE}.img
fi

exit 0

You can easily extend it to include a kernel and other binaries.
# 17  
Old 01-04-2011
He could have done that with my disk image too but refused to try it... Not like a modern, 4-meg linux kernel will fit on a 1.44 floppy either.

Last edited by Corona688; 01-04-2011 at 05:12 PM..
# 18  
Old 01-04-2011
Hey I never refused I said I'd appreciate it, I even uploaded the files to be included in the image. I said I wanted to know because, it's always good to know how to fish, if you know what I mean.
# 19  
Old 01-04-2011
Quote:
Originally Posted by neur0n
Hey I never refused I said I'd appreciate it
I meant the basic grub image that couldn't contain files. Right now we don't even know if you're running qemu correctly Smilie

I'm uploading an image maker thing.

---------- Post updated at 04:05 PM ---------- Previous update was at 03:55 PM ----------

http://burningsmell.org/mkisoboot.tar.gz

You have to extract it as root since it contains device files, so be careful not to extract it anywhere insane. tar -zxf ./mkisoboot.tar.gz

Once extracted you can just run ./mkisoboot.sh (this does not need to be done as root) and it will go through all the steps of turning the stuff in initramfs/ into linux's root ramdisk, then everything in cdimage/ into boot.iso, which I burned and booted on my end. It boots memtest86 by default, but if you enter 'linux' instead it will boot to the ramdisk.

It contains the following stuff:

Code:
cdimage/
        stuff that will appear in the raw CD image -- all bootloader stuff.

cdimage/isolinux/
        dump kernels, initrds, menus, etc. into here, so isolinux can find them.

cdimage/isolinux/vmlinuz
        A 32-bit x86 linux kernel copied from one of my systems.  It probably
        runs better on AMD than Intel, substitute with one of your choice.

cdimage/isolinux/memtest86
        just another example kernel.

initramfs/
        stuff that will appear in root when Linux boots.  Dump your own stuff
        in here.  Replace initramfs/init with a script of your choosing to make it
        boot your init script instead of mine.

        I put busybox, nano, and bash in it, all compiled to run safely on
        most 32-bit processors.  I didn't put anything kernel-specific
        in it, so it shouldn't puke when you replace vmlinuz with a kernel
        better suited to you.

mkisoboot.sh
        turns initramfs/ into cdimage/isolinux/init.gz, then turns cdimage/ into
        boot.iso.

clean.sh
        removes boot.iso and cdimage/isolinux/init.gz


Last edited by Corona688; 01-04-2011 at 06:11 PM..
# 20  
Old 01-04-2011
OK, I'm kinda new to all this stuff and, I'm not quite sure I could "fill" all these requirements. My entire project at this point just consists of four modules. It's basically an L4 microkernel test run, sorry if I gave the idea that it was a Linux kernel.
# 21  
Old 01-04-2011
Quote:
Originally Posted by neur0n
It's basically an L4 microkernel test run.
wat

---------- Post updated at 04:50 PM ---------- Previous update was at 04:35 PM ----------

Quote:
Originally Posted by Corona688
How about you tell us what your ultimate goal is, not just what your problem of the millisecond is, so we can guide you in the right direction now instead of when we finally find out where you're trying to go.
Now do you see what I mean? Smilie

If it can fit on a floppy, maybe fpmurphy's way will work.

Last edited by Corona688; 01-04-2011 at 06:49 PM..
Login or Register to Ask a Question

Previous Thread | Next Thread

8 More Discussions You Might Find Interesting

1. BSD

How to install Ultrix 4.2 on Qemu?

Hi Problem changed. I've got a message showing on the screen which says Guest has not initialized the display (yet) Any how I can fix this? Thanks Jack (4 Replies)
Discussion started by: lucky7456969
4 Replies

2. Virtualization and Cloud Computing

QEMU performance?

Heyas So, i like doing custom a LiveImage of my OS. Using Redhats kickstart/livecd-creator method. Anyway, so i would like to test the liveimages... AND also, i WOULD like to install FreeBSD, Solaris, or whatever, onto a Virtual Machine. I used to use Oracles Virtualbox, but eversince... (3 Replies)
Discussion started by: sea
3 Replies

3. IP Networking

Create a Bridge for Qemu using only loopback

hello networking folks, i have 3 virtual machines that need to talk to each other How can i create a bridge to loopback ? -net tap,vlan=0,ifname=tap1 where tap1 is connected to lo:1 , tap2 is connected to lo:2 etc thx (0 Replies)
Discussion started by: TwiceDone
0 Replies

4. Shell Programming and Scripting

matching image files to create one image

Hi, I have two sets of image files. Both sets have names A to Z but set 1 ends with .cdt.png and set 2 ends with .matrix.png. I want set 1 to match with set 2 if the names match (i.e. A.cdt.png will match with A.matrix.png) and with the convert image tool (program for images), it will merge the... (6 Replies)
Discussion started by: kylle345
6 Replies

5. Solaris

Dual Booting - Solaris image CD doesn't read in BIOS

I am trying to install solaris 10-x86 as second OS on top of Windows XP. I have downloaded iso image from Oracle website and burned into bootable cd. when I loaded into CD-drive and made changes in BIOS to boot from CD. Its not reading from CD drive. After restarting the system with CD(solaris... (8 Replies)
Discussion started by: SunSolars_admin
8 Replies

6. Programming

Qemu + gdb

Hi, I got: host machine: RedHat (RHEL6) virtual machine: RedHat (RHEL6) I run (on host machine): qemu-system-x86_64 ...... -S -s after that i run (on host machine): gdb target remote localhost:1234 set architecture i386:x86-64 and then i can use (on host machine) 'ctrl + c' to... (2 Replies)
Discussion started by: Chrisdot
2 Replies

7. UNIX for Dummies Questions & Answers

Anyone ever used qemu and networked it ?

hi i got a virtual linux machine running on qemu my problem is connecting it to the internet im a bit confused weather i have to make a virtual network card in qemu and than tun tap it? can anyone thats done it before help me out? (1 Reply)
Discussion started by: russian460
1 Replies

8. UNIX for Advanced & Expert Users

Create an Ignite image on tape from Online IgniteUX image

Hi, (HP-UX 11.11) I need to create a tape image of an igniteUX image created on our igniteUX server. That is to say. I have a "Online" image of the igniteUX of the targeted system but I now need to copy it to a useable TAPE (igniteUX) image so i can build an other server from it that is not... (3 Replies)
Discussion started by: Andrek
3 Replies
Login or Register to Ask a Question