Installing Gentoo in VMware Player – Part II

Written: 08/24/13

Last Updated: 11/18/13

This techtorial is the third article in my installing Gentoo in VMware Player series. This article picks up with the Gentoo installation where the previous article left off, and will cover chapters five and six of the Gentoo handbook. If you are just now joining this series, start with my first article.

We need to verify that the system has the correct date set, as an incorrect date may cause issues in the future.

date

gentoo-vmware-installation-part-ii-1

The date should be set to UTC time. If you are unsure, use this website. My time is incorrect, so I need to set it. I am going to set it to Saturday, August 24, 2013, 23:58. The format that the date command uses is MMDDhhmmYYYY, that is month, day, hour, minute, and year notation, with the corresponding number of digits. For me I will execute the below command to set my date.

date 082423582013

gentoo-vmware-installation-part-ii-2

We need to download the stage tarball, which will be used to install the Gentoo installation files. The files should be downloaded into the Gentoo mountpoint. Assuming you used the same mount points, as in my previous article, you can change your directory as follows:

cd /mnt/gentoo

gentoo-vmware-installation-part-ii-3

We will use links to find an appropriate mirror and download the stage three tarball. You should use whichever mirror is closest to you.

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

gentoo-vmware-installation-part-ii-4

Press enter on the links splash screen.

gentoo-vmware-installation-part-ii-5

Press the down arrow until you find a HTTP mirror that is near you. I am currently in CA, USA, so I am going to go with a mirror hosted by the University of California. When you have your mirror selected, press enter.

gentoo-vmware-installation-part-ii-6

Navigate to the “releases” directory, by using the down arrow, and enter into it.

gentoo-vmware-installation-part-ii-7

Navigate to the “amd64” directory and enter into it.

gentoo-vmware-installation-part-ii-8

Navigate to the “autobuilds “directory and enter into it.

gentoo-vmware-installation-part-ii-9

Navigate to the “current-stage3-amd64” directory and enter into it.

gentoo-vmware-installation-part-ii-10

Navigate to “stage3-amd64-*.tar.bz2”, where “*” refers to the most recent release date. Press “D” to download the tarball.

gentoo-vmware-installation-part-ii-11

Press enter to start the download.

gentoo-vmware-installation-part-ii-12

Wait until the download has finished.

gentoo-vmware-installation-part-ii-13

Once the download has finished press “Q” to quit and then enter.

gentoo-vmware-installation-part-ii-14

Now that we have downloaded the tarball we can unpack it, by using tar.

tar xvjpf stage3-*.tar.bz2

gentoo-vmware-installation-part-ii-15

Before we continue, we need to take note of what our target architecture is. I will explain the purpose of this shortly. For now, execute the below command and take not of what the value of “-march=”. In my example you can see that it is “corei7”.

gcc -march=native -Q --help=target | grep march

gentoo-vmware-installation-part-ii-15.2

We need to edit the Portage make.conf file. Portage is the default package manager used by Gentoo. Most of the programs you will install will probably be installed using Portage. The Portage make.conf file contains the global settings for how packages should be installed. This includes compiler flags, as well as which dependencies should be included, which mirrors to use, etc…. Go ahead and edit the file using your favorite text editor. For all file editing, I will use nano, as shown below.

nano -w /mnt/gentoo/etc/portage/make.conf

gentoo-vmware-installation-part-ii-16

Your file should look something like the following image:

gentoo-vmware-installation-part-ii-17

We are first going to edit the compiler flags. These flags are used for compiler optimizations. Each architecture type will require different flags. Discussing the different types of flags is beyond the scope of this document, so I will instead demonstrate a basic example. Edit the CFLAGS line, similarly as to what is shown below. Two steps ago, we determined what our target architecture is. For me, it is “corei7”. You should set the value of -march to whatever your architecture is. Alternatively, you may use “native”, which means that GCC will figure it out automatically. The “-O2” flag is used to specify that the optimization class 2 should be used. There are other classes; however, O2 is one of the safest options. The “-pipe” flag is used to send data between the stages of compiling using pipes, i.e. the data will be passed using your memory. If you do not have much memory, you may wish to remove this flag. Removing the flag will mean that files will be used to pass data, thus drastically increasing the amount of time it will take to compile. For more information about the compiler options, refer to the relevant GCC manual.

CFLAGS="-march=corei7 -O2 -pipe"

Now edit the USE flags. These flags will allow you to specify exactly what dependencies you wish to include or not include. These settings are very personal and depend on what your end goal is for the system. One build might want to use KDE, another Gnome, and yet another might decide to have no X11 support at all. Each one of these settings would entail a different set of flags. If you are unsure, then leave them at their default values. I plan on using KDE, so I am going to set my USE flags to have all of the options required for a basic KDE install. For more information about the USE flags, refer to this document.

USE="-gnome X kde qt5 dbus consolekit policykit udev udisks xa libkms"

At the end of the file, we will add a new line to specify the number of parallel compilations that should occur. The rule of thumb is to set this value to one more than the number of logical processors your system has. I mentioned before that you should only setup the VM with one core, so for us the option will just be set to two. If you decide to increase the number of cores, in the future, you will also need to increase the number in this file.

MAKEOPTS="-j2"

When you are done editing this file, it should look something like the following image:

gentoo-vmware-installation-part-ii-18

Go ahead and exit nano by pressing CTRL+X,Y, and enter.

gentoo-vmware-installation-part-ii-19

gentoo-vmware-installation-part-ii-20

To ensure that the source code is downloaded as fast as possible, we should tell portage to use mirrors that are close to us. Use the mirrorselect tool to select all relevant HTTP and FTP mirrors. You can use the spacebar to select as many mirrors as you like.

mirrorselect -i -o >> /mnt/gentoo/etc/portage/make.conf

gentoo-vmware-installation-part-ii-21

Once you have selected the mirrors, press enter to exit mirrorselect and apply the changes.

gentoo-vmware-installation-part-ii-22

Use the mirrorselect tool to select the relevant RSYNC mirror.

mirrorselect -i -r -o >> /mnt/gentoo/etc/portage/make.conf

gentoo-vmware-installation-part-ii-23

gentoo-vmware-installation-part-ii-24

It is a good idea to verify that mirrorselect worked, as expected. Check the Portage make.conf file to verify the changes.

nano /mnt/gentoo/etc/portage/make.conf

gentoo-vmware-installation-part-ii-25

gentoo-vmware-installation-part-ii-26

We need to copy over the DNS info to ensure that our networking will still work once we enter into the new environment.

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

gentoo-vmware-installation-part-ii-27

Now we need to mount the necessary filesystems, required by the new environment.

mount -t proc none /mnt/gentoo/proc
mount --rbind /sys /mnt/gentoo/sys
mount --rbind /dev /mnt/gentoo/dev

gentoo-vmware-installation-part-ii-28

We are now ready to enter into our new environment. In other words, we are going to change our current location from the installation CD to the actual partitions that we just configured. This is known as “chrooting”. The first command will change the location of root from the virtual CD to the partition. The second command will reload some settings. The last command is used to update the prompt to remind us that we are in the chrooted environment.

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

gentoo-vmware-installation-part-ii-29

We are going to install a Portage snapshot and update the Portage tree. The snapshot will tell Portage what programs we can install, what profiles are available, etc…. Updating the Portage tree, will ensure that we have the latest information.

emerge-webrsync
emerge --sync

gentoo-vmware-installation-part-ii-30

If you are warned that a new version of Portage is available, you should update portage by doing the following:

emerge --oneshot portage

You were probably notified that there was news that needed to be read, as I was. You can get a list of the news by using the first command, shown below, and you can read the news items by using the second command. I piped the result of reading the news into less, to allow the news to be read more easily. To exit less, just press “Q”.

eselect news list
eselect news read | less

gentoo-vmware-installation-part-ii-31

gentoo-vmware-installation-part-ii-32

We now need to select our desired profile. The profile you select will configure your system to be used for those settings. This involves setting default values for the USE and CFLAGS, as well as other settings. You should choose the profile that best suits your needs. As I said before, I am going to be using KDE, so I am going to select the KDE profile (number 5). If you do not plan on using a graphical environment, select the basic profile. If you plan on having a graphical environment, but are unsure which profile to use, use the desktop profile. You will be able to change your profile in the future, so do not worry if you decide to change your environment in the future.

eselect profile list
eselect profile set 5
eselect profile list

gentoo-vmware-installation-part-ii-33

We will now set our desired time zone. Before we can set it, we need to determine the location of the appropriate time zone’s file. As an example, I show the search process for finding the Pacific time zone.

ls /usr/share/zoneinfo
ls /usr/share/zoneinfo/US

gentoo-vmware-installation-part-ii-34

I now know that my time zone is “US/Pacific” and its path is “/usr/share/zoneinfo/US/Pacific”. I will go ahead and copy over the relevant zone files and then set the time zone. Make sure to change these settings to whatever your time zone is.

cp /usr/share/zoneinfo/US/Pacific /etc/localtime
echo "US/Pacific" > /etc/timezone

gentoo-vmware-installation-part-ii-35

This concludes the second part of installing Gentoo. The next part focuses on how to configure the Gentoo kernel. Click here to go to that article.

Discussion (4)

There are 4 responses to “Installing Gentoo in VMware Player – Part II”.

  1. Random dude responded:

    · Reply

    Please finish thing 🙂

    • There are a few more parts to this article. You can go to the next one by clicking here. The full series is not yet done, but I did cover the more difficult aspects (the rest will very closely follow the Gentoo handbook). I do plan to complete it; however, I am currently focusing on my thesis work, so it probably won’t be for a while….

  2. cari responded:

    · Reply

    Followed your steps.. But I’m stuck at the one with the command: “gcc -march[…]”.
    Error : “-bash: gcc: command not found”
    Seems like gcc is not found in path. I tried to find it manually but doesn’t seem to be here.

    • You can skip that step if you know what your microarchitecture is. If you are unsure, do some research on your specific system to figure out what type of CPU it has. You can then look at this list for 32 bit CPUs and this list for 64 bit CPUs for the various options.

      I hope that helps!

Leave a Reply