Download Video (1.18 MB)
This post shows how to install Gentoo for a default server. The installation is done using Minimal Installation CD from stage3 with manual kernel compilation.
First of all, boot from the Gentoo Minimal Installation CD. Boot with following options:
To avoid some errors it is recommended to check and update system time:
Configure the network:
ifconfig eth0 172.16.50.63/23 route add default gw 172.16.50.200 echo nameserver 172.16.50.105 > /etc/resolv.confThe above commands assigns the ip 172.16.50.63 with netmask 23 to the eth0 interface. The default gateway and nameserver are set to 172.16.50.200 and 172.16.50.105 respectively.
Once network interfaces are configured. Network connection should be checked using the commands:
ifconfig route -n ping google.comNext, configure and run screen. It will be used in process of manual kernel configuration. Download the .screenrc and use it:
wget sysadmin.md/stuff/.screenrc screenFor disk partitioning cfdisk will be used:
cfdiskIn video are used the following partition scheme:
sda1 – for /boot. Size 102 MB
sda2 – for swap. Size 512 MB
sda3 – for /. Size 8192 MB
Make and activate the swap filesystems:
mkswap /dev/sda2 && swapon /dev/sda2 free -m | grep SwapFor /boot and / partitions should be created ext3 filesystems. Next commands will create and mount them:
mke2fs -j /dev/sda1 && mke2fs -j /dev/sda3 mount -t ext3 /dev/sda3 /mnt/gentoo mkdir /mnt/gentoo/boot mount -t ext3 /dev/sda1 /mnt/gentoo/boot mount | grep sda cd /mnt/gentooDownload the Stage and Portage tree tarballs. Go to one of Gentoo mirrors and download stage-3 and portage, check their integrity and unpack the tarballs:
links http://distfiles.gentoo.org/distfiles/ md5sum -c stage3*.tar.bz2.md5.DIGEST md5sum -c portage*.tar.bz2.md5sum.DIGEST tar xvjpf stage3*.tar.bz2 tar xvjf portage*.tar.bz2 -C /mnt/gentoo/usrSystem configuration is done by editing the /etc/make.conf. Below commands will download the make.conf and package.use templates:
mv etc/make.conf etc/make.conf.old wget sysadmin.md/stuff/make.conf -O etc/make.conf mkdir etc/portage wget sysadmin.md/stuff/package.use -O etc/portage/package.use vi etc/make.confThe CHOST variable should be taken from make.conf.old and copied to make.conf template:
cat /mnt/gentoo/etc/make.conf.old | grep CHOSTInformation about CPU should be gathered to change CFLAGS and CXXFLAGS variables. The vendor_id, cpu family, model and model name values could be obtained using the command:
less /proc/cpuinfoThe safe flags can be found on http://gentoo-wiki.com/Safe_Cflags
Change MAKEOPTS variable. A good choice is the number of CPUs in system plus one. To obtain number of CPU’s use the following command:
cat /proc/cpuinfo | grep ^processor | wc -lFinally, change the variables and USE flags in make.conf template. If you don’t know the destination about specified USE flag, just comment it. A full description on the available USE flags can be found on your system in /usr/portage/profiles/use.desc. Also edit, if necessary, package.use template:
Next, mount proc and dev filesystems and copy nameservers file:
mount -t proc none /mnt/gentoo/proc mount -o bind /dev /mnt/gentoo/dev cp /etc/resolv.conf etc/Chroot in prepared environment:
chroot /mnt/gentoo /bin/bash env-update && source /etc/profileConfigure system clock by modifying the following variables in /etc/conf.d/clock:
CLOCK="local" TIMEZONE="Europe/Chisinau" CLOCK_SYSTOHC="yes"Important! After that, date/time should be checked and updated again:
date date MMDDhhmmYYYY date && hwclock hwclock --systohcOnce clock is configured, the portage should be updated:
emerge --sync emerge -av portage dispatch-confTo manually compile the kernel, install a kernel sources:
emerge -av gentoo-sourcesConfigure the kernel: for this screen and tools such lspci or lsusb are used to gather the hardware information:
cd /usr/src/linux make menuconfig lspci -v lsusb -vCompile and install the kernel and modules:
make && make modules make install && make modules_installOnce kernel and suitable modules are compiled, the GRUB bootloader should be installed and configured:
emerge -av grub wget sysadmin.md/stuff/grub.conf -O /boot/grub/grub.confThe GRUB uses the pre-configured template. Edit this file, if necessary.
The below command will set up GRUB from grub shell:
grub grub>find /boot/grub/stage1 grub>root (hd0,0) grub>setup (hd0) grub>quitDownload and install fstab file template:
wget sysadmin.md/stuff/fstab -O /etc/fstabNetwork configuration involves modifying several files:
echo HOSTNAME="gentoosrv" > /etc/conf.d/hostnameEdit file /etc/conf.d/net and add the lines:
config_eth0=( "172.16.50.63/23" ) routes_eth0=( "default gw 172.16.50.200") dns_domain="home.lan"Set the network to load at the default runlevel:
rc-update add net.eth0 defaultInstall system logger and sheduler and add them to runlevel default:
emerge -av syslog-ng vixie-cron rc-update add syslog-ng default rc-update add vixie-cron defaultFor security reasons, root password should be changed and a new user should be added to to the administrative tasks:
passwd rc-update add sshd default useradd -m -G users,wheel -s /bin/bash sysadmin && passwd sysadminExit the chrooted environment, unmount all partitions and reboot:
env-update && source /etc/profile exit cd umount /mnt/gentoo/boot /mnt/gentoo/dev /mnt/gentoo/proc /mnt/gentoo rebootPost install operations. Recompile entire world with new settings from make.conf (this may take a couple of hours):
emerge -eav world dispatch-confWhen all packages are recompiled with new settings, invoke cleanup commands:
env-update && source /etc/profile emerge -a --depclean emerge -av gentoolkit revdep-rebuild env-update && source /etc/profileFinally sync system time with a time server and update the file timestamps:
ntpdate -bu pool.ntp.org hwclock --systohc find / | xargs touch Related Posts:- [gentoo] Logging the boot messages on remote server
- Monitoring Linux and Windows hosts with SNMP and Cacti
- FreeBSD quick installation guide
- [apache] Smart way to show loaded modules from shell
- Debian LAMP + nginx installation for high-loaded webservers
- Verbose VPN server installation using OpenVPN and OpenSSL
- Scanning server for malicious tools with rkhunter
