Archive for 2012
The Issue
This post could very well be titled “How to install Linux on a Lenovo IdeaCentre Q180.” It was the purchase of one of the Lenovo IdeaCentre Q180 devices that triggered my quest to find the solution to the data packet loss I was experiencing. The Q180 comes with Windows 7 pre-installed which is a great Operating System to use as a media centre, but I had plans to turn the Q180 into a super-tiny test web server and Subversion/Git repository which definitely requires Linux.
The installation of Ubuntu Server 11.10 on the machine goes without a single hitch and the OS itself functions (almost) perfectly. It was when I tried to connect to the Internet or to SSH into the server from my laptop that the packet loss issue became most apparent. In fact, my SSH connection would die after 20 seconds requiring me to restart the session – at times it even required a reboot of the Server itself.
To test the connection, I would begin a continuous ping from my laptop to the Server’s IP address. Initially the ping would return a steady response but after about 20 – 30 seconds I would get “Destination host unreachable” as a response. The ping would then sporadically get a response before the host would be unreachable again. This unstable connection immediately kills any SSH session.
After much investigation (along with installs, re-installs, config changes and reading of websites) I found out that the Realtek 8168B ethernet controllers are actually incorrectly supported within the Linux kernel as far back as 2.4.x – I’m running Ubuntu Server 11.10 based on the 3.0.x Linux kernel myself.
So what exactly is the issue? It seems that during installation, Linux incorrectly installs the drivers for the Realtek 8169 ethernet controller which allows the 8186 to function but barely. The level of communication is akin to me using my Afrikaans to become a Dutch translator – I’d get the basics right but with a lot of problems along the way.
The Solution
The solution, in hindsight, is painfully simple – simply uninstall the 8169 driver and install the Realtek RTL8168 drivers.
Firstly, confirm you actually have the r8168 controller. (I recommend running all commands as root).
lshw -short
If so, you’ll need to download the latest driver from the Realtek driver website. Alternatively, run the following command in your Home directory:
wget http://r8168.googlecode.com/files/r8168-8.026.00.tar.bz2
Next we need to remove the r8169 drivers from the kernel.
rmmod r8169
Now we get to the good bit – compile and install the Realtek r8168 drivers:
tar xvf r8168-8.026.00.tar.bz2
cd r8168-8.026.00/
sudo modprobe -rfv r8169
sudo make
sudo cp src/r8168.ko /lib/modules/$(uname -r)/kernel/drivers/net/
sudo depmod -a
sudo modprobe -v r8168
Confirm everything went as planned and the driver is installed.
lsmod | grep r8168
You now have to blacklist the r8169 driver by editing /etc/modprobe.d/blacklist.conf and inserting
blacklist r8169
Test the success by rebooting your server and pinging it from another machine. This is how I tested it and after updating the driver my ping returned a consistent response. In fact, the response was much quicker as the r8169 driver also capped the ethernet controller at 100MBits.
I am not the biggest fan of the nano editor which is the default one in Ubuntu. I prefer using vim-nox and therefore I change the default text editor in my Ubuntu installs from nano to vim-nox as one of my first tasks after a fresh install.
If you wish to do the same, run the following command:
sudo update-alternatives --config editor
It will show you a list of all possible editor options – just type in the number of your personal favourite and the default editor will now be changed.
Do you sometimes wish you could just do a var_dump inside a Twig template while trying to debug some code? Well Twig comes with its own Debug extension to allow you to do just that.
Firstly, add the following to your /app/config/config_dev.yml (you don’t want to do this on Prod):
twig:
debug: 1
services:
debug.twig.extension:
class: Twig_Extensions_Extension_Debug
tags: [{ name: 'twig.extension' }]
Now inside your Twig templates you can “var_dump” variables using the built-in Twig Debug:
{% debug nameOfVariable %}
Happy debugging!
Sometimes you don’t want to render all of the elements of a form using form_rest but you’re still required to render the hidden CSRF Token on a Symfony2 form.
To render only the CSRF Token, use the following:
{{ form_row(form._token) }}
Use the following code to check if a variable exists within a Twig template:
{% if theVariable is defined %}











Recent Comments