Thursday, May 2, 2013

Arch Linux on Raspberry Pi Running XFCE [Version 2]

I have created a one-liner to install XFCE on Arch Linux, Raspberry Pi. Find it in the last line.

I wrote about installing XFCE on Arch Linux running on Raspberry Pi but it seems that those instructions are no longer valid for the new version of Arch as hosted on Raspberry Pi download page. So below are the new instructions for installing XFCE on Arch, Raspberry Pi. Please note that initial steps are similar for the previous versions of Arch too.

First off download the latest Arch Linux ARM from Raspberry Pi downloads page and unzip it to extract the img file. Once you have the img file, you need to write this on a SD Card. You can use dd command or tools like ImageWriter. There are more options available on elinux page. Let us use dd command for now:
# dd bs=4M if=~/archlinux-hf-2012-09-18.img of=/dev/mmcblk0

No, cp command is not supposed to be used here because cp copies over the file system and we have to do something at much more lower level. In case you are wondering how I got the /dev/mmcblk0 bit, I just mounted the sd card and check the output of df -h command. If you are using a sd card of more than 2G memory, then I recommend using gparted or anything else and expand the size of the file system since by default it'll be just about 2G and rest of your space will go unused. Once you are done here, insert the sd card into your Pi and fire it up.
Now you can see the awesome black login screen. The default password for root user is 'root'. Login as root and create pacman, the Arch Package Manager, database.
# pacman-key --init

Some randomness would be helpful here. So hit ALT+F2 to go to another tty and execute some random commands like ls and echo and cd etc. Switch back to the previous tty by hitting ALT+F1 and wait till the initialization of db is done. Now you can update your repositories:
# pacman -Syu

 Let us install Xorg libraries first:
# pacman -S xorg-xinit xorg-server xorg-server-utils xterm
This will get us the basic X server and related dependencies

Next, we will install XFCE:
# pacman -S xfce4
The CLI will ask you if you want to install selected packages only. I choose to install everything since they looked bare minimum anyway but you can be choosy here.

Now we may need the display drivers:
# pacman -S mesa xf86-video-fbdev xf86-video-vesa

Also we will need a login manager. I use SLiM since it is lightweight:
# pacman -S slim

Next we need to enable SLiM and graphics user mode (systemd lingo for runlevel 5):
# systemctl enable slim.service
# systemctl enable graphical.target

And we have to create a .xinitrc in the user's home directory. This file reads X server configs and starts XFCE environment:
# vim ~/.xinitrc 

#!/bin/sh 

if [ -d /etc/X11/xinit/xinitrc.d ]; then
for f in /etc/X11/xinit/xinitrc.d/*; do
[ -x "$f" ] && . "$f"
done
unset f
fi
exec startxfce4

Also we need a ~/.bash_profile to execute startx to initiate the Xserver as soon as the user (root in this case) logs in.  :
# vim ~/.bash_profile
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

That is it! Reboot and enjoy XFCE on Raspberry Pi.

To save you some time, I have combined these commands in a small shell script and put it on github (fork it). So now, to install XFCE on your Pi, you need to fire just one command:

curl https://raw.github.com/adimania/arch-desktop-environments/master/XFCE-Arch-RPi.sh | bash


Discuss this post on Hacker News.

16 comments:

  1. Where is the screenshots? Give picture from your zsh. It will be cool.

    ReplyDelete
  2. I've done this prject twice from the begining.
    After every reboot the XCFE starts and requires username and password.
    The root / root combinatin is not ok.
    Does anyboy knows them?

    Thx

    ReplyDelete
  3. Now I realsied that the root/root is possibly the good combination, becase with them the "Failed to execute login command" appears, but whith the other combinations (guest/guest ...) the requiring screen appears again. But why the login is not executable?

    ReplyDelete
    Replies
    1. Did you ever solve this problem?

      Delete
    2. I didn't get this problem. Most of the readers were able to use the script and get it working in first shot. If you can elaborate a bit then I may be able to help.

      Delete
  4. great job.. worked perfect :)

    Thanks so much!

    ReplyDelete
  5. I am having the same issue as Bloggerzso. Could anyone help?!! Thnx

    ReplyDelete
  6. Too late, maybe, but I suppose slim or xfce4 is configured to not accept root login. You have to create a normal user, give it a password and log in with that. If that is not the problem, I don't know...

    ReplyDelete
    Replies
    1. Nope. I used root/root just fine. Many other users did the same. Can you elaborate the problem and the steps you followed?

      Delete
  7. WORKED GREAT... FIRST SHOT AND I COULD USE root, root, WITH NO ISSUES... MANY THXXXS :D

    ReplyDelete
  8. Hi,

    Thanks for the detailed instructions. Followed them to a T then rebooted. It took my login then said "/etc/X11/Xinit/xserverrc: line 5: usr/bin/X:no such file or directory

    What am I doing wrong?

    Thanks again,

    Peter Farrell

    ReplyDelete
  9. If you are using the one line fix you may need to put -k after curl.

    ReplyDelete
  10. When I do get to the vim ~/.xinitric part, it says bash: vim: command not found. and the curl doesn't work either

    ReplyDelete
  11. No joy here - root/root does not work so I can't get in

    ReplyDelete
  12. URL is now: https://raw.githubusercontent.com/adimania/arch-desktop-environments/master/XFCE-Arch-RPi.sh

    To switch back and forth from X to CLI is by using the virtual terminals. You can boot into X and then hit Ctrl+Alt+ where Fn is a function key from F2 to F6. To return to X is with Ctrl+Alt+F7

    Created new user and rebooted - "Failed to execute login command"

    ReplyDelete

Note: Only a member of this blog may post a comment.