My *nix world

Minimalist Gentoo

I am already using a PC for more than 17 years so I am not enjoying any more of having "hundred" of useless applications/libraries/dependencies installed on my PC, a lot of fancy options which either I never use or I am willing "to pay for" (because I can live without them anyway). This is happening when you install a pret-a-porter distro, such as Ubuntu, Windows, etc.

Basically I was looking for a minimalist, lightweight Linux installation. This led me to Gentoo so I gave it a try.

Minimalist Gentoo

Because I had already a functional Ubuntu distro installed on my laptop I didn't want to wipe that. Instead I have cloned the HDD disk image to another external disk (size of the other disk does not matter as long it is bigger):

So basically my external USB WD /dev/sdb disk became a clone of my laptop internal /dev/sda disk. I had to check if it really worked so I got into laptop BIOS, I changed the boot options (boot from external USB hdd as first boot option) then I booted from USB external cloned disk without problems. So that was the point I decided that I can go further without fear, because I had a functional backup copy of the old distro (just in case).

First step was to get a install-amd64-minimal-.iso installation CD image from http://gentoo/releases/amd64/current-iso/. Next I burned the .iso image to a CD and I booted from CD.

Next step was to repartition my laptop hdd. The Gentoo handbook was helpful so I've got a /dev/sda1 , /dev/sda2 and /dev/sda3 partitions where I had created a ext2, swap and ext4 respectively file-systems. After that I had to download and install a stage3 and also a portage-latest tarballs.

It is also (very) important to know right from the beginning what options would you like your system to provide, because you can create a fine-tuning configuration file which will be used be any app/library/dependency you may need to install. Basically all the sources will be configured (before they are compiled) based on the uses flags specified in /etc/make.conf

My make.conf looks like the following:

Because Gentoo basically compiles everything from source it provides a way to specify the compiler flags which will be used. I my case I have:

Also, if you want to improve the final compile time you can take advantage of the multi-CPU arhitecture you might have so just tell portage to use as many threads you want (eg: CPU number +1). I my case I had specified:

You should know from the beginning the desktop manager you might want to use so you can disable all others (eg: gnome, kde, etc) just before they will be included/compiled within all libraries/pluggins.

In order to organize your USE flags based on the scope (eg: flags designed for X11 libraries, KVM, XFCE, etc) you can define two or more custom USE variable (eg: USE_X) where you define just those flags related to a particular scope, then you can construct the final USE variable based on a concatenation of all custom USE variable (eg: USE="${USE_DONT} ${USE_SYSTEM} ${USE_GENERAL}").
If you take a look at the /etc/make.conf file above you will understand what you can do and how it can help. If not then maybe you should stick for the moment with the defaults options already included on the file.

When you install Gentoo you install just the foundation of your system : a filesystem with a Linux kernel and in the top of these a clever package management designed by the Gentoo. So, after installing Gentoo as handbook says I had to install the X server and in the top of it a desktop environment.

Linux kernel

Because Gentoo will compile the Linux kernel directly from source code, you can configure what options your kernel will include, so you are able to tune little bit every option available. This is a very useful thing because your kernel will become little bit slimmer and faster. This is how my kernel .config file looks like:

I have started .config from the Linux kernel default options and latter I have tuned little bit based on my hardware devices, file-systems I was going to use, etc. Based on the above configuration and my hardware, my boot process takes about 20 seconds. This includes the loading of kernel, init, X server and xfce session.

This was achieved by using only those services that I really need (uninstall/disabled the others), parallel starting as many services as possible, and also by moving many of those from default to boot (just those that fit the scope). My rc-update is looking like that:

acpid | default
alsasound | default
bootmisc | boot
consolekit | default
dbus | default
devfs | sysinit
dmesg | sysinit
fsck | boot
gentoo32 | default
hostname | boot
hwclock | boot
iptables | boot
keymaps | boot
killprocs | shutdown
local | default
localmount | boot
modules | boot
mount-ro | shutdown
mtab | boot
net.lo | boot
net.wlan0 | default
netmount | default
ntpd | default
procfs | boot
root | boot
savecache | shutdown
swap | boot
sysctl | boot
syslog-ng | boot
termencoding | boot
udev | sysinit
udev-postmount | default
urandom | boot
vixie-cron | default

Note : gentoo32 is a daemon I have created for mounting/umounting at boot-time all the devices/folders I need for a gentoo 32-bit chroot environment. The others are Linux standard daemons so you might already know them.

Also I am using a autologin feature as described here because I do not need to use a login manager (this will speed up little bit the boot and X loading process). In fact you can use a Slim or lightDM or any other DM for that but if you prefer to login automatically then that might work for you too.

I want to know how much takes the booting process and if is something I can do to improve that. I have captured the whole boot process into a chart by using bootchart. It takes just 20 seconds. In real life I think the system boot speed will be at least 1 second faster, because it does not require to load a special init program such bootchart that I have used for capturing this chart:

minimalist gentoo

Update: after installing a SSD disk (instead for my 5200rpm HDD) the boot take about 12 seconds instead of 20.

One of the coolest thing after installing Gentoo, X server, Xfce, Slim (or other GDM) is that after you login to your X session the desktop does not provide almost any program: no file manager, no browser, no email client, no archive manager, no picture viewer, no graphical editor (except the console application called nano). So you have nothing yet installed but a wonderful package manager (portage) which is capable of providing you all the Linux open source applications which shares the source somewhere (maybe I have exaggerated little bit but you know what I mean).

Let's populate Gentoo with applications

I don't know about you but I need all sort of applications, like:

  • text and graphic editors
  • VM emulators
  • office tools
  • databases (front-end/back-end)
  • IDE
  • browser/email client
  • networking tools

So I have installed the following applications/libraries/tools that you can find in the portage:app-admin/logrotate

  1. app-admin/syslog-ng
  2. app-admin/testdisk
  3. app-arch/pxz
  4. app-arch/xarchiver
  5. app-benchmarks/bootchart
  6. app-cdr/xfburn
  7. app-editors/leafpad
  8. app-editors/nano
  9. app-emulation/libvirt
  10. app-emulation/qemu-kvm
  11. app-emulation/virt-manager
  12. app-misc/mc
  13. app-office/libreoffice
  14. app-portage/gentoolkit
  15. app-portage/layman
  16. app-portage/mirrorselect
  17. app-text/epdfview
  18. app-text/gocr
  19. app-text/pdf2html
  20. app-text/pdfedit
  21. dev-db/mysql-workbench
  22. dev-db/pgadmin3
  23. dev-java/javacc
  24. dev-java/sun-jre-bin
  25. dev-libs/boost
  26. dev-libs/hyphen
  27. dev-python/pyinotify
  28. dev-util/ccache
  29. dev-util/codeblocks
  30. dev-vcs/mercurial
  31. dev-vcs/subversion
  32. gnome-extra/gnome-utils
  33. gnome-extra/zenity
  34. mail-client/thunderbird
  35. media-fonts/corefonts
  36. media-fonts/freefonts
  37. media-fonts/liberation-fonts
  38. media-fonts/terminus-font
  39. media-gfx/gimp
  40. media-gfx/ristretto
  41. media-sound/despotify
  42. media-sound/lastfmplayer
  43. media-sound/spotify
  44. media-video/mplayer2
  45. net-analyzer/iftop
  46. net-analyzer/nmap
  47. net-analyzer/traceroute
  48. net-firewall/iptables
  49. net-fs/curlftpfs
  50. net-ftp/ftp
  51. net-im/pidgin
  52. net-mail/fetchmail
  53. net-misc/bridge-utils
  54. net-misc/dhcpcd
  55. net-misc/openntpd
  56. net-misc/spice-gtk
  57. net-misc/telnet-bsd
  58. net-misc/vinagre
  59. net-p2p/qbittorrent
  60. net-print/foomatic-db-ppds
  61. net-print/foomatic-filters-ppds
  62. net-wireless/iwl3945-ucode
  63. net-wireless/wireless-tools
  64. net-wireless/wpa_supplicant
  65. sci-calculators/galculator
  66. sys-apps/dmidecode
  67. sys-apps/flashrom
  68. sys-apps/hdparm
  69. sys-apps/hwinfo
  70. sys-apps/less
  71. sys-apps/lm_sensors
  72. sys-apps/mlocate
  73. sys-apps/portage
  74. sys-apps/usbutils
  75. sys-apps/usermode-utilities
  76. sys-block/gpart
  77. sys-block/gparted
  78. sys-block/ms-sys
  79. sys-boot/grub-static
  80. sys-boot/unetbootin
  81. sys-devel/gcc
  82. sys-devel/prelink
  83. sys-fs/aufs3
  84. sys-fs/dosfstools
  85. sys-fs/ntfs3g
  86. sys-fs/ntfsprogs
  87. sys-fs/squashfs-tools
  88. sys-kernel/genkernel
  89. sys-kernel/gentoo-sources
  90. sys-power/acpid
  91. sys-power/powertop
  92. sys-process/atop
  93. sys-process/iotop
  94. sys-process/nmon
  95. sys-process/time
  96. sys-process/vixie-cron
  97. www-client/firefox
  98. www-client/links
  99. www-client/lynx
  100. x11-apps/setxkbmap
  101. x11-apps/xrandr
  102. x11-base/xorg-drivers
  103. x11-base/xorg-server
  104. x11-libs/qt-meta
  105. x11-libs/qt-qt3support
  106. x11-libs/vte
  107. x11-misc/gtkdialog
  108. x11-misc/slim
  109. x11-terms/terminal
  110. xfce-base/thunar
  111. xfce-base/xfce4-meta
  112. xfce-extra/thunar-archive-plugin
  113. xfce-extra/thunar-volman
  114. xfce-extra/tumbler
  115. xfce-extra/xfce4-cpugraph-plugin
  116. xfce-extra/xfce4-mixer
  117. xfce-extra/xfce4-screenshooter
  118. xfce-extra/xfce4-sensors-plugin

You can find many plugins designed for Xfce. For example you might need a panel plugin which might help you to switch the keyboard layout between ENG and your native language. Or you might need a panel plugin which inform you about the memory ussage, weather forecast, volume control, etc. There exists many others but these can be handy and in my case I need them at least one time every day.

Because I would prefer to keep my system as lightweight as possible rather then loading and running these plugins round the clock, I was thinking to a way of achieving (almost) the same results but with fewer resources. I had already the libnotify installed so I have a program called notify-send which basically is capable to pop-up a balloon message with a title, a body and an icon on the left. I also have some Xfce icons pre-installed into the /usr/share/icons. So I had wrote few lightweight bash scripts that provided almost the same information to me:

  • [k] switch_kbs : switch keyboard layout (9)
  • [k] showfreem : display the physical available memory (1)
  • [k] weather : check the meteo station for your location and display the today (24h) forecast (66)
  • [k] volumctrl : change the volume control (raise, lower, toggle mute/unmute) (22)
  • [s] monitor_wifi : monitors your wifi connection and popup status information (26)
  • [s] xrandr : enable/disable your second monitor (dual monitor) (1)
  • [s] battery_status : check your laptop battery status and display a popup balloon with the status info (36)
  • [s] fetchmail : check for your email periodically (eg: every 5 minutes) (1)
  • [k] printer : start CUPS only when you need it (15)
  • [k] dualmon : switch from single to multi monitor and vice-versa (32)
  • [s] monitor_usb-storage : monitors when usb-storage is attached/removed

Note : [k] means that they can be called by keyboard shortcuts, [s] means they are loaded at session start-up and runs the same way a daemons does. The number at the end of line within parentheses represents the total number of code lines the bash script contains (fewer means a very lightweight script).

If you will ask why should I reinvent the wheel, the explanation is quite simple : I don't! In fact I am using the programs already installed on my Gentoo but instead of having 8 plugins which needs to stay into the memory all day long (and to run, of course) I have 8 bash scripts which collect (almost) the same info (from the Linux /proc or /dev) as these plugins does, BUT the most of them are running and loaded into the memory ONLY when I need them, when I call them.

For exemple, I have defined a keyboard shortcut (yes, Xfce rocks!) that will call switch_kbs bash script every time when I press Shift+CapsLook. So my keyboard layout is changed and I get a popup notification about that:

minimalist gentoo

Click for detailed article...

Also to find out the total physical RAM available to your system I have created a keyboard shortcut (Ctrl+Alt+F) which will call my showfreem bash script which will popup a simple balloon like the bellow:

minimalist gentoo

If you would like to checkout from time to time how will looks the weather today you can have a bash script like mine which will collect the info from the weather meteo station and will pop-up a balloon like the following:

minimalist gentoo

Click for detailed article...

Well, I don't have a permanent volume control plugin loaded into my desktop so I had wrote a bash script which basically can increase/decrease/toggle my system volume and will pop-up a balloon info like the following:

minimalist gentoo

Click for detailed article...

Well, sometimes you need to monitor some processes so you will need a daemon alike script to do that and which should be capable to notify you about the new status. This can be achieve also using a bash script and libnotify. I have done this to monitor my wireless connection (to notify me any time when the connection goes down/up). A sample notification can look like this one:

minimalist gentoo

Click for detailed article...

The "daemon" is in fact a bash script which will check for every 5 seconds the wireless new status, if it is different than the old status than it will popup a balloon like the one above. Also it will notify when connection becomes alive, when script starts or ends. It is something easy to cook at home, something like a "do it yourself" kit.

Also, when you are working with a laptop you need to be notified when your AC is unplugged or when your battery goes under 50%, etc. I have the same requirement so I had wrote a little "daemon" which loads at session start-up and checks every 5 seconds the battery status. When it changes (eg: AC unplugged, AC plugged in, battery charge is less than 50%, etc) it will pop-up a balloon with info like the following:

minimalist gentoo

Click for detailed article...

I found out also very useful to have a little daemon which will check few of my email accounts every 5 minutes and if I received a new email to get a pop-up notification with details about sender email address. I achieved this very simple by writing a simple bash script which will call the fetchmail console program every 5 minutes and check all the accounts I had defined into the .fetchmailrc file which exists in my home folder. So when a new email arrive I've got a notification like the one bellow:

minimalist gentoo

Click for detailed article...

So, what is telling me this notification? It says that I have received an email from to my eugenmihailescux account at the server. This account is also defined in my .fetchmailrc file, so you can have how many POP3/IMAP accounts you want defined into your .fetchmailrc, for any of them you will get a notification when new email arrives.

I don't use the printer all the time so why should I start CUPS every time even if I am only using it once per week? Well, I had wrote a bash script that starts/stops CUPS from a keyboard shortcut and inform me about this:

minimalist gentoo

Click for detailed article...

When working with multi-monitors is nice to be able to switch some of them on/off quickly. I had wrote a bash script that allows me to switch from my laptop monitor to both laptop+external monitor and back to only one. You might have only one or even more external monitors. When you switch on/off the others monitors a balloon notification like the one below will appear:

minimalist gentoo

Click for detailed article...

A feature that I miss from other distro is the ability to get notified when a USB storage is attached/remove. Well, I am sure that Xfce/Gnome/etc have such applet/plugin but I would prefer (for reasons I already mentioned few times) to keep things simple. So I have my own bash script which runs at X session start-up and when new USB storage device is attached/removed I get a balloon notification:

Minimalist Gentoo

Click for detailed article...

Conclusion :

  • a Linux distro that can boot in about 20 seconds (take a short look at the .config, a very capable kernel)
  • a Linux distro that will take maximum 150MB RAM (including kernel, X server, Xfce session); the rest remains available for other apps
  • nice 8 desktop lightweight features that replace the equivalent Xfce plugins in just 170 lines of bash code

I had played with Ubuntu Desktop for a while and also with all Windows versions from Win3x to Win7. At the end of the day I can only say this : Gentoo rocks! (because it's faster, it's simpler, it's far customizable than any other distro).

Now, if you think that this article was interesting don't forget to rate it. It shows me that you care and thus I will continue write about these things.

The following two tabs change content below.
Minimalist Gentoo

Eugen Mihailescu

Founder/programmer/one-man-show at Cubique Software
Always looking to learn more about *nix world, about the fundamental concepts of math, physics, electronics. I am also passionate about programming, database and systems administration. 16+ yrs experience in software development, designing enterprise systems, IT support and troubleshooting.
Tagged on: ,

Leave a Reply

Your email address will not be published. Required fields are marked *


Get every new post on this blog delivered to your Inbox.

Join other followers: