If you like my work show support on my Patreon
In my last post I started talkig about Gentoo, and getting everything that is needed to install Gentoo. In this post I will start to install Gentoo onto my PC. In my case I will be installing it onto a 64 bit machine and will be using a 64 bit version of Gentoo. Because of this I will be using the 64 bit Gentoo Handbook as a reference. The handbook starts with setting up network connections. However since networking is not needed until later. I will be starting with preparing the disk.
The first thing we will need to do is put our installation media we created in my last post into the computer while the computer is turned off. So if we are using a DVD we will put the DVD into the DVD drive and close the drive while the computer is turned off. If we are using a USB drive we will put it into our USB port while the computer is turned off.
After we have done this we will turn the computer on. Depending on how our system is setup it could boot right into the installation media. If it doesn’t we may need to go into the BIOS and change the boot order. In my case I just press F12 which gives me a boot menu. From there I simply choose the boot device I want to boot into.
If we are using the Gentoo Live DVD image I used in my previous post then you will see the Gentoo Desktop when it is finished booting. From here we will press Ctrl + Alt + F1 which will present us with our terminal. Now that we have our Terminal on our screen we can start to setup our disk.
To do this we first need to find out what our disk is. If you read my last post you will already know how to do this using fdisk.
After we have found out what our disk is, we will need to wipe the disk clean. For this example my disk is /dev/sda. So I will type the following.
fdisk -l /dev/sdb
Then we simply delete all partitions on the disk like we did in my last post. After we have done that we will write the changes to the disk and exit fdisk. Next we will partition our drive. But in order to partition our drive we need to know how unix systems partitioning works.
Traditionally most unix systems have 4 partitions. One partition is a boot record partition, the second is a partition that stores the boot loader, then we have a swap partition and then our main partition. The boot record partition can have one of two different types of labels. GPT is better for Unix systems however using GPT prevents us from being able to dual boot into Windows. If you plan to dual boot, then we will need to use the MBR (Master Boot Record) label. For the purposes of this article I will be using GPT for the boot record partition. The second partion is the boot loader partition. This partition will be the partition that will store our GRUB Bootloader files. We can use another bootloader like Lilo if we want but I prefer GRUB so we will use that. The swap partition requires it’s own formatting, which is called the swap format, and our root partition which will store the majority of our system can be in many different types of formats. In my case I will use the EXT4 format.
Now that we have the basic understanding of partitioning our disk lets get started. This will be the basic layout of our disk.
|Boot Record||Size 2GB||Unformatted|
|Boot Loader||Size 5GB||EXT2 Format|
|Swap||Size 10GB||SWAP Format|
|Root File System||All Left Over Space||EXT4 Format|
So lets start creating our partitions. To do this we will use the parted tool, by typing the following.
parted -a optimal /dev/sdb
Now that we are in parted we will create our GPT label. To do this we will type the following.
Now we will tell parted what unit of measurements we want to use for partitioning the disk. Since nothing we will do will be less then 1GB we will use GB as our unit of measurements. To tell parted this we will type the following.
Now we will create our boot record. This will will be 2GB in size and will be at the beginning of the drive. So we will type the following.
mkpart primary 1 3
If we wanted the partition to be just 1GB we would type
mkpart primary 1 2
If the partition is 3GB in size we would type
mkpart primary 1 4
It is important to remember the last number because we will have the next partition start where the last partition ended on the drive. Since our last partition ended at 3 we will start our new partition at 3 and end it somewhere else. But before we start our next partition lets name the first partition we just created. To do this we will type the following.
name 1 grub
Now we will set it to be bootable.
set 1 bios_grub on
Now that the first partition has been created we can check it, and make sure everything is correct. To do this we will tell parted to print all partition information.
It should output something like the following.
Number Start End Size File system Name Flags
1 1.00GiB 3.00GiB 2.00GiB grub bios_grub
Now lets create the boot partition. This will be the partition that will actually store our boot loader. For this partition I will make it 5GB. So to will type the following.
mkpart primary 3 8
name 2 boot
We will need to turn on our boot partition. To do this we type the following.
That is it for our boot partition. Next we will create our swap partition. Since I am installing Gentoo on an older computer and it is much slower, I will use a rather large swap partition. If my computer was faster I would use a smaller swap partition. For this example my swap partition will be 10GB. To do this we type the following.
mkpart 8 18
name 3 swap
The last partition will be our Root Filesystem. This will store everything else. So this will take up the rest of the disk. To make the partition fill the rest of the disk our last number will be set to -1. The -1 means it will go all the way to the end of the drive and attempt to loop around to the beginning if it can. Filling the the rest of the drive up with the partition. So we type the following.
mkpart 18 -1
name 4 rootfs
Now we will quit parted. To do this we will type the following.
Now we need to format our partitions. Remember I posted a table above to show what formats we will use with each partition. Refer to that if you need to. Lets format our boot loader partition. We know our boot loader partition is the second partition so we will type the following.
mkfs.ext2 -T small /dev/sdb2
Now lets format our Root Filesystem.
mkfs.ext4 -j -T /dev/sdb4
Now lets initialize the swap partition.
Now lets activate our swap partition.
Finally we will mount the Root File System.
mount /dev/sdb4 /mnt/gentoo
And we are all done setting up our disk. The next post will be setting up networking, and fetching the stage3 Tarball.
If you like my work show support on my Patreon