Installing Gentoo

Well I have decided to have a play with a Linux distribution. I chose
Gentoo because of the flexibility and the fact that it has a good user
support base.

I
have started using Gentoo for a LAMP based web server at work. I am
going to use Drupal as my CMS because of its flexibility and also ease
of use. Obviously I like Drupal (why else would my Blog use it)

One
thing I have found is that installing Gentoo is not as easy as I
expected. The main difficulty I had was with installing it at work
behind a firewall. I had the full installation CD, but I didn’t realise
I needed the packages as well…doh!

Anyway just for other
peoples info these are the steps I followed to get my first Gentoo
install going. I think it is still a bit broken but I will add bits as
I go. I am doing the same thing at home because I want to build a HTPC
and use Gentoo with MythTV, I know there are easier ways but I think I
will need some bleeding edge packages which won’t be included in the
"nice" distributions.

  • Get a Gentoo minimal install CD
  • Make sure you have a network connection to the Internet
  • Boot from the CD
  • Type gentoo at the prompt
  • Set the harddisk up using

fdisk /dev/hda
We need to remove existing partitions
d then 1
Do this for each existing partition
Now make the new Linux partitions
n then p then 1 then press ENTER then +32M
n then p then 2 then press ENTER then +512M
n then p then 3 then press ENTER then press ENTER
Now write the changes
w
Now we need to put the filesystem on
We will make the Boot and Root filesystems ext2
mke2fs /dev/hda1
mke2fs /dev/hda3
Set up the Swap
mkeswap /dev/hda2
swapon /dev/hda2

  • Mount the disks

mount /dev/hda3 /mnt/gentoo
mkdir /mnt/gentoo/boot
mount /dev/hda1 /mnt/gentoo/boot

  • Make sure the date is set correctly
  • Change to the new filesystem

cd /mnt/gentoo

  •  Use the inbuild browser to get the list of Gentoo mirrors

links2 http://www.gentoo.org/main/en/mirrors.xml

  • Get the latest stage3 from /releases/x86/2005.0/stages

It will be named something like stage3-x86-2005.0.tar.bz2

  • Unpack the downloaded stage

tar -xvjpf stage3-x86-2005.0.tar.bz2

  • From the same mirror used before get the latest portage snapshot in /snapshots

It will be named something like portage-20050803.tar.bz2

  • Extract the files

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

  • You should edit your make.conf file with a command like:

nano -w /mnt/gentoo/etc/make.conf
But I will include more details later once I work out my optimal flag settings. -w is EXTREMELY IMPORTANT, it makes sure nano doesn’t use wordwrap. I will explain how to turn this off permanently later. Stupid default setting!

  • Copy you DNS info over to the new install

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

  •  Mount the /proc filesystem

mount -t proc none /mnt/gentoo/proc

  • Enter the newly install environment

chroot /mnt/gentoo /bin/bash
env-update
source /etc/profile

  • Now sync the portage tree

emerge –sync

  •  You should edit the USE variables in /etc/make.conf but once again I haven’t decided the best ones yet
  • Go with a stage 3 install to make it quick 🙂
  • Upgrade the baselayout

rm /etc/conf.d/net
touch /etc/nsswitch.conf
CONFIG_PROTECT="-*" emerge baselayout

  •  Set the timezone

ln -sf /usr/share/zoneinfo/Australia/Melbourne /etc/localtime

  •  Get the sources

emerge gentoo-sources
maybe emerge gentoo-dev-sources might be required for bleeding edge

  • Manually configure the kernel
cd /usr/src/linux
make menuconfig

  • Defaults for menuconfig should work but I will put more details in here later
  • Compile the kernel

make && make modules_install

  • Copy over the new kernel to the Boot partition

cp arch/i386/boot/bzImage /boot/kernel-2.6.12-gentoo-r6
cp System.map /boot/System.map-2.6.12-gentoo-r6
cp .config /boot/config-2.6.12-gentoo-r6

  • Create /etc/fstab
nano -w /etc/fstab
I will put details of my fstab file in here later, should be something like this:
/dev/hda1 /boot auto noauto,noatime 1 2
/dev/hda2 none swap sw 0 0
/dev/hda3 / auto noatime 0 1
none /proc proc defaults 0 0
none /dev/shm tmpfs nodev,nosuid,noexec 0 0
/dev/cdroms/cdrom0 /mnt/cdrom auto noauto,user 0 0
  •  Set the hostname

    nano -w /etc/conf.d/hostname 

  • Set the domain name
    nano -w /etc/conf.d/domainname
  • Use rc-update to put this script in the startup sequence

rc-update add domainname default

  •  Set the root password

passwd

  •  Edit /etc/rc.conf

nano -w /etc/rc.conf

  •  Install a system logger

emerge syslog-ng
rc-update add syslog-ng default

  • Install cron

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

  • Install DHCP support

emerge dhcpcd

  • Once I have sorted out the framebuffer I will post details for setting it up here
  • Use GRUB as the boot loader, install it

emerge grub

  • Edit the config file

nano -w /boot/grub/grub.conf

  • Make the grub.conf file look like this

default 0
timeout 0
title=Gentoo Linux
root (hd0,0)
kernel /kernel-2.6.12-gentoo-r6 root=/dev/hda3

  • Further Grub setup required

cp /proc/mounts /etc/mtab
grub-install /dev/hda

  • Reboot (take the CD out)

exit
umount /mnt/gentoo/boot /mnt/gentoo/proc /mnt/gentoo
reboot

  • Yay it should work!

This entry was posted in Computers and tagged , . Bookmark the permalink.