Archive for August, 2015

[manjaro] install a new TTF font

August 31, 2015 2 comments

I found a nice TTF font at (reddit discussion here). How to install it?

Download the .ttf version and copy them to the /usr/share/fonts/TTF folder. Then update the font cache:

root$ fc-cache && mkfontscale && mkfontdir

I wanted to try it in Yakuake but first I had to restart Yakuake. Then this font appeared in the font list.

Other nice fonts for coding IMO: Consolas.

Categories: manjaro Tags: ,

10 Reasons to Upgrade to Ubuntu 15.04 (parody of a Windows 10 advertisement)

August 24, 2015 Leave a comment

And here is the original:

Found it on reddit.

Categories: fun, linux, windows 10 Tags:

Midnight Commander: remember directories on the left and right sides when you quit

August 21, 2015 5 comments

When you suffer enough, you will want to change. Nobody likes suffering. I’m a huge fan of MC but one thing troubled me for months: when I quit MC and restart it, it doesn’t remember the last directories in the left and right panels.

As it was driving me crazy, finally I decided to look after the problem. As usual, the solution was just 1 minute away.

A quick Google search dropped out this thread. That is:

Menu->Options->Panel options...
[x] Auto save panels setup
Categories: linux Tags: , , ,

[manjaro] compile MongoDB from source and install it manually

August 20, 2015 3 comments

I wanted to install MongoDB on an old 32-bit laptop of mine. After installing it from the official repository, the mongo shell died with the following error: ” Illegal instruction (core dumped)”.

The problem is that the binary file uses an instruction set that is not supported by my old 32-bit CPU:

$ cat /proc/cpuinfo | grep flags
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov clflush dts acpi mmx fxsr sse sse2 ss tm pbe nx bts est tm2

SSE3 is missing :( What to do? Uninstall the mongodb package and 1) compile it from source, 2) install it and 3) make it start at startup.

(1) Compile the source
I found an excellent blog post about it at . Here I would sum up the steps.

Download the source from here: . It’s about 35 MB. The source uses the SCons build system, so install the “scons” package too. Note that the compilation process took about 6 hours on my old laptop and the work directory where compilation was being done grew to 18 GB! I didn’t have that much free space so I had to move this work directory to an external HDD :) However, when you install the binaries, they will only occupy 90 MB.

So, if you have an old CPU, edit the file SConstruct:

        if using_gcc() or using_clang():
                myenv.Append( CCFLAGS=['-march=pentium3', '-mtune=generic'] )
                #myenv.Append( CCFLAGS=['-march=nocona', '-mtune=generic'] )

The target architecture “nocona” was replaced by “pentium3”. Again, this tip is from Karl.

After this you can start the compilation and wait :)

$ scons --disable-warnings-as-errors --32 all

The blog post at stops at this point.

(2) Install the binaries
I installed the binaries to /opt:

$ scons --prefix=/opt/mongo-3.0.5 install

Of course, replace “3.0.5” with your current version. I also put a symbolic link on this folder:

$ cd /opt
$ ln -s mongo-3.0.5 mongo

Note that the binaries are put into a “bin” folder, thus they are located in “/opt/mongo-3.0.5/bin/“.

Now put symbolic links in /usr/bin/ that point to the appropriate binaries in /opt/mongo/bin/. They look like this on my machine:

$ cd /usr/bin
$ ls -al | grep mongo
lrwxrwxrwx  1 root root         20 11.08.2015 08:30 mongo -> /opt/mongo/bin/mongo
lrwxrwxrwx  1 root root         21 11.08.2015 08:31 mongod -> /opt/mongo/bin/mongod
lrwxrwxrwx  1 root root         24 11.08.2015 08:31 mongoperf -> /opt/mongo/bin/mongoperf
lrwxrwxrwx  1 root root         21 11.08.2015 08:31 mongos -> /opt/mongo/bin/mongos
lrwxrwxrwx  1 root root         25 11.08.2015 08:31 mongosniff -> /opt/mongo/bin/mongosniff

(3) Make MongoDB start at startup
Create these two directories: /var/lib/mongodb and /var/log/mongodb . The mongo daemon shouldn’t run with root privileges, so we create a dedicated user for this purpose and set its password:

$ sudo adduser mongodb
$ sudo passwd mongodb

Now, the owner of the previously created two folders will be “mongodb“, and they will belong to the “daemon” group. Example on my machine:

$ cd /var/log
$ ls -al | grep mongodb
drwxr-xr-x  2 mongodb daemon            4096 11.08.2015 09:29 mongodb/

Use the chown and chgrp commands.

After this, you need to copy some config files as root. They are collected here.

First, create /etc/mongodb.conf . Mine looks like this:

# See for format details
# Run mongod --help to see a list of options

bind_ip =
quiet = true
dbpath = /var/lib/mongodb
logpath = /var/log/mongodb/mongod.log
logappend = true

noprealloc = true
smallfiles = true

Next, create /usr/lib/systemd/system/mongodb.service . Sample:

Description=High-performance, schema-free document-oriented database

ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf


Now it’s time to enable and start the mongodb service:

$ systemctl enable mongodb.service
$ systemctl start mongodb.service

Verify if it’s running:

$ systemctl status mongodb.service

If it seems OK, try to connect to it with the mongo shell using the command “mongo“.

If the service doesn’t start with the systemctl command, then try to launch the server manually:

$ mongod --quiet --config /etc/mongodb.conf

You may want to remove the “--quiet” option. If it has some problems, it will print a more detailed error message than “systemctl start...“.

I wrote this post one week after I installed MongoDB, but I hope I didn’t forget any steps. Good luck!

Update (20160109)
For compiling version 3.2.0, I used the following steps:

scons --wiredtiger=off --disable-warnings-as-errors mongo mongod
strip mongo
strip mongod

The compilation was too long, so I narrowed it down to mongo and mongod only. The resulting binaries were huge, but the command strip did the trick by removing the debug symbols.

Categories: bash, linux Tags: , , , ,

mongo shell: WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’

August 11, 2015 Leave a comment

You start the mongo shell (with the command “mongo“) and you get some warnings:

MongoDB shell version: 3.0.0
connecting to: test
Server has startup warnings:
2015-03-13T16:28:29.405+0800 I CONTROL  [initandlisten]
2015-03-13T16:28:29.406+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2015-03-13T16:28:29.406+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-13T16:28:29.406+0800 I CONTROL  [initandlisten]
2015-03-13T16:28:29.407+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2015-03-13T16:28:29.407+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2015-03-13T16:28:29.407+0800 I CONTROL  [initandlisten]

How to get rid of these warnings?

This issue is addressed at . Here they explain what to do under Ubuntu.

Update (20160329): The method above didn’t work for me under Ubuntu 14.04 with Mongo 3.2.4. Here is method that did work: It should also work with Manjaro, so first try this trick.

But what about Manjaro? ;)

First, follow the steps of this post: . Here it is explained how to create a script that is executed at startup. When ready, go on with the following operations:

Create the file /etc/rc.d/disable-transparent-hugepages with this content (copied from here):

#!/usr/bin/env sh

# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.

case $1 in
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      return 0

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    unset thp_path

Make it executable (chmod u+x). Then edit /etc/rc.d/rc.local and add the previous script to it. Mine looks like this:

#!/usr/bin/env bash

/etc/rc.d/disable-transparent-hugepages start

Next time you reboot and start mongo you won’t see the warnings.

Categories: mongodb Tags: ,

[manjaro] run a command at startup as root

August 11, 2015 2 comments

Manjaro (and Arch) uses systemd as a system and service manager, which differs from Ubuntu’s upstart. Under Ubuntu it is enough to edit /etc/rc.local and those commands are executed upon boot. How to mimic this functionality with systemd?

I found a nice solution in this thread, posted by patroclo7. Here I just copy his solution.

Create the file /etc/rc.d/rc.local and make it executable (chmod u+x). In this file add the command(s) you want to execute at startup.

Then, create a service file for rc.local in /etc/systemd/system/rc-local.service with this content:

Description=/etc/rc.local compatibility



Finally, enable it:

systemctl enable rc-local

Now if you reboot, the commands in rc.local will be executed with root privileges.


Categories: manjaro Tags: , ,

[manjaro] ignore package update

August 9, 2015 1 comment

I installed vuze from AUR but vuze keeps updating itself. When a new version appeared in AUR, I tried to update the vuze package but it failed due to file conflict. Since vuze is actually up-to-date, there is no need to update it from AUR, and I don’t want to see any messages from the package manager either to update this package.

Put this package on an ignore list and thus the package manager won’t want to update it.

Open /etc/pacman.conf and add this line:

IgnorePkg = vuze

You can also specify several packages separated by a space. Both pacman and yaourt will ignore this (these) package(s).

Categories: manjaro Tags: , ,