git Gentoo repos on GitHub

git me! The gentoo repos are on github, and I've just discovered them.. mysteriously hidden in the World Wide Web ;)

There is a post on the gentoo forums from 2015, re git/github saying:
Although some developers wrongly still recommend plain rsync-update method, you should never do that, since it is fundamentally insecure (emerge-webrsync is signed by a machine key, but still better). 

You should instead start to sync via git (best do that from github, unless you want to break our infra server).

Essentially, rsync update method is outdated and insecure. The recommendation is to sync update via git, and more specifically github, rather than the gentoo infra servers.

GitHub gentoo (without metadata cache, for developers) repo:

This seems to be a mirror of the gentoo git infra server:

I found a github mirror, which I now use. For anonymous portage sync updates, I am hoping this secondary mirror may be more stable and less noisy.

GitHub gentoo-mirror (with metadata cache, for users) repo:

Before we change our sync method to git, we need to prepare/clean the portage location. Delete existing files, or move them elsewhere, in case you might have second thoughts ;) If you are not happy with git, you can move them back, and continue with rsync updates.

# mv /usr/portage /tmp

If you don't have enough freespace in /tmp, or don't want to use it, move it elsewhere and remember the location.

My /tmp is on tmpfs, and I have enough free space there for now. If you have a similar setup, note that tmpfs will not survive a reboot.

Now we can change our sync method to git.

# vi /etc/portage/repos.conf/gentoo.conf
main-repo = gentoo

location = /usr/portage
sync-type = git
sync-uri = git://
auto-sync = yes

Make sure there are no other files in that folder. I had trouble when I renamed my gentoo.conf file to another name in that same folder as backup. I changed auto-sync = no to be safer. Sync wouldn't give me any errors, or updates!

I previously used the gentoo infra server, before changing over to github, and then to the mirror. Apparently, the gentoo infra servers are not ready to take the weight of the whole world. Apparently, GitHub is safer and more reliable. I was pleasantly surprised that my git was in sync after the changeover.

We have prepared, cleaned and emptied our portage for a git sync. Now we can sync.
# emerge --sync

And move the distfiles back where they belonged.
# mv /tmp/portage/distfiles /usr/portage/

Now you can sync again and again.. to your heart's content :) No more worrying about overloaded rsync servers warning, or ending up on the ban list for syncing too much.

It is now a pleasure to sync, and see exactly what has changed where. Such a difference from watching that cruft fly past like a matrix on your screen. You might miss the filed Change Logs, if you used them. They are no longer needed. Git has much better, automated and less error prone methods.

Note the efficiency of git sync, and github :) This is what Linus alluded to, when he wanted to have an efficient kernel repository, accessible to the whole world.

If you are happy with git sync, you can delete that portage backup.
# rm -rf /tmp/portage

Another more important aspect is about making open source truly open! Anyone, even without github logins, can view the sources and changes. With a free github account, anyone could make suggestions via a simple pull request. You don't even need to be a developer.

The Monolithic Cabals

A few decades ago, there was a great big flame war called the Monolithic vs Microkernel debate. It is said that the debate was won by Linus. And that is why Linux became so popular.

Personally, I am a fan of Microkernels. But I am more a fan of Open Source. I believe that is the sole reason Linux became so popular. Linux didn't become so popular because people loved a monolithic architecture. Folks embraced it because it was open source.

More recently, there have been similar flames wars, but on a much larger scale, likes of which had never been seen before, spreading out from the low-level Kernel layers to the higher layers above. Apparently, some years ago, Gnome won the battle for the top layer Desktop, or rather the Desktop Environment. What was left was the middle layers between the Kernel and the GUI. And that battle apparently ended with many distributions bowing down to systemd. This was more a victory for the Gnome camp, who had lent them more than a covert hand in that battle. RedHat won the battle this time.

These monolithic cabals want to do everything. They don't seem to understand The Unix Philosophy. Taking over everything just makes them Too Big To Fail. We should never put all our eggs in one basket.

Is the war seemingly over now? The powerful feudal lords have divided the spoils between who owns which layer of the empire. Each of them, in their wisdom, have decided that they shall be the sole decision makers over what everyone else is or not allowed to do.

The one saving grace that stops them being completely becoming evil is the fact that each of them are completely dependant on Open Source. Any change they attempt is open to the rest of the world. Even that fact didn't stop The Mad Hatters from attempting to take over the lower layer kernel, with their dubious code pushes.

If I didn't know any better, I might suspect this as a culmination or coming together of a series of covert Microsoft Strategies. If you have not read The Halloween Documents, it is worth having a quick look. The FUD has come full circle, and many camps within Linux got embroiled in major flame wars over the systemd middleware between desktop and kernel.

This also reminds me of a paper called The Cathedral and The Bazaar. Slaves never had a choice. Freemen could make their own choices, unencumbered by anyone telling them what to do or not. There must be a reason that the exalted cathedrals of yore are empty now, while the bazaars have flourished.

It all depends on which side of the fence you are. If you are among the ruling class, obviously you will want to remain in the cathedral, lording over others. But if you are not among the ones inside enjoying luxuries, you would rather be outside free to decide your lifestyle and how best to flourish yourself, than be a slave in the cathedral.

In the end, it all depends on what is best for the world. Is it better that a few rule over everyone? Or would the world be a better place, if everyone had equality of choice and rights? No one should be too poor or too rich!

There is a reason that Open Source has flourished with contributions from volunteers who gave back their skills and time, in order to make things better for everyone. In stark contrast, the extremely wealthy proprietary software companies are all sitting on great big piles of accumulated cash twiddling their thumbs, deciding what to do.

I think my thoughts are running amok now..

I just wanted to pen down some thoughts before I lost them. I will flush this a bit more later.. Keep an eye!

A Digital Beep

When you don't have a Speaker/Bell, or you can't make quite make it work, and you want a beep!

It seems some devs have been a bit over zealous in trying to get rid of the system beep. Apparently, some users have been loudly complaining about their systems playing loud beeps. So they have thrown the baby out with the bath water. And now users who need the system beep do not seem to have it anymore.

The traditional method, to trigger the bell sound on a system beep event, was using pcspkr or snd-pcsp kernel modules. It seems quite a lot of users have lost this functionality during system updates. There seem to be multiple workarounds of workarounds floating around to resolve this issue. They seem to work for some, but not for many.

If you can, it is best to try get either pcspkr or snd-pcsp to work, as the system beep is an integrated event. You can hear the beep anywhere you want, including the console and terminals. The beep volume can be controlled from your audio mixer. You can increase, decrease, or mute the beep volume. That is how it used to be, and that is how it should have been.

Unfortunately, we seem to have quite a lot of trigger happy devs lately. In their eternal quest to keep adding yet more features and bumping up versions, they lose sight of core functionality and stability. Personally, I would rather have stable (even if old) reliable systems, than use bleeding edge new systems filled with tons of new features and even more bugs. In this process, they seem to be cannibalising what they have been handed over from previous generations to maintain.

But I guess, we are where we are.. and we try to make the best of what we have.

A digital beep could be a useful alternative. In this case, an audio file sounding like a bell masquerades as the pc-speaker bell at each system beep. In a nutshell, an audio player plays an audio file, at every system beep event.

The caveat is that depending on the method used, a digital beep is restricted to certain environments only. The method used below will only work within X, not on the console or any tty or anywhere outside X.

Read on for what is required. You can customise, or replace most of the bits with something else.

Kernel config:

Since we will not use pcspkr or snd-pcsp, we might as well remove them from the kernel, or atleast mask them. No need to carry excess baggage. No point in having things we can't/won't use.

# vi /etc/modprobe.d/blacklist.conf
blacklist pcspkr
black snd-pcsp

Check your kernel config for INPUT_BEEP. If not, add them and recompile your kernel. You will need to reboot for the new kernel to take effect.
$ grep BEEP /boot/config-`uname -r`

This is enabled in the default kernel configs of gentoo, debian, ubuntu, and arch linux.

Packages required:
1. sound-theme-freedesktop
2. vorbis-tools
3. xkbevd

sound-theme-freedesktop: A standard minimal sound theme.
This package installs a set of sound files in /usr/share/sounds/freedesktop directory. One of those audio files called bell.oga simulates a digital beep.

This package contains the ogg123 audio decoder/player, which can play .oga sound files from a sound-theme.

$ man ogg123
ogg123 reads Ogg Vorbis audio files and decodes them to the devices specified on the command line. By default, ogg123 writes to the standard sound device, but output can be sent to any number of devices. Files can be read from the file system, or URLs can be streamed via HTTP.

xkbevd: XKB event daemon
We run this as a background service to check for bell events, and trigger ogg123 to play bell.oga.

$ man xkbevd
The xkbevd event daemon listens for specified XKB events and executes requested commands if they occur. The configuration file consists of a list of event specification/action pairs and/or variable definitions.

The default configuration file is ~/.xkb/, which needs to be created.

$ vi ~/.xkb/
soundCmd="ogg123 -q"

Bell() "freedesktop/stereo/bell.oga"

This is pretty much the standard configuration.

We could open this up, and use any other audio file and any other media player. One thing to consider would be the impact of using large audio files and/or large audio players. We don't really want our system to freeze at every single bell event, while bloatwares load.

Identify your environment, to auto-start the XKB event daemon, according to your DE (Desktop Environment) or WM (Window Manager).

In my case, I login at the console and startx. I added the following line to my startup file.

$ vi ~/.xinitrc
xkbevd -bg
exec i3

There are a few more lines in that file. But those are the last two lines.

Ok, we have pretty much finished up. Now, we need to check whether these settings take effect.

If you had to recompile your kernel, you need to reboot. If you didn't, you need to logout and login, to verify the daemon auto-start.

May the beep be with you!

i3 wm

I've been hearing about i3 Window Manager for a while now, and had been waiting to have a go. I finally did.
i3 User Guide

All the major advantages are listed on the homepage itself. What I particularly like:
"Don’t be bloated, don’t be fancy (simple borders are the most decoration we want to have)."

For now I am making it my home. I don't need any fancy distracting frills. The only thing I seem to be missing is Alt+Tab, as I keep hitting it. [Update: I got that working. See config below.]

You can have a really beautiful desktop, but how long are you going to look at it, before you open some windows which cover most of your desktop? As for me, I usually have all windows maximised on my smallish screen.

i3 has three layouts - split ($mod+e), stacking ($mod+s), and tabbed ($mod+w). I particularly like the tabbed layout maximising screen estate use on small laptop screen. (Auto)Hide the statusbar, and or full-screen ($mod+f) your windows.

$mod+Enter will open a new terminal window in your chosen layout. You can change layouts anytime.
$mod+Shift+q will close your active window.
$mod+Shift+e will exit i3.

Armed with this basic knowledge, we can start exploring i3.

It is a very simple install - three packages - i3 + i3status and dmenu.

On first run, i3 will prompt you and create it's config in ~/.config/i3/config.

Below are my config files.

$ cat ~/.xinitrc
setxkbmap -option terminate:ctrl_alt_bksp
exec i3

$ cat ~/.config/i3/config
set $mod Mod4

#font pango:monospace 8
#font pango:DejaVu Sans Mono 8
font pango:DejaVu Sans, FontAwesome 8

# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod

bindsym $mod+Shift+c reload
bindsym $mod+Shift+r restart
bindsym $mod+Shift+e exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"

bindsym $mod+Shift+q kill
bindsym $mod+Return exec i3-sensible-terminal

#bindsym $mod+d exec dmenu_run
bindsym $mod+d exec --no-startup-id i3-dmenu-desktop

bindsym $mod+j focus left
bindsym $mod+k focus down
bindsym $mod+l focus up
bindsym $mod+semicolon focus right

bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right

bindsym $mod+Shift+j move left
bindsym $mod+Shift+k move down
bindsym $mod+Shift+l move up
bindsym $mod+Shift+semicolon move right

bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right

bindsym $mod+h split h
bindsym $mod+v split v

bindsym $mod+f fullscreen toggle

bindsym $mod+s layout stacking
bindsym $mod+w layout tabbed
bindsym $mod+e layout toggle split

# toggle tiling / floating
bindsym $mod+Shift+space floating toggle

# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle

# focus the parent container
bindsym $mod+a focus parent

# focus the child container
#bindsym $mod+d focus child

set $workspace1 "1  "
set $workspace2 "2  "
set $workspace3 "3  "
set $workspace4 "4  "
set $workspace5 "5  "
set $workspace6 "6  "
set $workspace7 "7  "
set $workspace8 "8  "
set $workspace9 "9  "
set $workspace10 "10  "

assign [class="Geany"]  $workspace1
assign [class="Sylpheed"] $workspace2
assign [class="Opera"]  $workspace3
assign [class="QupZilla"] $workspace4
assign [class="Firefox"]  $workspace4
assign [class="mpv"]  $workspace9
assign [class="Spotify"] $workspace10

new_window none  #borders none
workspace_layout default #default|tabbed|stacking|splitv|splith
#force_display_urgency_hint 2000

for_window [class="mpv"] workspace $workspace9, floating enable, focus
#for_window [class="Spotify"] workspace $workspace10
for_window [class="Gimp"] floating enable
for_window [class="Uzbl-core"] focus child, layout tabbed, focus

bindsym $mod+1 workspace $workspace1, layout splith;
bindsym $mod+2 workspace $workspace2
bindsym $mod+3 workspace $workspace3
bindsym $mod+4 workspace $workspace4, layout tabbed;
bindsym $mod+5 workspace $workspace5
bindsym $mod+6 workspace $workspace6
bindsym $mod+7 workspace $workspace7
bindsym $mod+8 workspace $workspace8
bindsym $mod+9 workspace $workspace9, layout floating;
bindsym $mod+0 workspace $workspace10

bindsym $mod+Shift+1 move container to workspace $workspace1
bindsym $mod+Shift+2 move container to workspace $workspace2
bindsym $mod+Shift+3 move container to workspace $workspace3
bindsym $mod+Shift+4 move container to workspace $workspace4
bindsym $mod+Shift+5 move container to workspace $workspace5
bindsym $mod+Shift+6 move container to workspace $workspace6
bindsym $mod+Shift+7 move container to workspace $workspace7
bindsym $mod+Shift+8 move container to workspace $workspace8
bindsym $mod+Shift+9 move container to workspace $workspace9
bindsym $mod+Shift+0 move container to workspace $workspace10

# resize window (you can also use the mouse for that)
mode "resize" {
        # These bindings trigger as soon as you enter the resize mode

        # Pressing left will shrink the window’s width.
        # Pressing right will grow the window’s width.
        # Pressing up will shrink the window’s height.
        # Pressing down will grow the window’s height.
        bindsym j resize shrink width 10 px or 10 ppt
        bindsym k resize grow height 10 px or 10 ppt
        bindsym l resize shrink height 10 px or 10 ppt
        bindsym semicolon resize grow width 10 px or 10 ppt

        # same bindings, but for the arrow keys
        bindsym Left resize shrink width 10 px or 10 ppt
        bindsym Down resize grow height 10 px or 10 ppt
        bindsym Up resize shrink height 10 px or 10 ppt
        bindsym Right resize grow width 10 px or 10 ppt

        # back to normal: Enter or Escape
        bindsym Return mode "default"
        bindsym Escape mode "default"

bindsym $mod+r mode "resize"

bar {
 status_command nice -n19 i3status -c ~/.config/i3/i3status.conf
 position top
 colors {
  statusline #55BB55

hide_edge_borders both
workspace_auto_back_and_forth yes

#bindsym $mod+z workspace back_and_forth
#bindsym $mod+Shift+z move container to workspace back_and_forth
#bindsym $mod+Shift+z move container to workspace back_and_forth; workspace back_and_forth

bindsym $mod+Tab workspace back_and_forth
bindsym $mod+Shift+Tab move container to workspace back_and_forth

bindsym Mod1+Tab workspace back_and_forth
bindsym Mod1+Shift+Tab move container to workspace back_and_forth

bindsym XF86AudioRaiseVolume exec --no-startup-id amixer -q set Master 2+
bindsym XF86AudioLowerVolume exec --no-startup-id amixer -q set Master 2-
bindsym XF86AudioMute exec --no-startup-id amixer -q set Master toggle

bindsym XF86MonBrightnessUp exec xbacklight -inc 20
bindsym XF86MonBrightnessDown exec xbacklight -dec 20

bindsym $mod+b exec --no-startup-id i3-msg border toggle

bindsym $mod+t exec urxvt -e tmuxj
bindsym $mod+g exec geany, workspace $workspace1;
bindsym $mod+m exec sylpheed, workspace $workspace2;
bindsym $mod+o exec opera
#bindsym $mod+o exec opera, workspace $workspace3;
bindsym $mod+q exec qupzilla, workspace $workspace4;
bindsym $mod+Shift+s exec spotify, workspace $workspace10;

#bindsym $mod+Shift+e exec sh -c '[ $(echo "NO\nYES" | dmenu -sb "#ff6600" -i -p "Really exit i3 X session?") = "YES" ] && i3-msg exit'

exec --no-startup-id "nice -n19 volumeicon"
exec --no-startup-id "nice -n19 wpa_gui -t"
exec --no-startup-id "nice -n19 dunst"
exec urxvt -e tmux

The default i3status config is ~/.config/i3status/config, but I wanted to keep all my i3 stuff together. There's not much there.. just two files.

$ cat ~/.config/i3/i3status
# i3status configuration file.
# see "man i3status" for documentation.

# It is important that this file is edited as UTF-8.
# The following line should contain a sharp s:
# ß
# If the above line is not correctly displayed, fix your editor first!

general {
 output_format = "i3bar"
 colors = true
 interval = 5
 separator = ""
 color_good = "#55bb55"
 color_bad = "#ff0000"
 color_degraded = "#bbbb00"

order += "wireless _first_"
#order += "ethernet _first_"
order += "disk /"
#order += "cpu_temperature 0"
order += "cpu_usage"
order += "load"
order += "volume master"
order += "battery 0"
order += "time"

wireless _first_ {
 format_up = " %bitrate %quality  %essid %frequency"
 format_down = ""

ethernet _first_ {
 ## %speed requires root privileges
 format_up = "E %ip %speed"
 format_down = "E"

disk "/" {
 format = " %avail"
 prefix_type = "custom"
 low_threshold = "1"
 threshold_type = "gbytes_avail"

cpu_usage {
 format = " %usage"

load {
 format = " %1min"

cpu_temperature 0 {
 format = "%degrees °C"
 path = "/sys/devices/platform/coretemp.0/temp1_input"

volume master {
 format = " %volume"
 format_muted = " %volume"
 device = "default"
 mixer = "Master"
 mixer_idx = 0

battery 0 {
 #format = " %status %percentage %remaining %emptytime %consumption"
 format = " %status %percentage %consumption %remaining"
 format_down = ""
 integer_battery_capacity = "true"
 hide_seconds = true
 status_chr = ""
 status_bat = ""
 status_full = "☻"
 path = "/sys/class/power_supply/BAT%d/uevent"
 low_threshold = 10
 threshold_type = percentage

time {
 format = " %b %d %a %R"

ref: i3wm Jump Start, by Alex Booker

softvol boost increase alsa volume

One thing I liked with pulseaudio was increasing the volume to more than 100%. Although audiophiles may disagree, I need to increase the volume beyond 100% so I could hear some movies with low sound particularly voice dialogues.

I missed that feature in alsa. It turns out that this is built-in. Not many know about this, and those who do have issues configuring alsa softvol.

After trawling through much www research, this is what works for me. All one needs is a properly configured ~/.asoundrc file.

$ cat ~/.asoundrc
defaults.pcm.!card 0
defaults.pcm.!device 0
defaults.pcm.!ctl 0

pcm.!default {
    type asym
    playback.pcm "plug:softvol"
    capture.pcm "plug:dsnoop"
pcm.softvol {
    type softvol
    slave.pcm "dmix"
    control { name "PCM"; card 0; }
    #max_dB 32.0
    max_dB 20.0
    min_dB -5.0

Note that this uses PCM as your volume slider. So config your volume hotkeys (or triggers) to manipulate PCM, rather than Master. Set your Master level to 100% or whatever max suitable, and increase/decrease PCM for audio volume.

gentoo portage


Gentoo is Portage. Portage is Gentoo.

Getting the portage settings right is vitally important. It's not the end of the world, if you don't. But you sure will expend a lot of your time staring at the matrix flowing past, as you compile everything yet again one more time.. just to get it right.

I have learnt it the hard way.. Each time I learn what not to do, as opposed to in other systems before. Thankfully, the folks at the gentoo forums have been very helpful each time. If not for them, the gentoo journey would probably not have been worthwhile.

Now that I understand a little bit more, I recompile the whole system, during the installation phase itself, right after I extract stage3 and set my environment. Only then do I install those packages required during/post installation.

Starting with a clean slate lessens any starting troubles. The foundation is probably the most important thing to building the rest of our skyscraper.

During installation, I tweak /etc/portage files to my requirements, and run the following command,
# emerge --e @system
# emerge -c

$ man emerge

--emptytree (-e)
Reinstalls target atoms and their entire deep dependency tree, as though no packages are currently installed. You should run this with --pretend first to make sure the result is what you expect.

--depclean (-c)
Cleans the system by removing packages that are not associated with explicitly merged packages. Depclean works by creating the full dependency tree from the @world set, then comparing it to installed packages. Packages installed, but not part of the dependency tree, will be uninstalled by depclean.
See --with-bdeps for behavior with respect to build time dependencies that are not strictly required.

--with-bdeps < y | n >
In dependency calculations, pull in build time dependencies that are not strictly required. This defaults to ´n´ for installation actions, meaning they will not be installed, and ´y´ for the --depclean action, meaning they will not be removed.

For reference, these are my portage files.

$ cat /etc/portage/make.conf
## gcc -v -E -x c -march=native -mtune=native - < /dev/null 2>&1 | grep cc1 | perl -pe 's/ -mno-\S+//g; s/^.* - //g;'
CFLAGS="-march=native -O2 -pipe -fomit-frame-pointer"
CPU_FLAGS_X86="mmx mmxext sse sse2 sse3 ssse3"

INPUT_DEVICES="evdev synaptics"

LINGUAS="en_GB en"
L10N="en-GB en"


#MAKEOPTS="-s -j4 -l2"
MAKEOPTS="--jobs=3 --load-average=2 --silent"
EMERGE_DEFAULT_OPTS="--alert --ask y --ask-enter-invalid --jobs=2 --keep-going y --load-average 2 --quiet n --tree --unordered-display --verbose y --verbose-conflicts --with-bdeps=y"
PORTAGE_IONICE_COMMAND="ionice -c2 -n7 -p\${PID}"

USE="acpi alsa btrfs drm evdev ffmpeg glamor gstreamer jpeg libnotify minimal opengl png startup-notification threads udev vaapi xcb -X -acl -accessibility -crypt -dbus -debug -deprecated -egl -fortran -gdbm -gnome -gtk3 -introspection -ipv6 -joystick -ncurses -nls -pulseaudio -systemd -xinerama -xv"

$ cat /etc/portage/package.mask

$ /etc/portage/rsync_excludes

$ cat /etc/portage/profile/use.mask

I also replace the package.* directories with files of the same name. For eg,

# cd /etc/portage/
# mv -vi package.use{,.gentoo}
# cat package.use.gentoo/* >>package.use

The currently active USE flags, are the sum of all profiles.
# emerge --info | grep ^USE=

View all portage settings.
# emerge --info

Double check portage settings before starting compile, or it will be recompile everything all over again for each change. Nevertheless and frustratingly, this shall probably happen many times over ;-)

So, we have our settings right, and have rebooted into our gentoo. We probably should update our system.
# emerge --sync
# emerge --update --deep @world

The handbook recommends that we update the build dependencies (packages needed during compile/build process, but no longer required after install), once in a while. I try do this often.
# emerge --update --deep --with-bdeps=y @world

If you have changed any USE settings, portage needs to be told.
# emerge --update --deep --with-bdeps=y --newuse @world

Portage can remove orphaned dependencies, but only after a full update.
# emerge --update --deep --newuse @world
# emerge --depclean
# revdep-rebuild

That last command is from gentoolkit, not part of core gentoo. Another useful tool is eix. Install them like so.
# emerge --ask app-portage/{gentoolkit,eix}

And to remove packages safely:
# emerge --ask --depclean app-portage/eix

emerge -auvND world does not upgrade everything.
emerge -auvND --with-bdeps=yes world will attempt to upgrade build-time dependencies. run once a month or so.
emerge -e system maybe once or twice a year.

dash system & login shell

dash is more efficient than bash in all respects, except perhaps for interactive use. and i always replace system default and login shells with dash.

$ cd /bin
# ln -sf dash sh

# usermod -s /bin/sh root

i faced a particular problem in gentoo.

after the rebooting the just installed system, i couldn't login as root to finish installing the rest of the system. i finally gave up and trashed the system.

i wiped the disk clean, and re-installed yet again from scratch. all i wanted to check was that i could login. what's the purpose of installing a fabulous system, if you can't login? so i left most other install tasks/config for later. i could successfully login!

now i moved on with what i normally do to my systems, just to finish up and find that i could not login!

i rememembered that the last thing i did was to replace my system default and login shells with dash. so i undid that. bash became the default again. and i could login!

the problem was isolated to dash as login shell!

further troubleshooting narrowed down the issue to login shell only. gentoo was fully working with dash as the system default shell.

my research led me to the ever helpful gentoo forums, and this post.

indeed, gentoo does not list /bin/dash in /etc/shells. problem solved!

# echo /bin/dash >>/etc/shells

gentoo second install x86 btrfs debian

Now that my Gentoo Phase 2 has been put on hold for the near future, I have to satisfy this itch to install gentoo on my main laptop. Having it on my primary rig, would allow me to use it more often than pulling out my backup system.

My blind first attempt, at a gentoo install, gave me a lot of confidence in the gentoo community. This second attempt substantially lessens the time/aggro I spent previously installing gentoo.

I significantly pruned the install path from my previous gentoo install process, removing many distractions. I could have just copied over those btrfs subvolumes, but I wanted to start clean.

Beware if you systemd, don't just blindly follow this.

Install Environment

This time I start from my running debian. I have a working environment, networking and x-browser. No faffing about with any install disks etc. And I can continue working without downtime, while gentoo/emerge is crunching cpu/disk.

You may follow this, installing from your own distro.


I like btrfs - cow, subvolumes, snapshots. I have subvolumes for each os. I create new ones for this gentoo install, and use a few other existing ones.

# mount -L os /media/os
# btrfs subvolume create /media/os/@gentoo32
# btrfs subvolume create /media/os/@portage

The gentoo handbook refers to /mnt/gentoo. So we mount our subvolumes there.

# mkdir -p /mnt/gentoo
# mount -L os -o defaults,relatime,compress=lzo,subvol=@gentoo32 /mnt/gentoo/

I will use other subvolumes after this install completes to my satisfaction, as I don't want any accidents. This also keeps it simple & straightforward, with everything on one subvolume.


Download, verify & extract latest gentoo stage3. I use /tmp as working directory, as we won't need those files later.

$ cd /tmp
$ wget{yyyymmdd}.tar.bz2
$ wget{yyyymmdd}.tar.bz2.DIGESTS
$ sha512sum -c stage3-*.tar.bz2.DIGESTS
# tar --numeric-owner --xattrs -xvapf stage3-*.tar.bz2 -C /mnt/gentoo/

I downloaded a 228M file, which extracted 860M. So be patient..


mount required psuedo filesystems
# mount -o bind /proc /mnt/gentoo/proc
# mount --rbind /sys /mnt/gentoo/sys
# mount --make-rslave /mnt/gentoo/sys
# mount --rbind /dev /mnt/gentoo/dev
# mount --make-rslave /mnt/gentoo/dev
# mount --rbind /run/shm /mnt/gentoo/run/shm

Anything outside chroot will be inaccessible.

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

Enter the chroot

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

my favourite editor :-)
# ln -s /bin/busybox /usr/local/bin/vi

ref: gentoo portage

Do yourself a favour, and ignore everything the handbook says about portage.. for now!
Learning everything about portage is really really useful, but not during installation. Particularly, if you are a gentoo newbie.

Install the latest portage snapshot, with all the above settings.
emerge-webrsync -q

/usr/portage is created during this first run. Ignore all those warnings..

This will take time.. be patient ;)


$ man news.eselect
$ eselect news list
$ eselect news read [number]

Action the relevant news items. Do your own research though. I got news items too old, and although relevant, not completely correct either.


$ ls /usr/share/zoneinfo
# echo "Europe/London" >/etc/timezone
# ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime


$ cat /etc/locale.gen
en_GB.UTF-8 UTF-8

Each locale should be on a separate line. Atleast one should be UTF-8.

# locale-gen
$ locale -a
$ eselect locale list
# eselect locale set {number}

$ cat /etc/env.d/02locale

Reload environment, after changes.
$ env-update && source /etc/profile && export PS1="(chroot)$PS1"


No kernel is installed. We make our own.
ref: gentoo kernel

I moved the kernel section up ahead this time. While the kernel compiles, we continue the rest of the install..
on another terminal :) Enter chroot, and reload environment.


$ cat /etc/fstab


Gentoo utils are best in class. I use netifrc. Busybox udhcpc automatically for all configured interfaces.

My wireless card wasn't detected without lspci.
$ emerge --search pciutils
# emerge --ask sys-apps/pciutils

Configure interfaces
# ln -s /etc/conf.d/net.{lo,wlp3s0}

I need iw and wpa_supplicant.
ref: wpa_supplicant
# emerge --ask net-wireless/{wpa_supplicant,iw}

# vi /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel

# wpa-passphrase {ssid} {password} >>/etc/wpa_supplicant/wpa_supplicant.conf

# vi /etc/conf.d/hostname

# vi /etc/hosts localhost.localdomain localhost {hostname}

# vi /etc/conf.d/keymaps

root passwd
# passwd


No bootloaders to be installed in this instance, as I use an existing one and add another entry in wheezy's /etc/grub.d/

menuentry "@gentoo32/vmlinuz" {
  set gfxpayload=auto
  set rtlbl=os
  set subvol=@gentoo32
  search --no-floppy --set root --label $rtlbl
  set bootoptions="root=LABEL=$rtlbl ro rootfstype=btrfs rootflags=defaults,noatime,compress=lzo,subvol=$subvol quiet"
  linux /$subvol/vmlinuz $bootoptions
  initrd /$subvol/initrd.img

ensure you have the corresponding filesystem tools.

# emerge --ask sys-fs/btrfs-progs

Don't forget the other terminal.. and finish installing the kernel & initramfs!

Exit the chroot

# exit
# reboot

gentoo phase 2

My first attempt boosted confidence in gentoo (and it's community) beyond expectation. So much that the debian to gentoo transition continues to gather pace.

In all my systems, I have always replaced the full fledged (bloatware?) tools with minimal busybox, wherever I could. Busybox is stable, and fulfils all my requirements rather nicely. This led me to voidlinux which has that same ethos in it's core. It is a great booster that gentoo could satisfy me on this count too.

I am quite a fan of minimal systems. Any features over and above that I actually use is bloatware. A perfect efficient system is one from which you can't take out anything more, rather than one you can't add anything more.

So the next phase of my gentoo adventure continues.. with gentoo uclibc on my main rig. Will this satisfy my minimal tendencies?

Update: Gentoo wiki tells me that uClibc is a dead project now, and migration to uClibc-ng begins 01-Oct-2016. Unfortunately, there is no simple migration path.

So this Phase 2 goes on hold till then, and perhaps a bit later as i watch from the sidelines for initial hiccups. I am not really a fan of bleeding-edge.

most popular posts