Archive

Archive for August, 2015

[manjaro] install a new TTF font

August 31, 2015 2 comments

Problem
I found a nice TTF font at https://github.com/chrissimpkins/Hack (reddit discussion here). How to install it?

Solution
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

Problem
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.

Solution
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

Problem
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)”.

Solution
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 http://kdenby.homelinux.com/?p=25 . Here I would sum up the steps.

Download the source from here: https://www.mongodb.org/downloads . 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 http://kdenby.homelinux.com/?p=25 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 http://www.mongodb.org/display/DOCS/File+Based+Configuration for format details
# Run mongod --help to see a list of options

bind_ip = 127.0.0.1
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:

[Unit]
Description=High-performance, schema-free document-oriented database
After=network.target

[Service]
User=mongodb
ExecStart=/usr/bin/mongod --quiet --config /etc/mongodb.conf

[Install]
WantedBy=multi-user.target

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“.

Troubleshooting
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

Problem
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?

Solution
This issue is addressed at http://docs.mongodb.org/manual/tutorial/transparent-huge-pages/#transparent-huge-pages-thp-settings . 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: http://stackoverflow.com/a/29181918/232485. It should also work with Manjaro, so first try this trick.

But what about Manjaro? ;)

First, follow the steps of this post: https://ubuntuincident.wordpress.com/2015/08/11/manjaro-run-a-command-at-startup-as-root/ . 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

### BEGIN INIT INFO
# 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.
### END INIT INFO

case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

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

    unset thp_path
    ;;
esac

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

Problem
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?

Solution
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:

[Unit]
Description=/etc/rc.local compatibility
ConditionFileIsExecutable=/etc/rc.d/rc.local

[Service]
Type=oneshot
ExecStart=/etc/rc.d/rc.local
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99

[Install]
WantedBy=multi-user.target

Finally, enable it:

systemctl enable rc-local

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

Credits

Categories: manjaro Tags: , ,

[manjaro] ignore package update

August 9, 2015 1 comment

Problem
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.

Solution
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: , ,

turn off annoying YouTube annotations

August 9, 2015 Leave a comment

Problem
YouTube annotations are driving you crazy.

Solution
Turn ’em off for good. Follow these simple steps: http://www.businessinsider.com/turn-off-youtube-annotations-for-good-2014-8 .

Categories: tips Tags: , ,

I switched to Manjaro Linux on my main machine

August 6, 2015 1 comment

I bought an SSD and installed it last week in my main machine at home. I had Ubuntu 12.04 LTS on it before but I decided to put Manjaro on the new drive. Why the switch?

As I have several machines to maintain, a few years ago I decided to only use LTS releases of Ubuntu. I was fed up with installing new releases on about 8 machines in every 6 months. With the LTS everything is peaceful for 2 years :) However it also means that I don’t get the hot stuff, I need to wait for the next LTS release.

I met Manjaro less than a year ago when I installed it on an older laptop of mine. I played with it and it turned out to be a very nice system. It has several advantages:

  • It is based on Arch, but much easier to install. The relation between Arch and Manjaro is somewhat similar to Debian and Ubuntu.
  • Manjaro uses a rolling release model, which means a continually developing software system. In the case of Ubuntu when a new release comes out, you need to reinstall it over the previous version. Rolling software, instead, is continually updated, in contrast to standard release software which is upgraded between versions. (source) Thus, you install Manjaro once and you are done. Just update it regularly and you have an up-to-date system. When a new release comes out, you have nothing to do. Thanks to the regular updates you have the latest version.
  • Its package manager is very easy to use. For instance, it’s enough to execute “yaourt -Syua” to keep my system updated.
  • The AUR (Arch User Repository) is a community-driven software repository. It is similar to Ubuntu’s PPA but much easier to use. Just select a package and install it with a command. PPAs need to be imported first.
  • Fast, easy to install, easy to use. I also have Windows 7 on my machine but its installation with all the updates took almost a day. Manjaro and its updates were installed in 30 minutes. Windows 7 occupies 40 GB after a clean install. Manjaro needs about 7 GB. Since last week I’ve installed several other softwares but its size is still 14 GB.

It took me a few days to configure everything, but now I can do anything that I could do with Ubuntu.

The blog will go on under the same name (“The Ubuntu Incident”), don’t worry. I still use Ubuntu at my workplace for instance :) But expect more posts on Manjaro in the future.

Categories: linux Tags: , , ,

Xfce shortcuts

August 3, 2015 Leave a comment

Start -> Settings Manager -> Window Manager -> Keyboard.

Minimize all windows: Ctrl + Alt + D.

Update (20150806)
Under Ubuntu if you press the PrtScn button, an application starts that allows you to take a screenshot. How to have the same thing in Xfce? First, install the program xfce4-screenshooter. Then add a new application shortcut:

Start -> Settings Manager -> Keyboard -> Application Shortcuts tab.

Add xfce4-screenshooter and assign the PrtScn button to it.

Categories: manjaro Tags: , ,