Installing Gentoo
Very lightly-edited copy-paste from an emailed guide that a customer supplied:
| This guide is currently a work in progress. You should not expect it to work or be correct. Please see the discussion page for some areas where it might be improved. |
OK, my guide to running gentoo on bitfolk.
It presumes you know a fair bit about linux in general. including using bash, fdisk, making a kernel, etc.
I've got a single core machine, 20GB disk, with 500MB RAM VMS. This will work fine on the smallest package of a 10GB disk too. I've done most of my install now, and sitting < 3GB.
I'm also going for a 64 bit OS, feel free to change the various bits to make a 32 bit OS.
A lot of this is a summary of http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml, so if you've done Gentoo installs before, you need to know 4 things:
- Your disks are /dev/xvda (main disk) and /dev/xvdb (swap disk)
- You need to enable the following kernel modules (in addition to your normal stuff):
CONFIG_XEN=y CONFIG_XEN_MAX_DOMAIN_MEMORY=500 CONFIG_XEN_SAVE_RESTORE=y CONFIG_XEN_BLKDEV_FRONTEND=y CONFIG_XEN_NETDEV_FRONTEND=y CONFIG_HVC_XEN=y CONFIG_HVC_XEN_FRONTEND=y CONFIG_XEN_FBDEV_FRONTEND=y CONFIG_XEN_BALLOON=y CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y CONFIG_XEN_SCRUB_PAGES=y CONFIG_XEN_DEV_EVTCHN=y CONFIG_XENFS=y CONFIG_XEN_COMPAT_XENFS=y CONFIG_XEN_SYS_HYPERVISOR=y CONFIG_XEN_XENBUS_FRONTEND=y CONFIG_XEN_GNTDEV=m CONFIG_XEN_GRANT_DEV_ALLOC=m CONFIG_XEN_PRIVCMD=y CONFIG_XEN_HAVE_PVMMU=y
It's possible you can trim this little lot down, but that's working
You can also trim away a lot of stuff from a standard kernel, like PCI, power management etc.
- In /etc/rc.conf, set rc_sys="xenU"
Pre install work
- Copy the PASSWORDS file somewhere, so that you have it.
- Change the root password (we'll be binning the install soon, but in the interests of security whilst we work)
- Change your domain DNS to point to the right IP.
- Log into the console, look in your PASSWORDS file
- Run the rescue environment.
- You'll need the password for the user "user", which is displayed on screen.
- You can either work off the terminal you are in, or you can now ssh in.
Layout
YOU ARE ABOUT THE DELETE EVERYTHING ON YOUR BITFOLK DISKS. STOP UNLESS YOU WANT TO LOSE EVERYTHING!
- Disks are located at /dev/xvda and /dev/xvdb (swap disk) (run fdisk -l to be sure)
- fdisk /dev/xvda, and partition accordingly.
As this is a VPS, we don't really need a /boot partition, so just create 1 partition for /
For completness, I toggled the boot flag on the /boot partition.
- Because I like things to be correct, I fdisk'd the swap disk to change the type to 82,
"Linux swap / Solaris"
- Filesystem types - I'm going with ext4. Change to suit.
mkfs.ext4 -L root /dev/xvdb1
-
mkswap -L swap /dev/xvdb1 LABEL=swap, UUID=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Install
A summary of commands to run, with comments on decisions I made. Best advice is to use the gentoo handbook, so that you can make informed decisions yourself, and also have up to date information! Current on 2013-11-07. This is provided just to give some insight.
- Make dirs and mount
- Grab the source code and extract. Change the URL to match current version and arch
-
Make the appropriate edits to CFLAGS in /etc/portage/make.conf
Read the guide at http://wiki.gentoo.org/wiki/CFLAGS for
Make your own decision, but I've got:
CFLAGS="-march=corei7 -O2 -pipe -fomit-frame-pointer", but make your own decision.
-
Make the appropriate edits to MAKEOPTS in /etc/portage/make.conf.
Make your own decision based on what virtual hardware you have, but I've got 1 core, so have got:
"MAKEOPTS="-j2"
-
Mirror select isn't available in the rescue environment, so here are a couple of good example for the SYNC and GENTOO_MIRRRORS to paste into /etc/portage/make.conf:
SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage" GENTOO_MIRRORS="http://gentoo.virginmedia.com http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo http://mirror.bytemark.co.uk/gentoo http://mirror.qubenet.net/gentoo"
-
Setup the virtual environment, and chroot in
cp -L /etc/resolv.conf /mnt/gentoo/etc/ mount -t proc none /mnt/gentoo/proc mount --rbind /sys /mnt/gentoo/sys mount --rbind /dev /mnt/gentoo/dev chroot /mnt/gentoo /bin/bash source /etc/profile export PS1="(chroot) $PS1"
-
Update Gentoo
emerge-webrsync emerge --sync
Read the news. This stuff is useful, and should be read.
eselect news read
-
Basic setup
Look at the profile list. I'm sticking with a "server" install, the default.
eselect profile list
Make any changes to the USE variable. I chose to leave it as is for now.
nano -w /etc/portage/make.conf
I'm in the UK. Change accordingly.
cp /usr/share/zoneinfo/Europe/London /etc/localtime echo "Europe/London" > /etc/timezone
I like gentoo-sources. You can go with vanilla-sources if you wish, there are others too.
emerge gentoo-sources
Configure your kernel. See my stuff at the top for essential enables, then the rest is up to you. Probably should look at http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml if you're new to Gentoo.
cd /usr/src/linux make menuconfig make && make modules_install cp arch/x86_64/boot/bzImage /boot/vmlinuz
Edit your /etc/fstab. Mine is below:
/dev/xvda1 / ext4 noatime 1 1 /dev/xvdb1 none swap sw 0 0
Edit your hostname.
nano -w /etc/conf.d/hostname
Edit your network settings in /etc/conf.d/net. Mine is below (change your numbers! run ifconfig -a to get them):
config_eth0="XXX.XXX.XXX.XXX netmask XXX.XXX.XXX.XXX brd XXX.XXX.XXX" routes_eth0="default via XXX.XXX.XXX.XXX"
Change the root password
passwd
Modify /etc/rc,conf - set:
rc_sys="xenU"
If you only want a certain language, you can configure it in /etc/locale.gen:
en_GB ISO-8859-1 en_GB.UTF-8 UTF-8
If you do change locales, you need to run:
locale-gen
Setup your env language in /etc/env.d/02locale
LANG="en_GB.UTF-8" LC_COLLATE="C"
And update the environment:
env-update && source /etc/profile
Optional choices
I went with the gentoo choices of syslog-ng for syslog, vixie-cron for cron and installing mlocate.
You decide.
-
Bootlader.
Grub isn't needed. you only need a grub.conf
mkdir -p /boot/grub
Here's by grub.conf:
default 0 timeout 0 title Gentoo Linux root (hd0,0) kernel /boot/vmlinuz root=/dev/xvda2
-
All done!
Unmount and reboot, and cross fingers! Give it a minute to boot, and then you should be able to ssh in!
exit cd umount -l /mnt/gentoo/dev{/shm,/pts,} umount -l /mnt/gentoo{/boot,/proc,} reboot
mkdir /mnt/gentoo
mount /dev/xvda2 /mnt/gentoo/
mkdir /mnt/gentoo/boot
mount /dev/xvda1 /mnt/gentoo/bootwget http://www.mirrorservice.org/sites/distfiles.gentoo.org/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20131031.tar.bz2
tar xvjpf stage3-*.tar.bz2emerge syslog-ng
rc-update add syslog-ng default
emerge vixie-cron
rc-update add vixie-cron default
emerge mlocateGuess we want ssh on startup.....
rc-update add sshd defaultFinally
Don't panic if it doesn't work. You can start the rescue environment again, mount the disks, and work out what went wrong. GOOD LUCK!