Software Projects

Gentoo x86 Linux Installation on a VirtualBox Image

Posted in Uncategorized by rmt on March 14, 2011

UPDATE: now has a one-page “quick install guide” that covers the Gentoo installation.
(Adapted from: This is a work in progress.)

Download VirtualBox. Get the appropriate version–your computer’s current operating system is the host OS for Virtualbox.

Download the ISO minimal installer for Gentoo x86 from this directory, getting the file install-x86-minimal-xxxxxxxx.iso:

Start the Virtualbox image, and select the ISO file as the installation media

Set up networking, choosing wired or wireless according to on your own computer’s network setup:

net-setup eth0

Test networking:


Create the boot partition:

fdisk /dev/sda

Create the swap partition:


Create the root partition:


Apply the ext2 filesystem to the boot partition:

mke2fs /dev/sda1

Apply the ext3 filesystem to the root partition:

mke2fs -j /dev/sda3

Create a swap signature and activate the swap partition:

mkswap /dev/sda2
swapon /dev/sda2

Mount the partitions:

mount /dev/sda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/sda1 /mnt/gentoo/boot

Check the date:


Download and unpack the latest stage 3 tarball at the Gentoo mountpoint, getting the file stage3-i686-xxxxxxxx.tar.bz2:

cd /mnt/gentoo
tar xvjpf stage3-*.tar.bz2

Download portage from a mirror and install:

tar xvjf portage-latest.tar.bz2 -C /mnt/gentoo/usr

Don’t reconfigure any compile options

Choose a mirror for Gentoo base system installation

mirrorselect -i -o >> /mnt/gentoo/etc/make.conf

Copy DNS config

cp -L /etc/resolv.conf /mnt/gentoo/etc/

Mount filesystems for installation:

mount -t proc none /mnt/gentoo/proc
mount --rbind /dev /mnt/gentoo/dev

Change from installation CD to installation system

chroot /mnt/gentoo /bin/bash
source /etc/profile
export PS1="(chroot) $PS1"

Update system

emerge --sync

Choose the eselect profile for “desktop/gnome”:

eselect profile list
eselect profile set 3

Update make.conf:

nano -w /etc/make.conf

Change variables in make.conf:

USE="firefox gnome gtk icu kdrive python sqlite -qt4 threads"

Set your locale by uncommenting the two en_US entries and doing locale-gen

nano -w /etc/locale.gen

Set the time zone

cp /usr/share/zoneinfo/America/Los_Angeles /etc/localtime

Install a kernel source

emerge gentoo-sources

Automatically configure and compile kernel source

emerge genkernel
zcat /proc/config.gz > /usr/share/genkernel/arch/x86/kernel-config
genkernel all


Don’t auto-load any kernel modules

Configure filesystem information

nano -w /etc/fstab

Insert these lines into fstab:

/dev/sda1   /boot        ext2    defaults,noatime     1 2
/dev/sda2   none         swap    sw                   0 0
/dev/sda3   /            ext3    noatime              0 1
/dev/cdrom  /mnt/cdrom   auto    noauto,user          0 0

proc        /proc        proc    defaults             0 0
shm         /dev/shm     tmpfs   nodev,nosuid,noexec  0 0

Set computer name

nano -w /etc/conf.d/hostname



Set the domain and DHCP:

nano -w /etc/conf.d/net


config_eth0=( "dhcp" )

Set to automatically start networking at boot

ln -s /etc/init.d/net.lo /etc/init.d/net.eth0

rc-update add net.eth0 default

Set up the hosts file

nano -w /etc/hosts

Insert: mycomputername localhost

Set the root password


Don’t edit /etc/rc.conf
Don’t edit /etc/conf.d/keymaps

Set clock options (set CLOCK to “UTC” for dual boot with Windows, non-Virtualbox)

nano -w /etc/conf.d/hwclock



Install system logger

emerge syslog-ng


Add system logger to update list:

rc-update add syslog-ng default

Install cron daemon

emerge vixie-cron
rc-update add vixie-cron default

Install file indexing

emerge mlocate

Install DHCP client

emerge dhcpcd

Install bootloader and configure

emerge grub
nano -w /boot/grub/grub.conf


default 0
timeout 30

title Gentoo Linux 2.6.36-r5
root (hd0,0)
kernel /boot/kernel-genkernel-x86-2.6.36-gentoo-r5 root=/dev/ram0 init=/linuxrc ramdisk=8192 real_root=/dev/sda3
initrd /boot/initramfs-genkernel-x86-2.6.36-gentoo-r5

## Only in case you want to dual-boot
#title Windows XP
#rootnoverify (hd0,5)
#chainloader +1

grep -v rootfs /proc/mounts > /etc/mtab
grub-install --no-floppy /dev/sda

Unmount the partitions:

umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo

Shut down the system:

shutdown -h now

On VirtualBox, remove the installation disk from virtual drive, or change the boot order so you don’t boot from the installation CD.

Add a user: restart the VirtualBox image, log in as root and do:

useradd -m -G users,wheel,audio -s /bin/bash newusername
passwd newusername

Update applications and dependencies

emerge --sync

Remove stage 3 tarball and Portage snapshot

rm /stage3-*.tar.bz2*
rm /portage-latest.tar.bz2*

Install vi:

emerge vim

Update make.conf:

nano -w /etc/make.conf

Set variables in make.conf:

USE="firefox gnome gtk icu kdrive python sqlite -qt4 threads"


Attempt to add video drivers:

emerge --config nvidia-drivers

Install VirtualBox Guest Additions:

emerge virtualbox-guest-additions

Install GNOME:

emerge gnome


Configure settings for GNOME:

/etc/init.d/dbus start

rc-update add dbus default

echo "exec gnome-session" > ~/.xinitrc

sed -i '1i\export XDG_MENU_PREFIX=gnome-' ~/.xinitrc


Exit GDM

rc-update add xdm default

Add to /etc/conf.d/xdm:


Install Chromium:

export ACCEPT_KEYWORDS="~x86"

emerge -av www-client/chromium



Clone the VirtualBox VM for backup purposes.


12 Responses

Subscribe to comments with RSS.

  1. C. Gebert said, on October 19, 2011 at 10:17 AM

    /etc/conf.d/clock should be /etc/conf.d/hwclock

    You need to add the eth0 to the default runlevel before you restart
    # cd /etc/init.d
    # ln -s net.lo net.eth0
    # rc-update add net.eth0 default

    • rmt said, on February 27, 2012 at 7:28 PM

      Thanks. I’ve incorporated your corrections into the instructions.

  2. mattdinky said, on February 27, 2012 at 5:51 PM

    Hi and thanks for the tutorial. What made you add instructions for Chromium at the end when you specified firefox earlier in the article? Just curious.


    • rmt said, on February 27, 2012 at 7:30 PM

      You’re welcome–glad you find it helpful. Specifying Firefox and then Chromium was just an oversight, but I liked using Chromium because at the time I wrote these instructions it had bookmark syncing and Firefox didn’t.

  3. simon said, on June 27, 2012 at 11:24 AM

    hi rmt!! Thanx a lot for your useful guide! I found it very complete, only one problem that i can’t fix… i’ve the famous grub error 15: File not found
    But this time and in this case i can’t fix it… i can’t see my error, so can you suggest me something?? i’ve installed on virtualbox… this is my error:
    root (hd0,0)
    Filesystem type is ext2fs, partition type 0x83
    kernel /boot/kernel-genkernel-x86-2.6.24-gentoo-r5 root=/dev/ram0 init=/linuxrc real_root=/dev/sda3

    and grub.conf
    kernel /boot/kernel-genkernel-x86-2.6.24-gentoo-r5 root=/dev/ram0 init=/linuxrc real_root=/dev/sda3
    initrd /boot/initramfs-genkernel-x86-2.6.24-gentoo-r5

    this is not my first time error 15, i fix it everytime but not now… why?!?!? where is my error??
    thanx and sorry me for my bad english!

  4. simon said, on June 27, 2012 at 11:47 AM

    wow! thanks for fast reply! now i’ll try it!

  5. danny said, on March 30, 2013 at 2:36 AM

    Guida perfetta! complimenti ! tanks a lot !

  6. Prlm said, on October 24, 2013 at 8:57 AM

    I had to “emerge unzip” before I did “emerge grub”, because grub comes on zip. Using install-amd64-minimal-20131010.iso. Thanks for the great guide!

  7. Jonny Quest said, on January 10, 2014 at 11:15 AM

    Very helpful description. Thank you! I just want to point out that Virtual Box is able to take snapshots. DO THIS befor the first restart. I helps if grub was not installed correctly.

    In the mean time gentoo switched to GRUB2 and the procedure to install it correctly has changed. Checkout this ->

  8. alexblyz said, on April 30, 2015 at 6:00 AM

    i keep getting an error when writing to grub.conf : no such file or directory, ive done everything else as described do you know why?

  9. Tical said, on September 10, 2015 at 7:34 AM

    Yeah, I was getting the same error, I think the Grub functionality is different now.

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s