Gentoo Install Notes

I was working on installing gentoo on a new machine (that will eventually replace this machine I am typing this on) and I was going through the Gentoo Handbook and kept running into problems (I have (and will explain) figured them out) so kept having to go through the same steps and was looking to create some notes.  Initially I wrote these notes in my notebook.

What I did wrong

Gentoo uses a “stage 3” install at an early part of the installation and careful selection of the correct (or close enough to correct) stage 3 is important.  I picked one that on the download stage 3 page it points to that looked “closest” to what I wanted, but really the one I wanted needed to be downloaded from the complete list of stage 3 downloads.  I believe that I am on my way now.

My Cheat Sheet

Here is what I have made notes of the steps involved, with a bit better explanation about why I am doing the various things.

Mounting system root partition

I mount my root partition as one of the first things that I work from on the new system.

mount /dev/sda5 /mnt/gentoo

My device is unusual, it is usually /dev/sda4 for most partition layouts, but for compatibility reasons, and to handle blocking off “reserved” space on the SSD, I have needed more than 4 partitions, which leads to 4, turning into 5, with the spare space on partition 6.

Setting Date

Setting correct date is important, and I’ve found that my system doesn’t have the correct date, so:

ntpd -gq

The first command gives the current date, and you might have a correct date set, the second one sets the date to the date using the ntp protocol. It also starts the daemon running.

Installing Stage 3

Here is where I screwed up, as noted above. I had a stage 3, which it wasn’t easy to switch to a different one. I have replaced that now (and am working on getting it properly updated).

tar -xjpvf stage3-x32-20170803.tar.bz2 --xattrs --numeric-owner

editing make.conf

I have worked on editing the make.conf file which controls how emerge/portage builds new (undated, rebuilt) packages:

CFLAGS="-march=native -pipe -O2"


You need to copy the DNS information before you chroot into the new system (or you won’t have working DNS) so the simple command:

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

The use of the -L is helpful in case the /etc/resolv.conf is a symbolic link, it will copy the contents, rather than the link.

mounting other filesystems

The other filesystems need to be mounted so they will be in the right places when you chroot to the new system.

mount /dev/sda2 /mnt/gentoo/boot
mount -t proc /proc /mnt/gentoo/proc 
mount --rbind /sys /mnt/gentoo/sys 
mount --make-rslave /mnt/gentoo/sys 
mount --rbind /dev /mnt/gentoo/dev 
mount --make-rslave /mnt/gentoo/dev

The first one is to have your boot partition mounted when it is needed later in the process. The other ones are mounting the proc, sys, and dev filesystems where they will be looked for in the chroot system which you will be entering next.

Entering and setting up chroot

You now need to enter the new environment, you have 3 lines to enter to do so:

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

The first line is what puts you in the new install, the next line sets the usual things which you expect when you log in, and the third simply changes the command prompt to remind you that this is the new system.

Setting up portage repo

This is best to do as two steps (I have tested it):

emerge --sync

This will update you to the latest version of portage, the first line taking the latest snapshot, and the next updating to the latest live version.

Checking News items

When you do this, you likely will get some news items which show up, these are supposed to be important to note:

eselect news list
eselect news read N 
eselect news read

This first line lists the news items, the second if you see one which you think you should pay special attention to can be used with N replaced by the item number, the third, will make sure that it doesn’t keep telling you about the same news items.

Setting your profile

This is a similar process to the news one, but this will set how you will be using the system. The commands are:

eselect profile list
eselect profile set N

Here the N is the profile that you want to use. Depending on what you ended up selecting as your stage 3, you may end up with a number of options which will not work (without a lot of fiddling). I recommend before you go to the next step of upgrading your system (which will mean new software when you have changed the profile you are using) checking to make sure that you have selected the correct one.

Updating system

You will need to update your system to the new (or updated profile if you happen to have not changed your profile). The quick (for me) means is:

emerge -uDaNt @world

depending this could end up not working, so if it does I would recommend doing the update in a more phased approach:

emerge -a1 portage
emerge -uDaNt @system 
emerge -uDaNt @word

I should talk about what those options mean, these are all one letter options so they string together like I have used them:

-a ask before proceeding
-u update atom listed
-1 oneshot — this does not add package to @world set
-D check "deeply"
-N check to see if the use flags have been updated since you installed packages
-t Display as a tree.  This also lists the packages with the first package to install on the bottom of the list

Future updates to this

This is the point that I am at with my install, so I will update this with further steps in getting things up to date.

This entry was posted in Computer Support, Linux and tagged , , , , . Bookmark the permalink. Both comments and trackbacks are currently closed.