Tiny-Gentoo with Qemu howto


1. prepare

#mkdir tiny-gentoo
#cd tiny-gentoo
#wget http://gentoo.osuosl.org/experimental/x86/embedded/stages/
#wget http://gentoo.osuosl.org/snapshots/portage-20060102.tar.bz2
#tar xjpf stage*.tar.bz2
#cp -L /etc/resolv.conf etc/resolv.conf
#mkdir -p usr/portage
#tar xjf portage-20060102.tar.bz2 -C usr2. chroot to tiny-gentoo#chroot . /bin/bash
#env-update && source /etc/profile

3. Make a minimal gentoo

#ln -snf /usr/portage/profiles/uclibc/x86/2005.1/ /etc/make.profile
#nano /etc/make.conf
#emerge ccache
#emerge -auDN world
(#emerge vanilla-sources)
#cp /etc/skel/.bash_profile /etc/skel/.bashrc /root/

4. Make the real tiny rootfs

#mkdir /rootfs
#mkdir -p /etc/portage
#echo “sys-apps/baselayout-lite -*” >> /etc/portage/package.keywords
#nano /etc/make.conf
#ROOT=/rootfs emerge -av baselayout-lite uclibc busybox

5. Chroot to the new /rootfs

#chroot /rootfs /bin/ash
#addgroup -g 100 users foo
#adduser -h /home/foo -s /bin/ash -G users foo
#exit (–this exit to the last chroot box tiny-gentoo)

6. Modify the fstab file.

#echo “TinyGentoo” > /rootfs/etc/hostname
# echo “/dev/hda / ext3 defaults” >> rootfs/etc/fstab
#chmod 555 /rootfs/proc

7. Emerge the wanted packages into /rootfs

#ROOT=/rootfs emerge -av net-tools udhcp lynx scrollz dropbear screen

8. Now the /rootfs directory now contains your complete system. Clean it and make a tar ball.

# cd /rootfs
# tar -zcf ../rootfs.tgz .
# exit ( — exit to your host linux)

9. Build the disk img file. (write the rootfs to an img file.)

# qemu-img create gentoo.img 64M
# mkfs.ext3 -q gentoo.img
# mount -o loop gentoo.img /mnt/floppy
# tar -zxf rootfs.tgz -C /mnt/floppy
# umount /mnt/floppy

10. Build kernel for Qemu

The Qemu has following devices:

  • i440FX host PCI bridge and PIIX3 PCI to ISA bridge
  • Cirrus CLGD 5446 PCI VGA card or dummy VGA card with Bochs VESA extensions
  • PS/2 mouse and keyboard
  • 2 PCI IDE interfaces with hard disk and CD-ROM support
  • Floppy disk
  • NE2000 PCI network adapters
  • Serial ports
  • Soundblaster 16 card

Just remember to add all the device drivers into kernel, not as modules. And also add ext3 support into the kernel.
Finally we’ll get kernel/arch/i386/boot/bzImage.

11. Boot from Qemu!

# qemu -hda gentoo.img -kernel bzImage -append “root=/dev/hda”


  1. solar said

    This url provides a script which makes an even smaller bootable system. I mainly use it to test a kernels before rebooting my desktop. But is a fine example of just how small you can really make things. Requires busybox/genext2fs

  2. solar said


  3. themoonseeker said

    Hi I follow this tutorial but I’ve got an error that I can’t resolve…

    The system boot and hang at this point :

    VFS : Cannot open root device “hda” or unknown-block(0,0)
    Please append a correct “root=” boot option
    Kernel panic – not syncing : VFS : Unable to mount root fs on unkown-block(0,0)

    Any solution?

    When making the kernel, I choose ext3, ext2 in kernel (not in module)


    And good tutorial!

  4. sleepworm said

    I got the same problem with themoonseeker, any solutions???

  5. opensas said


    could you please provide us a guide on how to configure the kernel for this particular emulated hardware…

    (I’ve posted a question at http://forums.gentoo.org/viewtopic-p-3938392.html#3938392)

    thanks is advance

  6. Browsem said

    Just wanted to mention in “4.4”
    the “#echo “sys-apps/baselayout-lite -*” >> /etc/portage/package.keywords”
    should be
    #echo “sys-apps/baselayout-lite **” >> /etc/portage/package.keywords

    thx for great howto

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: