Saturday, November 17, 2012

How to set up Arch Linux on a Raspberry Pi. Part 3: Network Configuration

Network Configuration

Wired Network

I had no problems with connecting to the internet using the wired connection during and after installation, so I am not going into any detail here. The only thing I did was setting up a hostname:
  # echo hostname > /etc/hostname

Wireless Network

I am using the Edimax EW-7811Un nano USB adapter to connect my Raspi to my wireless network. You can get it from Amazon.
This working setup was pieced together from the Arch Linux wiki, their forum, and this site.

Driver Installation

This will not be fun. First a few tools have to be installed in order to be able to configure the wirless network.
  # pacman -S wireless_tools wpa_supplicant wpa_actiond dialog netcfg
The parameter -S will install packages from the internet. A simple confirmation will download and unpack them. Check the name of the wireless interface with 
  # ip link
but it usually is wlan0. The command will also spit out the MAC addresses of all connected network adapters, which is useful for configuring wireless card access lists of a router.

And now comes the nastiest bit: The installation of the linux drivers. Download them from the Realtek website (the ones from the Edimax website are outdated and do not work on the Raspberry Pi Arch LInux) using
  # wget ftp://WebUser:n8W9ErCy@208.70.202.220/cn/wlan/RTL8192xC_USB_linux_v3.4.4_4749.20121105.zip
[Update: The login for the FTP server does not work anymore]
which will download and save the file to the home directory of the superuser. Unpack the archive using
  # pacman -S unzip
and then
  # unzip RTL8192xC_USB_linux_v3.4.4_4749.20121105.zip
This will unzip the file into the rtl8192CU_8188CU_linux_v2.0.939.20100726 directory. Change into driver directory within that directory via
  # cd RTL8188C_8192C_USB_linux_v3.4.4_4749.20121105/driver/
and unpack the contained tar file with
  # tar -xvzf rtl8188C_8192C_usb_linux_v3.4.4_4749.20121105.tar.gz
The option -x tells tar to unpack the file, in this case using gzip via -z. The output is made verbose (i.e. putting out every action) with -v, and the input is the file defined by -f. Change into the new directory using
  # cd rtl8188C_8192C_usb_linux_v3.4.4_4749.20121105/
Just for safety (and because I did it for the non-functional drivers from the Edimax website) create a symbolic link with
  # ln -s /usr/src/linux-
i.e. create a link to the arm directory in the kernel source directory. Keep in mind that the kernel version can change depending on updates!
Now install the tools necessary for compilation with
  # pacman -S base-devel
Compile the driver (this will take a while) with
  # make
and install it with
  # make install
This will create a kernel module with the driver, which has to be loaded via
  # modprobe 8192cu 
Now it is time for a reboot with
  # reboot
Hopefully the driver will load properly during startup.

And now for the actual configuration of the wireless interface ...

The wireless interface can be fired up using
  # ip link set wlan0 up
and configured with
  # wifi-menu
The console will change to a menu view with that ugly blue background and a blue menu "in front" of it. At least that is wat that black "drop shadow" suggests. Nevermind, the menu will show all detected wireless networks and their signal quality and encryption strength. Select your network using the arrow keys and
confirm with [enter].

wifi-menu: Selection of available networks.
The next menu screen will request the Wifi password. Enter it and hit [OK].

wifi-menu: Enter password.

The menu will then drop back into console mode. Apparently the error message "Failed to initialize driver 'nl80211' can be ignored; the wlan0 interface will fire up without problem. This can be tested with a ping:
  # ping -c 3 www.google.co.uk
The '-c 3' parameter will send out 3 pings. Google is a good choice because a) they answer to pings and b) they are always online. The configuration can be examined using
  # iwconfig
or
  # ifconfig
The former will give details about network mode, ESSID etc, while the latter reveals the ip addresses (which might be usefull if you want to SSH into the Arch system).

Hmm, this is way more chaotic than I intended. This article will need some clearing up some day. Maybe.

How to set up Arch Linux on a Raspberry Pi. Part 2: User Accounts

This article is following the suggestions from r3v0luti0n. These are steps that are not fully described on that page though. Further information comes from the Arch Linux Beginner's Guide.

In the following the root shell will be denoted by #, while the user shell uses $.


Setting Up User Accounts

Set up a root password

Keeping the password "root" for the root account is rather dangerous. The command
  # passwd
will allow you to change the password for the root account. You will be asked to enter the password twice. If you want to change it later, use
  $ su -c passwd
The command su -c will grant you superuser privileges for a single command (-c) after you entered the current root password, and the passwd command will be executed afterwards.

Set up a normal user account

The use of the root account for daily work is strongly discouraged. A standard user can be set up using
  # useradd -m -g users -s /bin/bash yournamehere
The -m option creates a home directory for the new user, and the -g option allows you to set the groupid of the new user (users in this case). The -s parameter sets the login shell (/bin/bash) but can be omitted in order to use the default shell. Yournamehere is the name of the new account. The password can be changed later using
  $ su -c passwd
from the user shell. 

Remove a user account

Normal user accounts can be removed by
  # usderdel -r user
The option -r will delete the home directory, and user defines the username which is to be removed.

Monday, November 12, 2012

How to set up Arch Linux on a Raspberry Pi

This article was shamelessly stolen from r3v0luti0n. At least I didn’t simply translate it, but actually used it to configure Arch Linux on my Raspi.

First Login

You should see something like this:

  Arch Linux 3.1.9-20-ARCH+ (tty1)
  alarmpi login: root
  Password:


Both username and password are root. If you put in anything else you can watch the system trying and failing to start a graphical system.

  [root@alarmpi ~]#

Change of Keyboard Layout

Not done. I am fine with an English layout for now. The main problem is the switch between y and z anyway.

Test of Internet Connection

This was not really necessary for me because I knew from the previous Raspbian system that the internet connection was fine. If you want to you can do

  [root@alarmpi ~]# ping -c 3 r3v0luti0n.com

The r3v0luti0n.com can of course be replaced by an internet address of your choice which is known to be always available. So maybe not twitter.com or some other site similarly prone to outages.
I haven’t bothered with trying to set up a wireless connection at this point, so I am deviating even further from the guide.

System Update

One of the first steps for any linux setup is always a system upgrade. The Arch package manager pacman is said to be very fast and simple to use.

  [root@alarmpi ~]# pacman -Syu

The parameter -S requests packages from the preconfigured repositories, -y updates the resources and checks available packages against the system, and -u starts the upgrade.
The first upgrade will take a long time. Arch Linux uses a rolling upgrade and update system:There are no big system upgrades, but instead packages are continuously updated. This means that even after downloading the most recent image there might be quite a lot of updates waiting for you. I was luck with only 48 package updates, which took about 30 minutes.

Configuration of Locale and Keyboard Layout

As with most things the locale is defined in a text file. Use
  
  [root@alarmpi ~]# nano /etc/locale.gen

to start the nano text editor. Nano is a very simple text editor that runs in the command line. The main commands are explained at the bottom, and the rest is done by navigating with the arrow keys and typing text. The file contains some explanatory text and a long list of possible locales, i.e. language and localisation settings. Uncomment the ones you would like to use. For me this was the line

  #en_DK.UTF-8 UTF-8
  #en_DK ISO-8859-1
  en_GB.UTF-8 UTF-8
  #en_GB ISO-8859-1
  #en_HK.UTF-8 UTF-8


(The important line is highlighted in bold print). [Ctrl]-o will write the file (after a confirmation), and [ctrl]-x will exit nano. [I didn’t know that Denmark had a specific English keyboard layout, but you never stop learning …]
The command

  [root@alarmpi ~]# locale-gen

will generate the corresponding language files.

Main Configuration

There was no /etc/rc.conf present on my system, so I had to create it myself. It seems that quite a bit of the essential of the system configuration has changed since the r3v0luti0n guide was created, so from here on I am following the ArchWiki. Actually, there was a change to systemd as the default init daemon, so /etc/rc.conf is obsolete.

Keyboard Layout

The keyboard layout is stored in /etc/vconsole.conf. If you want to change from the default (US of course …) you can look up the available keymaps with

  [root@alarmpi ~]# ls /usr/share/kbd/keymaps/i386/querty

and set it by using
  
  [root@alarmpi ~]# nano /etc/vconsole.conf

[Ctrl]-o will write the file (after a confirmation), and [ctrl]-x will exit nano. My final /etc/vconsole.conf looks like this:
  
  KEYMAP=uk
  FONT=lat9w-16
  FONT-MAP=8859-1_to_uni


I haven’t touched any other settings than the keymap because I am not sure what they do.

Main Configuration File

I created a file using
  
  [root@alarmpi ~]# nano /etc/rc.conf

looking like this:

  # /etc/rc.conf - configuration file for initscripts
  #
  # Most of rc.conf has been replaced by various other configuration
  # files. See archlinux(7) for details.
  #
  # For more details on rc.conf see rc.conf(5).
  #
 
  DAEMONS=(syslog-ng network crond)
 
  # A reasonable DAEMONS array when using sysvinit is:  

  # DAEMONS=(syslog-ng network crond)
  #
  # When using systemd, it is recommended to only enable daemons that
  # do not have native systemd service files.
 
  # Storage
  #
  # USEDMRAID="no"
  # USELVM="no"
 
  # Network
  #
  # interface=
  # address=
  # netmask=
  # gateway=


Again, [ctrl]-o will write the file (after a confirmation), and [ctrl]-x will exit nano.

Reboot

After this ordeal I rebooted with

  [root@alarmpi ~]# reboot

This is particularly important if you want to use the GB keyboard layout right away. I really can’t get used to # being on [shift]-3 …

Later more.


Monday, July 16, 2012

Mendeley instead of Endnote

I recently switched from using Endnote to Mendeley. There were several reasons behind this:
  • It must be platform-independent. I have to work on an Apple Mac at work, and I enjoy working on my Windows 7 system at home, with occasional explorations into the Linux world. Writing a paper or a thesis and inserting references has to be possible on all 3 operating systems.
  • It must be software-independent. It should not matter if I am writing on Word, OpenOffice or in LateX, references have to be easy to integrate.
  • It must sync between different machines. 
I eventually stumbled upon Mendeley on the PLoS ONE website of my first paper where it was mentioned in the right sidebar. And bingo, there was a usable piece of referencing software!

Advantages

  • It integrates into Word, OpenOffice and Bibtex, runs on Windows, Mac OS and Linux. I can't say anything about the performance in long documents with hundreds of references yet, but once my thesis is redone I will create a version with Mendeley references
  • Mendeley synchronises the references between different machines. The free plan includes 1 GB of storage, which is enough for about 1000 references for me (with the odd badly digitized 5 MB PDF among more modern an smaller ones). 
  • Unlike Endnote it is very good at finding document information from DOI addresses provided nowadays by all journals on their websites. It has some trouble though with recognizing them in some documents (PNAS, I'm looking at you!).
  • It has also its own Chrome/ Chromium extension for easier import of websites and documents into the Mendeley library.

Problems

  • Mendeley is, compared to Papers2, quite bad at reading the essential information out of a PDF file. It regularly fails to find the abstract in an automatically imported PDF.
  • The software  is not open source, so development might stop at any moment due to financial trouble. Or prices might rise so quickly so high that I might have to hunt for yet another reference management system. 
But there is a nice way around the freemium system: Dropbox. I already have it, it synchronises files between computers on Mac OS, Windows and Linux (what I am looking for!) and there are quite often promotions to expand one's storage size without having to pay for it. Even the initial 2 GB free storage should be sufficient for quite an extensive library, about 2,000 references by my guess. Oh, and someone else has already done it before me, so there are actually some instructions on what to do already out there. There are some problems though, and often checks for duplicates are recommended.

Sunday, July 15, 2012

Review: Logitech k400

It is meant to be used later on on my Raspberry Pi, if I can ever get my hands on one. For that I would like to have a second small keyboard with a tiny receiver so that I might be spared even more clutter on and next to my desk. Also, I need something else to do but only thesis revisions. Oh, and a wireless keyboard with a trackpad should work nicely with a TV-connected computer.


The k400 in all its beauty.


The good

  • A few multimedia keys on top of the keyboard (mute, volume up, volume down, and a 'home' button to open a browser window).
  • It worked without problem once the drivers were recognised and installed. It might have helped that the Logitech SetPoint software had already been installed on my home PC. The keyboard was also recognised at once on my work CrapBook.
  • The keys work quite well once you're used to their size and their position.
  • It takes normal AA batteries, and two of those babies were included. This opens the possibility for using rechargeable AA batteries.
The k400 from underneath with the battery compartment cover removed.


The bad

  • The touchpad could be a bit more responsive and sensitive to fine manipulation. As these things go, I would guess that it is about 5 years behind in development of touchpads.
  • The arrow keys are in a very bad position. It was quite easy for me to hit both up arrow and the shift key at the same time and then delete the marked line when hitting the letter that was meant to be capitalised. 
  • The badly positioned arrow and right shift keys.
  • The enter key is a bit narrow for my taste.

The weird

  • There is a 'left mouse click' button on the top left side of the keyboard. I don't know yet how useful that would be, given the full touchpad on the right side of the keyboard with single tap recognition and a left click button.

The weird 'left click' button on the top left.
  • Instead of using only the tiny unified receiver one is supposed to use and additional bridge between that receiver and a desktop PC. I don't know why, but that makes the whole receiver larger than a standard Logitech one. And it worked fine without that connector on my desktop at home. Maybe it is meant for signal amplification when the receiver is connected at the back of a PC tower underneath a desk, but I used it on the USB dock on top of my desk.
The actual nano receiver on the left, the connector for PCs on the right.

[Update]
There is one thing I am missing: The touchpad does not support multi-touch gestures. The minimum I would like to have would be that a two-finger-tap would do a right click, but unfortunately I have to use the button. I personally got very used to a touchpad doing exactly that. Hell, even my ancient Dell Inspiron 6400 laptop did that!

Monday, March 26, 2012

Thesis submission

Just a week ago I finally submitted my thesis "Study of the mutual interactions of basic amyloidogenic peptides with polyanions". A last near-all-nighter (well, I got 3 hours shut-eye), and it was done. All I had to do was to convert a massive (35 MB) word document into a bound paper copy.
I spend a horrible Monday just printing that thing on our slow lab HP Laserjet 2605dn. Once more that thing was seriously struggling with printing any embedded image files because of its limited memory. If a image resolution of 300 ppi is seen as "high quality for printing" standard, why does it take more time to print the 15 full-page figures than the rest of the thesis? That should be easily done ... well, it is another Apple Mac OS X printer driver problem. Their printer drivers are quite bad in general.

My thesis before binding: 2 copies in the paper box, 1 on top, and two copies of thesis summary and thesis submission form.

The binding could not be done on the same day anymore, but stroke 9:00 on Tuesday morning (20/03/2012) I submitted two bound copies of my thesis and two copies each of the thesis submission form and the thesis summary form. The most anticlimactic ending for a thesis imaginable.
Relief and relaxation came only on the following weekend.

Wednesday, March 21, 2012

Endnote trouble

While writing my thesis I cam across quite a few problems with Endnote. As you might know, this software allows you to maintain a reference library for writing scientific articles or something like a PhD thesis. It can insert references and format them according to different journal styles (e.g. Science random number or human readable PLoS ONE etc.) and create a reference list in a Word document.

But there are many problems

  • It makes working with Word a pain. Each time a reference is inserted it's having a big think and then reformats the whole reference list. During which time both Word and Endnote are unusable. Also, if this coincides with with a Word autosave all your work progress since last save will be lost because Word will crash.
  • It is slow. As soon as you hit about 10 references in a document updates take forever. 
  • Occasionally it gets the styles wrong up to a point that you would be better off writing the reference list yourself. Science journal is not a book, so the city it is published in is unimportant!
  • It is expensive. £200 for a single license, and there is a new version out every year. Also, older versions do not support newer versions of Word and don't receive updates.
All in all I will try to never use it again. It is just too clunky and buggy. I only have to find some alternative that works well on Windows, MacOS and Linux (just to be prepared for all eventualities).

Thursday, February 9, 2012

How to make a 500 mM EDTA solution

Getting EDTA into solution is easier said than done. I just needed 50 ml of a 500 mM EDTA stock, but it really does not dissolve well. Buying it was not an option since I couldn't find any solution that was not buffered, and I wanted it as pure as possible. So I prepared it myself.

First Try
In the beginning I made the mistake of starting with the pure acid which has to be completely deprotonated before it goes into solution, and that is a long way to go. A nasty surprise was that such a solution goes up to a pH of 8 when a NaOH solution is added, but then decreases to 7.8 within a few minutes without any visible effect of dissolving the salt. I had to discard this failure because I exceeded the 50 ml maximum volume.

Second Try
Next time I tried to use water and pure NaOH tablets, again starting with the EDTA acid. This resulted in a white sludge (I did not keep a proper record on the number of NaOH tablets added after various waiting times) which spilled out of a not properly closed Falcon tube. In the end I got it into solution, but because of the leak I did not trust the concentrations anymore and dumped it.
I finally got the idea that starting with an acid and taking it's pH up is not the best thing to do if there is already a disodium salt available.

Third Try
Eventually I managed to do it like this (for 50 ml of 500 mM EDTA with a pH of ~9):

  • 9.3 g EDTA disodium salt dihydrate (the stuff we had on the shelf, 372.24 g/mol) in 50-ml-Falcon tube. Watch out, that stuff is charged and reacts to static electricity!
  • Add 40 ml water. Mix and watch the precipitating EDTA settling down.
  • Add 10 tablets of pure NaOH. Mix and wait for 1 hour. Feel the warmth spreading through the tube.
  • Add another 10 tablets of pure NaOH. Mix and wait for 1 hour.
  • The solution was now clear. A pH check gave me 9.71, which was good enough since this was a stock solution to be added to some buffer. Next time I will be more careful about the second lot of NaOH tablets.
  • Fill up to 50 ml and filter with 0.2 µm syringe filter (just to have done it).
This is probably more than I will ever need.


Wednesday, February 8, 2012

A nice Sunday walk in the mud

I don't have much time for walking these days, but I try to get at least twice a week out there for some fresh air and some dirt on my boots.
The walk two weeks ago gave me the opportunity to test the camera of my new phone, the Samsung Galaxy Nexus. It was holding out quite well when compared to that of my old HTC Desire. The built-in panorama function is working great! Just point the camera at the landscape, and the phone does the rest. Just don't go too fast: That led to the  aberrations on the right side of the image. 
Panorama view somewhere north of Cardiff

There are some alternatives out there, but unfortunately I hadn't thought to compare them on the spot. The app Pano does not take the images automatically, but the user has to take them one by one (with some help from the app). And one has to be careful to not twist the camera which leads to a distorted stitched image.
An alternative I used with my proper cameras is Microsoft ICE which allows me to stitch the images together after I got them off the camera. This works quite well, and one can create stitches in more than one dimension, i.e. take pictures in a grid and then create a composite. I will add some examples later.

Other than a testing ground for the phone camera the walk was quite muddy, and it was worse than these images suggest:
Left foot

Right foot
Usually the ground is quite easy to walk in that area north of Cardiff, but the recent rain and the heavy use by horses turned some of the horse paths we ended up walking on turned them into shallow bogs. But at least the first daffodils were out, although we are not sure if they will make it through the spring: 
The first daffodils
One of the surprises we found is this sign of some hiking path leading into nowhere. It seems no one has been using that path for a long time, and nature claimed it back. Not sure if the owner of the land would actually care ...
A path to nowhere

... since the house just across the fence is derelict:
Anyone home?