3

I just built a Linux kernel on Ubuntu and now I want to make it run on VirtualBox. I wanted it to be in an img format. I created a hard drive image by doing the commands:

$ qemu-img create disk.img 512M
$ mkfs.ext2 -F disk.img

What should I do next?

2
  • img format, you mean "raw" format right? Anyway Vbox supports it.
    – daisy
    Oct 8, 2012 at 23:52
  • Your question looks vague now, were you trying to boot from the disk(that has a boot loader installed already), or use qemu to boot that disk with an external kernel file?
    – daisy
    Oct 10, 2012 at 1:32

2 Answers 2

3

Why are you creating the disk manually?

You should use VirtualBox to create the disk while creating the VM, unless you plan to use it together with qemu. (why?)

Here, when adding disks, use the existing disk that you created.

enter image description here

2
  • All I have done is create the kernel. I want to take the bzImage and put that with a bootloader, and a hard drive image then run that in Virtualbox (or possibly qemu if there is a way to do both).
    – Coder404
    Oct 9, 2012 at 0:48
  • Could you give a step by step process?
    – Coder404
    Oct 9, 2012 at 0:48
3

To run a kernel directly in qemu or kvm, use the -kernel argument:

qemu-system-x86_64 -kernel /boot/vmlinuz-3.2.0-2-amd64

Virtualbox may have something similar.

If you really want it installed on a hard drive image, it's a bit harder. You need a bootloader installed, which may also require a partition table. Something like SYSLINUX or EXTLINUX could be straightforward, or you could just go straight ahead to what most real systems use and install GRUB. For GRUB, the instructions in Linux From Scratch will be helpful, as will the GRUB documentation itself.

6
  • I have tried to boot the kernel by doing the kernel argument. My issue was that I didnt have a hard drive image so it would not boot.
    – Coder404
    Oct 9, 2012 at 11:02
  • That's a very different problem. You can add a hard drive with the -hda option. Your kernel is booting, now you've moved into the realm of what the kernel itself is doing once it boots.
    – Jim Paris
    Oct 9, 2012 at 15:27
  • I know that I can add a hard drive by doing that command. My question is how do I create the image (preferably in img format)??
    – Coder404
    Oct 10, 2012 at 0:46
  • 1
    You already know how to create the image -- you listed the commands to do it. It is unclear what you are asking.
    – Jim Paris
    Oct 10, 2012 at 1:26
  • I want to create an img file that has grub, the linux kernel (bzImage) and I want to be able to run in virtualbox. Thats what I am asking
    – Coder404
    Oct 10, 2012 at 2:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .