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.