Happy new year

Just a short shout out to everbody

So, I hope everyone had a happy holiday season this year with their families 🙂

2016 is coming to an end and my blog is now online for a couple of years. I’m happy that I’m able to write about things that some people might help now or then and so I will keep on doing this in 2017 as well. Also, one of my main goals in 2017 is to make more posts with the same type of quality than in the last years.

But for now, I wish everyone a Happy new Year! We will read us in 2017 🙂

Advertisements

Error inside a LXC container: bash: fork: retry: No child processes

LXC Logo
Image source: wikipedia.org

I’ve started to migrate all my OpenVZ Containers to the LXC container virtualisation. This is because of several reasons which I don’t want to write down in this post. This time I just want to give you a fix for a problem which has bumped up for several containers after their migration on my system.

The error in summary

This error is not a problem of LXC. SystemD is causing this and it’s causing this for a good reason. SystemD wants to protect your system that one or multiple processes are able to spawn other processes without limitation. Now, if you use LXC you will get of course a enormous amount of processes which are started by your container. The container itself is a process on your host system. And this is where the problems of the limitation begins.

The Fix

The fix is rather easy and doesn’t even require a restart of your system or of your containers. As root open the file /etc/systemd/system.conf and enable / set the following value:

DefaultTasksMax=infinity

after you’ve done this, simply let the SystemD reload itself:

root@system:~# systemctl daemon-reload

That’s it. Your containers should now run as expected without the bash: fork error.

Have fun with your containers 🙂

Python error: SyntaxError: Non-ASCII character

You will already know that I’m a heavy Python user. Python is the perfect language for me for a fast and easy way to script some useful and helpful tools. Something which I came across a longer time ago: Python has some problems with umlauts and other special characters.

What is it all about?

In Python 3 you can use special characters such as the German umlauts all the time. You will not run into any issue. But if you have to use Python 2, you will run into serious problems. For example, the following code will run with Python 3 but will produce errors with Python 2:

# This are german umlauts äöü
print("foo")

While we will get the expected result with Python 3, Python 2 will gives you the following error:

SyntaxError: Non-ASCII character '\xc3' in file foo.py on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

This error indicates, that Python 2 was unable to encode the umlauts which are written down in the script file. But there is a solution available …

The Solution

The solution is rather simple. Just put this into the first line of your Python script file and you will be read to go again:

# -*- coding: utf-8 -*-

For the example above the code will now look like this:

# -*- coding: utf-8 -*-
# This are german umlauts äöü
print("foo")

Save and rerun your script. Python 2 will now be able to work with it as well.

Rocket League under Linux: “There has been an error connecting to the Rocket Leauge servers please try again later”


Source: wikipedia.org

One of my favorite games actually is Rocket League. It’s competitive, supports splitscreen (yes, even on PC), makes a lot of fun and now it’s also available for Linux. I played Rocket League before as it was a part of the PS Plus monthly free games months ago. Now that Rocket League has official arrived for Linux, I decided to buy this game on Steam as well.

Unable to connect to servers

Well, the bad thing was, after I started the game, the following message appeared:

There has been an error connecting to the Rocket Leauge servers please try again later

I started to check my network connection, was googeling if the Rocket League server were down and so on. Then I started to feel that this has something to do with my distribution (for the records, I’m actually using openSUSE Tumbleweed, a rolling release distribution). After a short time of searching the web I found the solution for the problem. For openSUSE you simply have to issue the following command as root or with the //sudo// command:

user@opensuse:~$ sudo ln -s /etc/ssl/ca-bundle.pem /etc/ssl/certs/ca-certificates.crt

This command creates a symbolic link which can later be found in ///etc/ssl/certs/ca-certificates.crt//. The link itself points to ///etc/ssl/ca-bunble.pem//. Rocket League needs this certificate to connect to their servers. It’s looking in the directory ///etc/ssl/certs// for the certificate which can’t be found. To solve this, we need the symbolic link of the certificate file where it is originally stored in openSUSE Tumbleweed (which is ///etc/ssl//).
The solution for this problem was originally discussed at the Steam community site: Link.

Restart Rocket League and you should be able ready to go. Please keep in mind that the path of the certificate can differ if you use another distribution. Anyway the target path (which is ///etc/ssl/certs///) is always the same.

Good luck and have fun with a working Rocket League 🙂

Post Script for OpenVPN clients

OpenVPN Logo
Image source: openvpn.net

Did you ever wanted to automatically do something after you OpenVPN client has successful connected to your OpenVPN server? To do so you can just add 2 simple lines to your client OpenVPN file:

script-security 2
up postscript.sh

This 2 lines above are doing the following:

  • script-security 2: Allows the calling of built-in executables (ip, route, ifconfig, …) and user-defined scripts (see next line). A script-security of 1 would mean that only built-in executables are allowed to be called.
  • up postscript.sh: This line defines the script which should be started after the client successfully connected to the server. In this case the script is called postscript.sh. If you don’t define the total path to the script here, the script has to be in the same directory as the OpenVPN client configuration.

And that’s it. After you are connected to your OpenVPN Server the given script will be fired up. Don’t forget to make the script executable for course.
For e.g. I use this to create a route on specific clients after they connected to the OpenVPN server. Of course you can do whatever you want inside the script.

MySQL / MariaDB: “Table ./mysql/proc is marked as crashed and should be repaired


Image Source, wikipedia.org: [1], [2]

Eventually you know this: Your server crashed. The server had a running MySQL or MariaDB instance with software which are using the instance to store their data. After a fresh new start after your server crashed, the software you’re normally running constantly claims the following: “Table ./mysql/proc is marked as crashed and should be repaired.”.

How To fix

A fix for that problem is very easy. First, ensure that your server and your MySQL Daemon is normally running again. You can check the MySQL Daemon like this:

root@server:~# service mysql status

If you are running MariaDB, you have to use the following command:

root@server:~# service mariadb status

If the Daemon is not running, you can start them with this command:

root@server:~# service mysql start

Or, if you use MariaDB:

root@server:~# service mariadb start

When you’re sure that MySQL / MariaDB is running, you can issue the following command to get rid of the problem:

root@server:~# mysqlcheck --auto-repair -A -u root -p

Of course, for this command you need your MySQL / MariaDB root password. The now started process can take a long time. It checks every single table in your database on corruption. If there is a corruption found, it will be fixed. After the process, you should restart your MySQL Daemon:

root@server:~# service mysql restart

Or for MariaDB:

root@server:~# service mariadb restart

From now on, everything should work as expected again.

How To get your Realtek RTL8111/RTL8168 working (updated guide)

Realtek Logo
Image Source: wikipedia.org

A lot of people will remember my guide how to get a RTL8111/RTL8168 running under your Linux box. This guide is almost 5 years old now and I wanted to make a complete overhaul, because a lot of things has changed since then.

Why do I need this driver anyway?

Some people asked me, “Why do I need this driver anyway? Doesn’t the Linux Kernel ship it?”. This is of course a valid question. As far as I can see this, the RTL8111/RTL8168 is not Open Source and this would be of course the reason why the driver isn’t included into the Linux Kernel. As long as the driver isn’t Open Sourced, we have to build it on our own.

The installation methods

A lot of things have changed since I written the initial article about how to compile the driver under Ubuntu / Debian. Today we can use 2 methods for installing the driver. The following lines describes both of them.

The automatic way

NOTE: Thanks to the user “Liyu” who gave me this hint!
NOTE2: For this way you need a working internet connection. You could use WLAN or a USB ethernet card like this one to get a temporary internet connection. You could also download every needed single package onto USB from another PC and install them in the right order.

As I said ealier, 5 years is a long time. And today Ubuntu and Debian have the driver included in it’s repository. For Debian you have to enable the non-free package sources. For Ubuntu you have to enable the universe package sources. You can easily do this by open your /etc/apt/sources.list as root with your editor of choice and add for each line starting with “deb” non-free or universe at the end. So for example, if you use Debian a line like:

deb http://ftp.de.debian.org/debian/ jessie main contrib

would become to

deb http://ftp.de.debian.org/debian/ jessie main contrib non-free

The same for Ubuntu:

deb http://de.archive.ubuntu.com/ubuntu/ xenial main restricted

would become to

deb http://de.archive.ubuntu.com/ubuntu/ xenial main restricted universe

After this you have to do a:

sudo apt-get update

You can of course use graphical ways to enable non-free or universe. After you enabled the missing package repository, you will be ready to install the driver. This can be easily done with the following command:

sudo apt-get install r8168-dkms

The procedure will take some time, depending on your CPU because the driver will be build for your working Kernel. The good side is, that if any Kernel update happens on your machine, the kernel will be rebuild against the new Kernel automatically after the update because of the use of dkms.
After the procedure is finished, you should be able to use your network card instantly. If not, you should consider a reboot of your PC then.

The manual way

Well, the manual way is almost the same as it was before in the initial article. Anyway, I want to rewrite the steps here again. This is also tested against newer Kernels ( >= 4.0) which caused a lot of trouble for some people in the past.

  • 1. Install dependencies: Once more you need a working internet connection for this. You could also use the Debian or Ubuntu DVD which includes the needed packages. To install the dependencies just enter the following command:
    sudo apt-get install build-essential linux-headers-$(uname -r)
  • 2. Download the driver: You can download the driver from the official Realtek homepage. This is the link: click me. From the table, select the “LINUX driver for kernel 3.x and 2.6.x and 2.4.x” for download.
  • 3. Blacklisting the r8169 driver: The r8169 is loaded when the r8168 is not found on your system. This will give you a network and internet connection, but with the r8169 driver your RTL8168 card will be very unstable. This means slow download rates, homepages taking hours to load and so on. To avoid that the r8169 is loaded, we blacklist it. This is be done by entering the following command:
    user@linux:~$ sudo sh -c 'echo blacklist r8169 >> /etc/modprobe.d/blacklist.conf'
  • 4. Untar the archive: After you successfully downloaded the driver, cd into the directory where the driver is downloaded and untar the driver with the following command:
    user@linux:~$ tar xfvj 0005-r8168-8.042.00.tar.bz2

    NOTE: Your tar filename can of course differs if you download a newer version in the future for e.g.

  • 5. Compiling and installing the driver: Now we have to start compiling the driver. For this you cd into the extracted directory:
    user@linux:~$ cd r8168-8.042.00

    NOTE: Don’t forget to change your version number in the future here.
    Now that you are in the right directory, we can start with the real compiling process. For this Realtek brings an easy to use script which is called autorun.sh. So, to start compiling and installing the driver enter:

    user@linux:~/r8168-8.042.000$ sudo ./autorun.sh

    You should see a output which looks like this:

    Check old driver and unload it.
    rmmod r8168
    Build the module and install
    At main.c:222:
    - SSL error:02001002:system library:fopen:No such file or directory: bss_file.c:175
    - SSL error:2006D080:BIO routines:BIO_new_file:no such file: bss_file.c:178
    sign-file: certs/signing_key.pem: No such file or directory
    Backup r8169.ko
    rename r8169.ko to r8169.bak
    DEPMOD 4.4.0-31-generic
    load module r8168
    Updating initramfs. Please wait.
    update-initramfs: Generating /boot/initrd.img-4.4.0-31-generic
    Completed.

    You can ignore the SSL error for now. The driver should be successfully compiled and installed into your system. The driver is already loaded and should work.

  • 6. Check the driver: As a final step, you could start checking if the driver is really loaded into your Kernel. For this you can use the command lsmod. lsmod lists all drivers, which are usable by your Kernel. So, if everything was successful, you should see an output like this:
    user@linux:~/r8168-8.042.000$ lsmod | grep r8168
    r8168                 491520  0

    You can also check as well your ethernet device directly to see if the correct driver is loaded (special thanks goes to Tim which posted this in the comment section):

    user@linux:~$ sudo ethtool -i enp1s0
    driver: r8168
    version: 8.042.00-NAPI
    firmware-version:
    expansion-rom-version:
    bus-info: 0000:07:00.0
    supports-statistics: yes
    supports-test: no
    supports-eeprom-access: yes
    supports-register-dump: yes
    supports-priv-flags: no

    NOTE: You have to the change enp1s0 to the device name of your network card of course. This can be eth0, eth1, enp2s0, and so on.

    If your driver isn’t loaded until now, you should go with a reboot before further investigation.

That’s it

And that’s it. Now you’re ready to use your RTL8168/RTL8111 with the official Realtek drivers. If you have any questions and / or suggestions, please let me know in the comments.