Gentoo vmware-player and systemd

Gentoo has moved into systemd for those who are using Gnome3 – systemd is mandatory – But not all services from sysVinit or openrc have the new .service files needed for systemd. Vmware player, a closed source virtualization solution still doesn’t has the files, being necessary to create one.

After digging a while, I found the solution.

The old vmware-player sysVinit file just started the network – we’re going to replicate this with a vmware.service file systemd style

As root, go to /usr/lib/systemd/system (if you’re in x86_64 system, lib will be a symlink to lib64) and create the .service file

cd /usr/lib/systemd/system
vi vmware.service

Put the following lines in it

Description=VMware Network
ExecStart=/opt/vmware/bin/vmware-networks --start 
ExecStop=/opt/vmware/bin/vmware-networks --stop

Save the file.

Enable the service

systemctl enable vmware.service
ln -s '/usr/lib64/systemd/system/vmware.service' '/etc/systemd/system/'
systemctl start vmware.service

Check the status:

systemctl status vmware.service 
vmware.service - VMware network 
 Loaded: loaded (/usr/lib64/systemd/system/vmware.service; enabled) 
 Active: active (exited) since Fri 2014-02-14 10:00:23 WET; 3min 17s ago 
 Process: 19708 ExecStart=/opt/vmware/bin/vmware-networks --start (code=exited, status=0/SUCCESS) 
 Main PID: 19708 (code=exited, status=0/SUCCESS)
Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: Internet Software Consortium DHCP Server 2.0 
Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: Copyright 1995, 1996, 1997, 1998, 1999 The Internet Software Consortium. 
Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: All rights reserved. 
Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: Please contribute if you find this software useful. 
Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: For info, please visit 
Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: Configured subnet: 
Feb 14 10:00:24 nightraider vmnet-dhcpd[19764]: Setting vmnet-dhcp IP address: 
Feb 14 10:00:24 nightraider vmware-networks[19708]: Started Bridge networking on vmnet0

That’s it ! Now you have vmware starting with systemd


Arch Linux forums for the .service file

Solving thumbnails problems in Gnome

Sometimes, Gnome doesn’t show the thumbnails, whether for videos or pictures.  It can be by the lack of a thumbnailer, but almost because the location of the thumbnails folder has changed !

Now, the thumbnails are stored under the .cache folder.

To solve the problem, just follow these steps:

  1. Go to your cache folder : cd .cache
  2. Create a symbolic  link to the folder (.)thumbnails in your home folder:  ln -s ../.thumbnails thumbnails
  3. You now get a link in .cache to thumbnails:thumbnails -> ../.thumbnails/

Open Nautilus and see the previews appear !


Firefox new tab page as home page

Firefox is an amazing browser, and it’s getting better and better.

What i love most is the “new tab” page, where it lays down the nine most visited pages.


The problem is, Firefox startup options doesn’t has any  to put the same page as our home page.


But there is a small trick we can use. Opening a new tab, the page we want appears. We can use the right mouse button and click it.  Choose “view page info”.

A new window appears with some details about the page.  You can see the address – about:newtab -

Now, returning to the Firefox Startup options, choose “Show my home page” and in the URL box bellow, just type : about:newtab

Now, every time you press the home button or open firefox, the tabs page will be your home page.

Install and configure moodle in CentOS 6.3 with video streaming and recording

Moodle is a E-learning platform free as in free beer. Moodle is a CMS (Course Management System) and also known as a LMS (Learning Management System) or a VLE (Virtual Learning Environment).

I was in need to install a configure a system like this and I’ve chosen Moodle not also because is one of the best out there, but because is also free.

One of the key features that i was also needing was a video streaming and recording facility.  Moodle has it all (through plugins).

What I’m going to describe here is an installation of Moodle from the very beginning:
Continue reading

Using gnome nautilus as ssh and smb gui

Everyday i use ssh in the command line to administrative tasks and the need to copy files is big. I’m comfortable using the command line and at any given time, i have 4 and 5 consoles open but sometimes it’s nice to have a GUI for some tasks (when the character set of one system is not the same and all the accentuated characters do not display correctly and scp has an hard time dealing with it).

I wounder if Linux had such a tool like WinSCP. I sometimes (only when absolutely needed and work related) use windows and WinSCP comes handy.

If you use Gnome, you don’t need a GUI, because Nautilus has support for several protocols. I use Samba when i need to connect to Windows computers, and Nautilus is my tool.

When in Nautilus, if you press Ctrl+L (the L is not in  caps. I type it in caps just for readability) , it opens a location text bar so you can type where you want to go.
Continue reading

How to connect Android (ICS and JB) to Linux for file access

Since Android switch from mass storage to MTP, it’s being hard to connect an Android phone to Linux and use it to browse files. I had that problem every single day, having to resort to another choices.

I’ve tried this on Gentoo Linux and Ubuntu 12.04, but I guess it should work on any distribution.

Since using mass storage, two partitions cannot be mounted simultaneously, Android developers switch to MTP. Here’s a better explanation

Some parts of this tutorial have been borrowed from here:

Most credits should go to Bilal Akhtar (from

What I’ve did was taken a step further. Since udev can execute scripts automatically, why not use udev to manage most of the operations?

Note: unless specified, all commands are to be run as the root user (or if you use sudo, just prepend sudo to the commands)

Install packages

For this to work, we’ll rely on fuse and libmtp


apt-get install mtp-tools mtpfs


emerge -av sys-fs/fuse sys-fs/mtpfs media-libs/libmtp

Go to /media (or /mnt) and create a folder with a relevant name for the device

cd /media

mkdir AsusFT201

We’re doing this because udev only knows about the removed device when you actually remove it and that’s is not good to remove the device without first umount it. Here’re going with Bilal Akhtar solution (references in the bottom of the document) and have an alias to umount the device

Now, on the computer, run the following command:

tail -f /var/log/messages (or tail -f /var/logo/syslog on Ubuntu)

Now connect your device to the computer. In your device, make sure to select “Media device (MTP)”

The kernel messages after connecting the device:

Oct 8 16:43:27 nightraider kernel: [ 5263.446971] usb 1-3: default language 0×0409
Oct 8 16:43:27 nightraider kernel: [ 5263.447477] usb 1-3: udev 11, busnum 1, minor = 10
Oct 8 16:43:27 nightraider kernel: [ 5263.447479] usb 1-3: New USB device found, idVendor=04e8, idProduct=6860
Oct 8 16:43:27 nightraider kernel: [ 5263.447481] usb 1-3: New USB device strings: Mfr=2, Product=3, SerialNumber=4
Oct 8 16:43:27 nightraider kernel: [ 5263.447483] usb 1-3: Product: SAMSUNG_Android
Oct 8 16:43:27 nightraider kernel: [ 5263.447484] usb 1-3: Manufacturer: SAMSUNG
Oct 8 16:43:27 nightraider kernel: [ 5263.447486] usb 1-3: SerialNumber: 111X1111XY11111Z
Oct 8 16:43:27 nightraider kernel: [ 5263.447552] usb 1-3: usb_probe_device
Oct 8 16:43:27 nightraider kernel: [ 5263.447555] usb 1-3: configuration #1 chosen from 2 choices

SerialNumber is the line we’re looking for.

With this value, let’s create the udev rules.

create the following file:

(I use vi, you can use emacs or gedit. Still, you don’t know what you’re missing by not trying vi)

vi /etc/udev/rules.d/81-android.rules

Read here why the file is called 81-android.rules

and add the following lines (replace 111X1111XY11111Z with the serial with your device):

SUBSYSTEM==”usb”, ATTRS{serial}==”111X1111XY11111Z”, MODE=”0666″, GROUP=”plugdev”, SYMLINK+=”AndroidPhone”, RUN+=”/usr/bin/mtpfs -o allow_other /media/ AsusFT201″


The full path of the commands is necessary. Read the udev manual for more information

I went with serial because it is unique and I’ve seen the idDevice change in the same computer. – can someone confirm if this is possible ?

Now save and quit the editor.

Reload the udev rules:

udevadm control –reload-rules

Now, edit /etc/fuse.conf and remove the comment from the last line (just delete the ‘#’)





Add yourself to the fuse group (if not already)

To find out, type:

id (as your user)

uid=1000(username) gid=1000(username) groups=1000(username),4(adm),24(cdrom),27(sudo),29(audio),30(dip),44(video),46(plugdev),60(games),105(fuse),109(scanner),111(lpadmin),115(netdev),124(sambashare),1012(sharing),1013(bumblebee)

If you don’t have the group in your list, just run the following command:

gpasswd -a <your_username> fuse
Adding user <your_username> to group fuse

On Gentoo you need to add your user to the group disk

The command is the same, just replace fuse with disk

You need to logout and login again for it to take effect (if not in the group)

After that, just plug your device and wait a bit. I’m saying wait a bit because for me, my phone (with ICS) and my tablet (with JB) take a while to mount. Don’t know why. This happens in both distributions.


To unmount the device, just edit your .bashrc file (in your home) and add the following lines:

vi ~/.bashrc

Give it the name you want – replace android-disconnect

alias android-disconnect=”fusermount -u /media/AsusFT201″

Save and quit

Now, execute the command:

source ~/.bashrc

Now you can remove the device issuing the command android-disconnect


DHCP failover / load balancing (and synchronization) with CentOS 6

DHCP is a wonderful piece of software. It keeps our networks running smoothly. For small networks, probably 100 machines or so, one server is enough, but to larger networks, is not a bad idea to have another one, just in case the firts one fails or the load is just to much..

DHCP has some configurations for load balancing and failover, the – failover declaration – that allows us to configure it.

The Servers:

Primary IP address:

Secondary IP address:

To keep things simple, you can create a new file, and then just insert it in the global dhcpd.conf (configuration below)

Primary DHCP server

Open a new file and put the following lines in it:

vi /etc/dhcp/dhcpd.failover

# Failover specific configurations

failover peer “dhcp” {
port 647;
peer address;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
mclt 600;
split 128;
load balance max seconds 3;
Now, in the secondary DHCP server, just to the same:
Secondary Server
failover peer “dhcp” {
port 647;
peer address;
peer port 647;
max-response-delay 60;
max-unacked-updates 10;
load balance max seconds 3;
After creating the files, just add the configuration to the global config file (in both servers), somewhere before (groups | share networks | host) definitions
include “/etc/dhcp/dhcpd.failover”;
Now, to the definitions.
To take advantage of the new definitions, we need to create a pool. You can put it in any (subnet| shared-network|etc..) declaration:
network netmask {
option routers;
option subnet-mask;
option broadcast-address;
pool {
failover peer “dhcp”;
Note: If you have static declarations (i have all my clients in static declarations), to avoid warnings in the log about dynamic and static mappings, reduce the range to only one client. It’s mandatory the range declaration
IMPORTANT: Is of utmost importance to have both servers with the same date and time. If they are not, DHCP will complain and the secondary server (the whole server) will not work well… You can accomplish this with ntpdate
If you are getting this messages in syslog:
Failover CONNECT to dhcp rejected: Connection rejected, time mismatch too great.

Then the time is not the same.

If you want to know more about the configuration parameters in the failover declarations, go to the ipamworldwide web site
DHCP doesn’t have a synchronization mechanism (as far as i know – please correct me if i’m wrong), so changes you’ll make to the primary server will not reflect in the secondary server. This could be done using scripting or yourself manually copying the changed file over to the secondary server. But sometimes, in the heat of the moment, because something important happened or someone is waiting for your attention, you forget…
There’s a small program that can accomplish the synchronization without you even remember that you must copy the files…
iwatch is a small program that monitors wherever you want (files, directories) and upon changes, it can perform several actions.
A few months ago i wrote about iwatch and how’s installed and configured (portuguese), but i’ll replicate the steps here, using the DHCP files has an example.
The CentOS minimal installation doesn’t have rsync and wget installed, so we need to install those.
yum install rsync wget
Note: The steps above are only required in the primary server. The changes are made here and then replicated to the secondary server.
Install the rpmforge repositories. You can get the rpm and instructions here
Install the required perl packages
yum install perl-Event perl-Mail-Sendmail perl-XML-SimpleObject perl-XML-Simple perl-Linux-Inotify2
After installing, we can finally install iwatch.
Download it from sourceforge
After download, untar it:
tar -zxvf iwatch-0.2.2.tgz
A new directory is created
cd iwatch
In there, you’ll find a few files.
Let’s copy the files to the proper places
cp iwatch /usr/local/bin/
cp iwatch.xml /etc/
cp iwatch.dtd /etc/
A few considerations before continuing:
We want to synchronize changes in the DHCP configurations, so, we’ll monitor the /etc/dhcp directory for:
  • Creation of files
  • changes in files
  • deleting of files
  • add an exception for dhcpd.failover (those are different in the servers – depending of primary or secondary server)
Now that we know what we want, let’s proceed:
Before we edit the configuration file, so we can execute iwatch as a daemon, let’s execute it in command line and edit a file so we can see what’s happening. Open two terminals: One will be used to execute iwatch and some arguments, the other will be to edit a file.
First terminal:
Execute iwatch and see some output:
/usr/local/bin/iwatch -e modify,create,close_write -c “touch /tmp/someaction” -r -v /etc/dhcp/

Watch /etc/dhcp
Watch /etc/dhcp/Configs
Watch /etc/dhcp/dhclient.d

Second terminal
Let’s edit a file in the watched directory and see what’s happening in terminal 1. You can just open it, no changes, but save the file and watch the output in Terminal 1.
vi /etc/dhcp/dhcpd.conf
In terminal 2, you’ll see:
[14/Mar/2012 16:18:34] IN_CREATE /etc/dhcp/Configs/.dhcp.vlan.swp
[14/Mar/2012 16:18:34] * Command: touch /tmp/someaction
[14/Mar/2012 16:18:34] IN_CREATE /etc/dhcp/Configs/.dhcp.vlan.swx
[14/Mar/2012 16:18:34] * Command: touch /tmp/someaction
[14/Mar/2012 16:18:34] IN_CLOSE_WRITE /etc/dhcp/Configs/.dhcp.vlan.swx
[14/Mar/2012 16:18:34] * Command: touch /tmp/someaction

Now that we saw it working, let’s configure the daemon part.

Edit the file /etc/iwatch.xml. The file syntax is XML. Here’s an example of my configuration.
You can read more in iwatch sourceforge page.
<?xml version=”1.0″ ?>
<!DOCTYPE config SYSTEM “/etc/iwatch.dtd” ><config charset=”utf-8″>

<guard email=”” name=”IWatch”/>


<title>DHCP Sync</title>
<contactpoint email=”” name=”Administrator”/>
<path type=”recursive” syslog=”on” alert=”off” events=”create,delete,close_write” exec=”/root/scripts/syncFiles”>/etc/dhcp</path>
<path type=”regexception”>b4913b</path>
<path type=”exception”>/etc/dhcp/dhcpd.failover</path>
<path type=”exception”>/etc/dhcp/dhclient.d</path>

<path type=”regexception”>.*.swp*</path>

<path type=”regexception”>.*~</path>



Now, edit that file and make the changes you want

I’ve added a few exceptions, because there are files i don’t need to sync.

Also, vi creates a few temporary files (directory 4913 and backups with ~ | swp extensions) when you’re editing, and those don’t mind.

We are not also using modify, because if a file is closed with write, it was modified, right ?

The exec  parameter tells iwatch what to do when any of the events occurs. I have a script (syncFiles) that synchronizes with the secondary server and sends and email

# Script to synchronized dhcp changes
# This script will be called by iwatch
# 15/12/2011
echo “Syncing dhcp from primary server to secondary server” >> $log
# Using rsync so it can only copy different files – Low on bandwith/usr/bin/rsync -avz –delete -e ssh /etc/dhcp/ –exclude dhcpd.failover root@secondary:/etc/dhcp >> $log
# Restart the service with the new configurations
ssh root@secondary -C “service dhcpd restart” >> $log
service dhcpd restart >> $log
# Email
if [ -a $log ]; then
mail -s “Sync dhcp ” < $log
rm -f $log

I use rsync to perform the copy. I exclude dhcpd.failover because the files are not the same and they depend on the server (primary or secondary)

Notes: A few security issues. iwatch is executed with root privileges – it’s started by /etc/rc.local

If you do nothing, every time the script is executed, you’ll have to give the root password of the secondary server. You can prevent this (if you want) by adding the ssh key to the authorized keys and have a password-less ssh configuration between those two servers (using only keys)

Now, just put iwatch executing when the machine start:

vi /etc/rc.local
# Exec iwatch
/usr/local/bin/iwatch -d

Execute iwatch as daemon

/usr/local/bin/iwatch -d

Now you have a dhcp failover instalation and synchronization

Hope it helps anyone


Install logwatch Centos 6

Logwatch is a wonderfull Linux tool that informs us (by email if you like) to what happened to a server during the previous day (configurable).

EDIT: I’ve just tried with CentOS 6.3 minimal install, with the default mirrors configured and logwatch (yum install logwatch) installed just perfectly.

In CentOS 6, there’s a problem installing it (at least in all my servers with CentOS 6 i had it) because of perl-Date-Manip, with the error: [Errno -1] Package does not match intended download.

I guess it’s because of the version…

The solution: Get perl-Date-Manip-5.54-4.el6.noarch.rpm from the internet (ie and before installing it, install all it’s dependencies.

NOTE: This version is i686. For x86_64 just replace the arch.

Go to and download it.

Edit (new package):

Before installing, install all it’s dependencies:

yum install mailx perl perl-Module-Pluggable perl-Pod-Escapes perl-Pod-Simple perl-YAML-Syck perl-libs perl-version

And then, install perl-Date-Manip that we have downloaded before:

rpm -ivh perl-Date-Manip-5.54-4.el6.noarch.rpm

and next, we can install logwatch:

yum install logwatch

This way, logwatch is installed


If you want to have logwatch mailed to you, you need to install sendmail (or postfix). According to logwatch.conf, only sendmail (and mailers that support output stream) can be used

From logwatch.conf:

# By default we assume that all Unix systems have sendmail or a sendmail-like system. # The mailer code Prints a header with To: From: and Subject:. # At this point you can change the mailer to any thing else that can handle that output # stream. TODO test variables in the mailer string to see if the To/From/Subject can be set # From here with out breaking anything. This would allow mail/mailx/nail etc….. -mgt

Installing sendmail

yum install sendmail

Configuring the email address

Now, we have two choices – or we just put our email address in logwatch configuration file – or we put it in /etc/aliases, thus receiving all email to root from the system. The latter is better, since we catch all email from our system.

Editing aliases

vi /etc/aliases

Go to line 96, uncomment the line (remove the ‘#’) and change the name to your email address:

# Person who should get root’s mail

Save and run:


Start sendmail

/etc/init.d/sendmail start

and you can see how things are going by watching /var/log/maillog

tail -f /var/log/maillog

 Note: If you get an error because of Perl-Date-Manip and the timezone, that’s a problem and i couldn’t find a solution.

Upgrade Linux Mint 11 (Katya) to version 12 (Lisa)

Well, Linux Mint 12 is out and it’s time to upgrade and take advantaged of the new features…

There are many ways of upgrading, as you can read here: Please read it carefully before proceeding with the upgrade. You can turn your current installation useless.

Both are valid, but not without possible problems.

I have Linux Mint 11 transformed in a Media Center, running XBMC and connected to my Video Projector! And now, i’m ready to upgrade, using the “C2 – Packages Upgrades”.

NOTE: After altering the sources.list and start the upgrade, there’s no turning back.

Warning: I’ve tried and it didn’t work for me… I had errors about apparmor and udev… Had to install all over again… But this method is supported and i’ve tried twice (from Mint 9 to 10 and from 10 to 11) and always had worked.


Warning: It didn’t work for me. It didn’t work for me.It didn’t work for me. It didn’t work for me. It didn’t work for me. It didn’t work for me. It didn’t work for me.


This means that, i’m going to edit the file sources.list of apt, and change the sources.

First, let’s upgrade Linux Mint 11 -

apt-get update

apt-get dist-upgrade

After Linux Mint 11 updates itself, let’s go to update the sources.list. First, copy the file, so we can have a backup (just in case, but after you start to upgrade, there’s no turning back…)

So, i’ll transform the following lines:


deb katya main upstream import backport

deb natty main restricted universe multiverse

deb natty-updates main restricted universe multiverse

deb natty-security main restricted universe multiverse

deb natty partner

deb natty main

deb natty free non-free



deb lisa main upstream import backport

deb oneiric main restricted universe multiverse

deb oneiric-updates main restricted universe multiverse

deb oneiric-security main restricted universe multiverse

deb oneiric partner

deb oneiric main

deb oneiric free non-free

Basically, just alter katya to lisa and natty to oneiric

After you change the sources, let’s update the packages:

apt-get update

apt-get dist-upgrade



1133 upgraded, 373 newly installed, 23 to remove and 0 not upgraded.

Need to get 786 MB of archives.

After this operation, 987 MB of additional disk space will be used.

Do you want to continue [Y/n]?

Just press <enter> and let the “games” begin…

Good Luck

EDIT: Even if you get some errors when apt is upgrading, and the errors does not seam to be critical, ignore them and reboot the machine. After rebooting, just run apt-get upgrade and apt-get dist-upgrade so apt can update any package and configure again the “broken” configurations… I’m not saying the upgrade will work, but i’m finished and everything seems working.

Install core fonts Centos 6

Centos 6 does not comes with the Core Fonts from M$. Here 's how can we add them

yum install ttmkfdir cabextract rpm-build

For chkfontpath, we need the ATrpms repository or download the file directly from

Note: The chkfontpath has dependencies, so it's best to add the ATrpms repository…

If you want to add the ATRPMS repository, just download the rpm to add the repository from here:

rpm -ivh atrpms-repo-6-4.el6.i686.rpm

yum install chkfontpath


rpmbuild -bb msttcorefonts-2.0-1.spec

cd rpmbuild/RPMS/noarch



rpm -ivh msttcorefonts-2.0-1.noarch.rpm

cd /usr/share/fonts/msttcorefonts



Voilá! We have now the M$ core fonts installed and available to us.