Gentoo x86 Linux Installation on a VirtualBox Image
UPDATE: gentoo.org now has a one-page “quick install guide” that covers the Gentoo installation. (Adapted from: http://www.gentoo.org/doc/en/handbook/handbook-x86.xml. This is a work in progress.)
Download VirtualBox. Get the appropriate version–your computer’s current operating system is the host OS for Virtualbox.
http://www.virtualbox.org/wiki/Downloads
Download the ISO minimal installer for Gentoo x86 from this directory, getting the file install-x86-minimal-xxxxxxxx.iso
:
http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/releases/x86/current-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:
ping www.google.com
Create the boot partition:
fdisk /dev/sda
n
p
1
Enter
+32M
p
Create the swap partition:
n
p
2
Enter
+512M
t
2
82
p
Create the root partition:
n
p
3
Enter
Enter
p
w
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:
date
Download and unpack the latest stage 3 tarball at the Gentoo mountpoint, getting the file stage3-i686-xxxxxxxx.tar.bz2
:
cd /mnt/gentoo
links http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/releases/x86/autobuilds/current-stage3-i686/
tar xvjpf stage3-*.tar.bz2
Download portage from a mirror and install:
wget http://ftp.ucsb.edu/pub/mirrors/linux/gentoo/snapshots/portage-latest.tar.bz2
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
env-update
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
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
Wait
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
Insert:
HOSTNAME="mycomputername"
Set the domain and DHCP:
nano -w /etc/conf.d/net
Insert:
nic_domain_lo="my-nisdomain"
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:
127.0.0.1 mycomputername.my-nisdomain mycomputername localhost
Set the root password
passwd
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
Put:
CLOCK="local"
TIMEZONE="America/Los_Angeles"
Install system logger
emerge syslog-ng
Wait
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
Put:
default 0
timeout 30
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
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)
#makeactive
#chainloader +1
grep -v rootfs /proc/mounts > /etc/mtab
grub-install --no-floppy /dev/sda
Unmount the partitions:
exit
cd
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"
VIDEO_CARDS="nvidia"
Attempt to add video drivers:
emerge --config nvidia-drivers
Install VirtualBox Guest Additions:
emerge virtualbox-guest-additions
Install GNOME:
emerge gnome
Wait
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
startx
Exit GDM
rc-update add xdm default
Add to /etc/conf.d/xdm:
DISPLAYMANAGER="gdm"
Install Chromium:
export ACCEPT_KEYWORDS="~x86"
emerge -av www-client/chromium
Reboot
reboot
Clone the VirtualBox VM for backup purposes.