if you didn’t read Part 3 yet, you better go and read it first.
TABLE OF CONTENTS
- Download, Configure, Compile and Install Kernel
- Configure Filesystem Table
- Setting Hostname and Install PC Card Support
- Configure System Information
- Installing Necessary Tools
1. Download, Configure, Compile and Install Kernel
Linux is a kernel only. It is not a complete OS. Richard Stallman tries so hard to pull people toward saying GNU/Linux rather than Linux only. Because Linux itself is a kernel only and does not contain any system application nor user application. In order to boot into Gentoo, you have to download Linux kernel source and install it. We can do so using emerge tool.
Doing this, Gentoo will pull the kernel source and put it in ‘/usr/src/linux‘. Now is the time to configure the kernel. Basicly, you can configure the kernel manually or by using the genkernel tool. If you want to configure the kernel automatically using genkernel, then refer to the Gentoo Handbook since I didn’t configured the kernel that way. I’ll go with configuring the kernel manually.
Configuring the kernel is the hardest step you will ever encounter. I repeated this step 5+ times till I get it working optimally with my machine. Before configuring the kernel, you have to know your system hardware. Forunately, there’s a tool called ‘lspci‘ that will list all the devices that is connected to your PCI (Peripheral Component Interconnect). PCI is created by Intel and it is a bus to connect hardware devices to your computer. To use the ‘lspci‘ you have to emerge pciutils. Let’s see your hardware devices:
Take a note of your hardware devices and let’s configure your Linux kernel now:
‘make menuconfig‘ will open up the very damn big list of Linux kernel options. As I said before, configuring the kernel is the hardest step you’ll encounter. You should choose to enable the options that you want it to be compiled into the kernel and leave the options that you don’t want it to be compiled. But, how to know the options that need to be compiled into the kernel ? Well, you will know some of the options through the hardware devices list you just took a note when you listed the PCI devices. Other options comes from experience, researches and your knowledge. Let me mention two important facts. First, pressing ‘?‘ on an option will bring a help screen to explain what that option for. Second, pressing a spacebar will enable the option ‘*‘ and pressing it again will switch the ‘*‘ to ‘M‘. When an option is enabled by ‘*‘, it is meant to be compiled inside the kernel. While ‘M‘ means that the option will be compiled as a module. Compiling the option inside the kernel will make it run faster but it will crash the whole kernel if it crashes. While Compiling the option as a module will make it run a bit slower but it won’t crash the whole kernel if it crashes plus the kernel can safely restart the module again. This brings up the topic of monolithic kernel and microkernel. I recommend reading this topic in Wikipedia if you’re interested. Happy configuring the Linux kernel and please refer to Gentoo Handbook because there are some important options that should be enabled. Otherwise, Gentoo won’t be able to boot.
If you’re using a USB modem like me and want it to be supported in the kernel, then you probably should enable the option (as a module) USB driver for GSM and CDMA modems located:
-> Device Drivers
-> USB support
-> USB Serial Converter support
Once you finish configuring the kernel, exit the configuration screen and it will prompt you to save. Just click yes. Now, let’s compile the kernel and install the modules you’ve chosen:
make && make modules_install
The modules will be installed in ‘/lib/modules/<kernel_version>‘. Once kernel compilation finishes and modules installed, you got to copy the new kernel to the ‘/boot‘ folder.
cp arch/<your_architecture>/boot/bzImage /boot/kernel-<kernel_version>-gentoo-r1
Fine now. Kernel is ready to be booted (still you need a bootloader for the BIOS to run upon computer start which will run kernel) and modules are installed. The modules won’t be loaded automatically. So, you have to tell the kernel the modules that you want it to load through the file ‘/etc/modules.autoload.d/kernel-2.6‘. The kernel read this file and expect one module per line to load. Apply this command to see the list of all modules installed:
find /lib/modules/<kernel_version>/ -type f -iname ‘*.o’ -or -iname ‘*.ko’ -print | less
Take note of the module names you want to automatically load and remove the extension. Open up nano and write the module names:
2. Configure Filesystem Table
Filesystem table is a table that inform Linux kernel what partitions are there to mount, where to mount them, what filesystem that partition has, what are the permissions of that partition and so on. It is located at ‘/etc/fstab‘. So, let’s configure the filesystem table inside your system:
The syntax of the table is demostrated in the comments of the file. It’s easy. Each line represent the settings for a single partition. Items of the settings are separated by whitespace. Let me show you my filesystem table:
$ cat /etc/fstab | egrep -v ‘^#’
/dev/sdb1 /boot ext2 defaults,noatime 1 2
/dev/sdb2 none swap sw 0 0
/dev/sdb3 / ext3 noatime 0 1
/dev/sr0 /mnt/cdrom auto noauto,user 0 0
proc /proc proc defaults 0 0
shm /dev/shm tmpfs nodev,nosuid,noexec 0 0
The first column is the partition. The second is the mountpoint (which is where to mount that partition). The third is the filesystem type. The fourth is the options of the mount operation (see the man page of ‘mount‘ to know more about the options). the last two columns are for the dump and the pass numbers. The proc is for the kernel to provide information about your system. The shm is an implementation of the shared memory concept which is a way of communication for the programs.
3. Setting Hostname and Install PC Card Support
Change your Linux hostname by the variable HOSTNAME in the file:
If you want your system to support PCMCIA (PC Cards) then you should install the package ‘pcmciautils‘ through emerge:
4. Configure System Information
Let’s change the root password now:
Then choose your favourite (default) editor (through the variable EDITOR):
Then select the proper timezone (Through the variable TIMEZONE, note that it should be the same as the timezone you’ve copied to /etc/localtime):
For me, I’ve chosen ‘Mideast/Riyadh89‘.
5. Installing Necessary Tools
First, a system logger. The system logger is a software that logs everything that happens in your system to a log file. There is a variety of system loggers. I prefer syslog-ng:
rc-update add syslog-ng default
the ‘rc-update‘ will add syslog-ng init script to the run level sothat it will start automatically with kernel boot.
Second, a cron daemon. The cron daemon is a daemon that schedule jobs to run at a certain time/date. (Just like task scheduler you Windows guys). Again, there is a variety of cron daemons out there. I prefer dcron:
rc-update add dcron default
Third, file indexing service sothat you can locate them quickly later on:
Fourth, filesystem programs and utilities sothat you can manage these filesystems:
emerge xfsprogs reiserfsprogs jfsutils
Fifth, necessary network tools like DHCP client, PPP daemon and internet dialing program (wvdial):
emerge dhcpcd ppp wvdial
If you’re using a USB modem again like me, make sure to install wvdial sothat you can dial your connection out from your USB stick. That’s it for now. Comming up in Part 5, how to install and configure a bootloader sothat you can boot your kernel and start Gentoo from harddisk…
Gentoo Handbook <http://www.gentoo.org/doc/en/handbook/handbook-amd64.xml?full=1>