Warning Livedoc is no longer being updated and will be deprecated shortly. Please refer to https://documentation.tjhsst.edu.

Gentoo Workstation Install

From Livedoc - The Documentation Repository
Revision as of 11:45, 30 October 2016 by 2019okulkarn (talk | contribs) (um fix things i hope)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


Installing Gentoo on a workstation is quite the adventure. You should probably follow these instructions line-by-line if you don't want to mess up. The first thing you'll want to do is get a Gentoo LiveUSB, or if netroot is up, then you can use that. Networking should automatically get set up using DHCP, and if it doesn't, you're probably doing something wrong.

Preparing the Disk

Now, you'll probably be using /dev/sda, but if you aren't, substitute the disk you are using throughout the documentation.

Partitioning the Disk

First, you'll be creating the partitions on the disk. The CSL uses LVM to manage partitions, so keep that in mind. Run the following commands to partition your disk correctly. If parted throws a warning about informing the kernel about the change, you can go ahead and ignore that.

# parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel msdos # this will format the disk
(parted) unit MB
(parted) mkpart primary 1 124
(parted) mkpart primary 124 10000
(parted) mkpart primary 10000 -1  //-1 means end of disk
(parted) set 1 lba off
(parted) set 2 lba off
(parted) set 3 lba off
(parted) set 1 boot on
(parted) set 3 lvm on
(parted) print
Model: ATA TOSHIBA DT01ACA0 (scsi)
Disk /dev/sda: 500108MB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number  Start           End               Size              Type           File system  Flags
 1             1.05MB      124MB          123MB          primary                            boot
 2             124MB       10000MB     9877MB       primary
 3             10000MB  500107MB   490107MB    primary                            lvm
(parted) quit

You should get something that looks similar, if not exactly the same as this.

LVM Volume Creation

First you will be creating the LVM volumes, which allow us to resize partitions without having to repartition the physical disk. If there is already a logical volume system on the disk, you will have to remove it by running vgremove vgwkstn and accepting all the prompts.

# pvcreate /dev/sda3  //create the physical volume 
# vgcreate vgwkstn /dev/sda3  //create the volume group
# lvcreate -L 2G -n swap vgwkstn  //create the swap partition
# lvcreate -L 50G -n usr vgwkstn
# lvcreate -L 50G -n opt vgwkstn
# lvcreate -L 10G -n var vgwkstn
# lvcreate -L 1G -n afs vgwkstn
# lvcreate -L 5G -n tmp vgwkstn
# lvcreate -L 5G -n root vgwkstn //note this will be mounted at /root, not /

Congratulations, you're done!

Creating the Filesystem

So now you'll be creating the filesystem for the new partitions. THIS WILL ERASE ALL DATA CURRENTLY ON THE DISK!!! Run the following commands to make the filesystem correctly.

# mkfs.ext2 /dev/sda1
# mkfs.ext4 /dev/sda2
# mkswap /dev/vgwkstn/swap
# swapon /dev/vgwkstn/swap
# mkfs.ext4 /dev/vgwkstn/afs
# mkfs.ext4 /dev/vgwkstn/opt
# mkfs.ext4 /dev/vgwkstn/root
# mkfs.ext4 /dev/vgwkstn/tmp
# mkfs.ext4 /dev/vgwkstn/usr
# mkfs.ext4 /dev/vgwkstn/var

Mounting the Filesystems

Now you'll be mounting the filesystem in the correct location to install Gentoo. Run the following commands to mount the filesystems in the correct location.

# mount /dev/sda2 /mnt/gentoo/
# cd /mnt/gentoo/
# mkdir usr opt var tmp root boot
# mkdir -p var/cache/openafs
# mount /dev/sda1 boot/
# mount /dev/vgwkstn/usr usr/
# mount /dev/vgwkstn/opt opt/
# mount /dev/vgwkstn/var var/
# mount /dev/vgwkstn/afs var/cache/openafs/
# mount /dev/vgwkstn/tmp tmp/
# mount /dev/vgwkstn/root root/

Installing Files

Make sure the date is set correctly before proceeding.

ntpdate -s ntp1.csl.tjhsst.edu

If ntp1 is down, which it shouldn't be, use ntp2.csl.tjhsst.edu

Download Base Files

You will be downloading the Gentoo stage3 files from RIT's mirror because it gives us the maximum download speed. You will have to find the correct link based on the current date, but it should be similar to the one in the code below.

# cd /mnt/gentoo/
# wget http://mirrors.rit.edu/gentoo/releases/amd64/autobuilds/current-stage3-amd64/stage3-amd64-20161020.tar.bz2
# wget http://mirrors.rit.edu/gentoo/snapshots/portage-latest.tar.bz2
# tar xvjpf stage3-amd64-20161020.tar.bz2 --xattrs
# tar -xvf portage-latest.tar.bz2 -C /mnt/gentoo/usr/


You will have to prepare for chroot by setting USE flags and other stuff for portage. Just kidding. I'm not entirely sure how USE flags works so don't ask me. Just do what it says. The more important config files such as make.conf and krb5.conf are stored on a remote server (TBD 2016-17)

# scp root@remotehost:/srv/config/make.conf /mnt/gentoo/etc/portage/make.conf //remote path tbd
# cp /etc/resolv.conf /mnt/gentoo/etc/resolv.conf
# cp -av /etc/ssh/ssh_host_* /mnt/gentoo/etc/ssh/

Mount the remaining filesystems:

# mount -t proc none /mnt/gentoo/proc
# mount -o bind /dev /mnt/gentoo/dev
# mount -o bind /sys /mnt/gentoo/sys

Finally, chroot into the newly set up Gentoo install:

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

Configuring the system

Now may be a good time do emerge vim.

Locale Settings

We need to set the LOCALE variables to English and US, so run the following commands:

# vim /etc/locale.gen //uncomment the 2 lines starting with en_US
# locale-gen

Updating Packages

Now you'll want to update all the packages in the @world set:

# emerge --sync
# USE="-java" emerge --ask --update --deep --newuse @world // the java USE flag causes circular dependencies

Configuring the Kernel

You will be configuring the kernel using make. Luckily for you, the kernel config is stored on a remote server, so you don't have to do much. The following commands will build the kernel with the proper flags.

# emerge --ask lvm2
# rc-update add lvm boot
# emerge --ask =sys-kernel/gentoo-sources-4.1.15-r1  //change this to the latest stable kernel version supported by AFS
# emerge --ask sys-kernel/genkernel
# scp root@remotehost:/srv/config/fstab /etc/fstab //remote path tbd
# cd /usr/src/linux
# scp root@remotehost:/srv/config/kernel.config /usr/src/linux/.config  //remote path tbd
# make && make modules_install  //this will take a while
# make install
# genkernel --lvm --install initramfs  //build a new initramfs with the new options
# emerge --ask net-fs/openafs-kernel //for afs support

Configuring the Network

All you need to do here is set networking to start at boot.

# cd /etc/init.d/
# ln -s net.lo net.{interface_name}
# rc-update add net.{interface_name} default

Install Essential Packages

There are certain packages that are essential to the system, so you will be installing them now. All other packages will be installed using salt

# emerge -a sys-boot/grub:0 syslog-ng vixie-cron logrotate dhcpcd

Editing Config Files

You'll have to edit the configuration files for hostname and timezone, but the other important ones are stored on the remote server.

# vim /etc/conf.d/hostname // change it to hostname="something"
# echo "America/New_York" >> /etc/timezone
# scp root@remotehost:/srv/config/hwclock /etc/conf.d/hwclock
# scp root@remotehost:/srv/config/sshd_config /etc/ssh/sshd_config
#  rc-update add sshd default
# rc-update add syslog-ng default
# rc-update add vixie-cron default


Please, please, please, please, please do not forget to do this. Set the password to the current workstation root password. If you don't know what it is, ask someone who does.


Grub Configuration

You'll have to set up/install grub on the disk in order for the workstation to boot.

# scp root@remotehost:/srv/config/grub.conf /boot/grub/grub.conf
# grep -v rootfs /proc/mounts > /etc/mtab
# grub-install --no-floppy /dev/sda

Exit chroot and Reboot

Congratulations! You're almost done! All you have left is to exit the chroot, unmount all filesystems, and reboot:

# exit
# cd
# umount -R /mnt/gentoo  //if this fails unmount the disks one at a time
# sync
# sync
# reboot

You're done!