Showing posts with label Arch. Show all posts
Showing posts with label Arch. Show all posts

Saturday, November 17, 2012

Two Arch Linux updates and a guide on how to get Arch Linux ARM running on a Raspberry Pi.

I spent three weeks travelling because of work and the last week I was busy playing with my Raspberry Pi. I'll do a quick guide on how I got my RPI working, what packages I installed and what I could manage to do on it. But before that, I'll quckily comment on two news on the Arch Linux site:

1) ConsoleKit was replaced by logind

Anything that depended on ConsoleKit now depends on logind. This means that you can take that "ck-launch-session" from your ~/.xinitrc file if you're using systemd.

2) Support for Initscripts was dropped

I knew it was going to happen sooner or later, but I do think it was too soon. Anyway, fellow Archers, you need to adopt systemd at once!

With that said, let's go to the RPI! :)

I ordered a LOT of stuff from dealextreme, but on this post I won't cover this stuff, just the bare essentials (regular USB keyboard, regular USB mouse, wiimote as mouse and ethernet). I ordered a 16GB C10 SD card, a cordless keyboard with a touchpad, power source (microusb, 5V, 2A), externally powered USB hub, Wifi USB dongle, Bluetooth USB dongle, etc. For now, I ended up buying a usual USB keyboard and a usual USB mouse so I could start playing around. I already had an unused 2GB C4 SD card and a HDMI cable. While I was travelling I also bought a cheap 5V 1A power source (raspberrypi.org recommends at least a 700mA one).

Well, I downloaded the lastest Arch Linux ARM image from their site and followed the instructions to dd the image to the SD card. That was a piece of cake. Hooked everything up for the first boot: ethernet cable, HDMI cable, keyboard, mouse and cheap power source. The RPI didn't boot. Searching the web I found out that the most common cause for this was the quality of the power source, and I knew mine was... kinda crappy. So I had to go to bare essentials and see if it worked: HDMI cable and keyboard (took the ethernet cable and the mouse). The RPI booted.

There I saw the RPI symbol and systemd started loading a lot of stuff, including the NTP daemon and a SSH server. Right there I realized: the image is a pre-built arch install, I wouldn't have to go through all the hassle of setting everything up, just adjust the config files (vconsole.conf, set timezone and locale, etc.) and install the applications I wanted. So I logged as root (password is also root) and browsed around. The default resolution (1080p) is so high that I could barely read what I was typing on my FullHD 32" TV. So the first thing I did was lower the resolution to 720p on the /boot/config.txt file (both nano and vi are available on the base system). All parameters can be found here. After rebooting I could read everything but there were two "stripes" of unused lines on the TV, one at the bottom and one the top of the screen. I figured I'd take care of this later (and I'll show how).

So, what can one do with a Linux box without networking (remember I had to disconnect my ethernet cable so my RPI would boot)? Not much. I then remembered that I had a cellphone charger that is a microusb one rated at 5V, 850mA. This one was able to hold the ethernet and mouse. Now I was all set! I'll list everything I did to get stuff working.

-1) You'll need a GOOD power source (PSU). Most RPI problems are related to poor PSU quality. I had two problems with the cell phone charger I mentioned (one was already mentioned and the other will be covered on the next post). Get a GOOD PSU.

0) Installation

Simply download the image on this link and follow the instructions listed there. The image you'll write to your SD card will have two partitions: a FAT one (/boot) and a EXT4 one ( / ).

1) Lower the resolution

1080p is the default resolution for the RPI HDMI output. As I already said, I had to lower the resolution so I could see what I wrote. If you can see what you're writing, the resolution is good enough and you can skip this step. On this link all possible values are listed. I simply added the following to my /boot/config.txt:

hdmi_group=1
hdmi_mode=4

Like I said, this changes the resolution to 720p but still got two "stripes" of unused lines on the TV, one at the bottom and one the top of the screen. To get rid of them I added the following lines to my /boot/config.txt. I did get to these values after getting X11 running so I could be confident they were correct.

disable_overscan=1
overscan_left=37
overscan_right=37
overscan_top=23
overscan_bottom=23

2) Configuring the keyboard

Now that I could see what I wrote, I had to configure the keyboard configuration. This is done the same way as the usual arch install (using the loadkeys command and editing /etc/vconsole.conf). Check this post for details.

3) Set timezone and locale

Like the previous step, this is done just like the usual arch install. Check this post for details.

4) Change hostname

The default hostname is alarmpi. You can change this if you like:

hostnamectl set-hostname yourhostname

Of course, change yourhost name to the hostname you want.

5) Change root password and add a regular user.

This is important. The default root password is also root. You should change that. Also, add a regular user for you to use. Check this post for details.

6) Next I disabled the SSH server (don't need it at the moment, and I don't know about the default config). If you want to keep it running, simply skip this.

systemctl disable opensshd.service
systemctl stop opensshd.service

7) Sudo

Now we install sudo, edit the sudoers file (with the visudo command) and simply stop using the root user. Check this post for details.

8) Packages!

All right! Now for the best part. I'll list the packages I installed and why I installed them. You can install packages the the usual way: pacman -S packagename (of course, you'll need to do a pacman -Suy first) and search for packages using pacman -Ss packagename.

8.1) Sound

I installed the alsa-utils and alsa-plugins packages. In addition, you'll have to do type the following command as root (or sudo it) for sound to work (it loads the sound module):

modprobe snd-bcm2835

You may need to unmute the sound using alsamixer.

To make it load on startup, create the following file: /etc/modules-load.d/snd-bcm2835.conf. Then add snd-bcm2835 to it.

8.2) X11 basics

Raspberry Pi video driver: xf86-video-fbdev;
Xorg: xorg-server, xorg-server-common, xorg-server-utils, xorg-xinit;
For input: xf86-input-keyboard, xf86-input-mouse;
Basic fonts: xorg-font-utils, xor-fonts-100dpi;

8.3) Fonts, cursors, themes, etc. And lxappearance

This post has some fonts, cursors and themes you can install. I don't know if all of them are available in the Arch Linux ARM repos. Anyway, you can search for the available ones easily. Also, install lxappearance to easily configure themes, cursors, etc. Just install whatever you think looks good. :P

8.4) Applications.

I'll list what apps I installed, but you can install whatever you like. As usual, I stuck to Fluxbox as WM, but this time I won't use a login manager (usually I use slim). I used this method to login directly to X. The reason for this is that this system needs to be VERY light.

WM: fluxbox;
Utilities: galculator, thunar, vim, leafpad, feh, dmenu, gksu;
Browsers: uzbl-core, uzbl-browser, dwb;
Audio player: xmms;
Video player: xbmc-rbp-git;

I configured Fluxbox as I usually do. This post shows how I usually do it. I did swap a few applications: xfc4-appfinder for dmenu and gpicview for feh, etc. But this is because only VERY lightweight stuff must be installed on RPI (exception for XBMC which I'll talk about in a minute).

Side note: I didn't install conky, but intend to.

8.5) XBMC

As you should well know, the RPI GPU can do hardware decoding of H264 video. The "problem" is that, as far as I know, only two players can currently use the GPU instructions to do proper H264 FullHD video playback using the RPI: XBMC and OMXPlayer. OMXPlayer a CLI utility and XBMC is a fullblown Media Center. I chose XBMC because it would be easier to install (XBMC is available on the repos, OMXPlayer needs to be compiled from source).

It runs great anyway. I managed to watch The Avengers movie on 1080p. It's fantastic.

One note on XMBC: you NEED to set 128MB of RAM to the GPU for it to playback video properly. To do this, add the following to your /boot/config.txt:

gpu_mem=128

In the end, this is how the top of my /boot/config.txt file looks like (the rest of the file is commented, no use in posting it here):

# SETS GPU RAM AND RESOLUTION! 

# For watching movies (128MB VRAM and 1080p resolution)
#gpu_mem=128
#hdmi_group=1
#hdmi_mode=16

# For computing (8MB VRAM and 720p resolution)
gpu_mem=8
hdmi_group=1
hdmi_mode=4
disable_overscan=1
overscan_left=37
overscan_right=37
overscan_top=23
overscan_bottom=23


As the comments say, I have two groups of settings: one for watching movies and one for general computing.  The first group sets 128MB of RAM for the GPU and 1080p resolution. The second sets 8MB of RAM for the GPU (leaving more RAM for the Operating System) and 720p resolution so I can actually read stuff.

8.6) CwiiD

CWiiD enables you to use wiimote (plus nunchuck or classic controller) as input devices, provided you have a bluetooth USB dongle for the RPI. I used a regular cheap-ass one. Simply swapped the mouse for the bluetooth dongle. You only need to install the cwiid package and do some configuration. This link will tell everything you need to know to configure it. The only thing you won't find there is that you need to enable the bluetooth service:

sudo systemctl enable bluetooth.service

The next time you reboot, it'll be started. If you want to start it now:

sudo systemctl start bluetooth.service

Just as example, here's my /home/username/.cwiid/wminput file, I'm only using my wiimote as mouse.

#IR pointer 

Plugin.ir_ptr.X = ABS_X
Plugin.ir_ptr.Y = ABS_Y

#buttons

Wiimote.A        = BTN_LEFT
Wiimote.B        = BTN_MIDDLE
Wiimote.Up       = KEY_UP
Wiimote.Down     = KEY_DOWN
Wiimote.Left     = KEY_LEFT
Wiimote.Right    = KEY_RIGHT
#Wiimote.Minus   = KEY_BACK
Wiimote.Plus     = BTN_RIGHT
#Wiimote.Home    = KEY_HOME
#Wiimote.1               = KEY_SLASH
#Wiimote.2               = KEY_SPACE

#Nunchuk.C              = BTN_LEFT
#Nunchuk.Z              = BTN_RIGHT
#
#Classic.Up             = KEY_UP
#Classic.Down   = KEY_DOWN
#Classic.Left   = KEY_LEFT
#Classic.Right  = KEY_RIGHT
#Classic.Minus  = KEY_BACK
#Classic.Plus   = KEY_FORWARD
#Classic.Home   = KEY_HOME
#Classic.A              = BTN_LEFT
#Classic.B              = BTN_RIGHT
#Classic.X              = 
#Classic.Y              = 
#Classic.ZL             = 
#Classic.ZR             = 
#Classic.L              = 
#Classic.R              = 


[end of tutorial]

That's it, pretty simple aye? The RPI is amazing. It's so small and can do so much. For now, I managed to playback some 1080p video, playback some mp3s, use my wiimote as mouse and browse the web. It's a full featured computer, you can do whatever you want with it. On the next post I'll tinker with the stuff I bought on dx.com to enhance my RPI experience.

Sunday, October 14, 2012

Arch Linux News, a Raspberry Pi story and my plans for it!

Now it's official, systemd is now default on new installations. If anyone plans on using the last post as a guide to installing Arch Linux using the lastest install medium, the part "RUNNING A PURE SYSTEMD SYSTEM" can be skipped, as well as inserting (and removing) the line "init=/bin/systemd" in /etc/default/grub. I don't know if syslog-ng, cronie and dhcpcd@eth0 are loaded by default on the new installation. It can be easily checked though: just do a sudo systemctl list-unit-files (then press q to quit).

Unless you have been living under a rock or is not as nerdy as I am, you probably have heard about the Raspberry Pi (from now on I'll just call it RPI). It's a US$ 35 credit card sized LINUX computer with a 700 MHZ ARM CPU, 256 MB of RAM and a GPU capable of decoding H264 video files (also MPEG2 if you buy the license for it). It comes with 2 USB ports, an ethernet port, a HDMI out (full size), a composite video out, a stereo audio out and some GPIOs (general purpose I/Os) . Also, it only consumes around 3.5 watts on idle. Considering the power source efficiency, other peripherals connected, etc. let's round it up to 5 watts. This means that it costs (in Recife, Brazil) US$ 0,94 a month (R$ 1,87, US$ 1 = R$ 2) to keep it turned on. This makes a pretty cheap server!

I was thinking of importing one myself, but I found this page (it's in portuguese though). You see, here in Brazil the taxes are insanely high, so importing a US$ 35 RPI would mean I'd have to pay almost US$ 150 (R$ 300) for it, converting the brazilian currency (Real) to US dollars. The main reason being: not only the taxes are high but I'd have to pay taxes over the RPI AND the shipping service, which is even pricier than the RPI (around US$40).

I looked a Mercado Livre, the brazilian ebay, and found some RPIs being sold for around US$ 125 (R$ 250). That's cheaper and the RPIs were already in Brazil, so I woundn't have to wait so much. I "bought" one. The next day though, as I got to work, I encountered a friend of mine and told him how I "got" the RPI for around US$ 125 (R$ 250). Then he turned to me and said: "Dude, Farnell Newark Brazil is selling it for US$ 87,50 (R$ 175)".

This friend of mine ended up buying one as well, so we got two RPI and shared the shipping service bill. So, I ran to my computer and cancelled my original order. The RPI ended up costing US$ 93,16 (R$ 186,32). Considering my options, not bad right?

The RPI will probably get here in the middle of this next week, but I'll be travelling for the next two weeks. In the mean time, I have already made a list of all the stuff I'll need. Since it's so cheap to keep it turned on (also, using less energy is the green thing to do!) it makes a perfect little server. I'll hook it up on my 32" LCD TV on my living room. I plan on using my RPI as a: (not listed in order of importance):

1) Old console emulator (mainly MAME and SNES);
2) Media center (streaming media from my desktop);
3) Torrent box (saving stuff on the SD card then ssh or ftp the stuff to my desktop);
4) Printer server (my printer is currently connected to my desktop, so if my wife wants to print something from her laptop, she needs to turn on my desktop).

Since it runs Linux, the possibilities are... many. I plan on using Arch Linux ARM (ARM port of Arch Linux!) with Fluxbox as WM. Later, I plan on using Xmonad or Awesome WM.

For the RPI to do those 4 things I listed, I reckon I'll need:

1) Power supply

Power is supplied to the RPI by a mini-USB port. The RPI manufacturers recommend using a supply with 700mA of rated current. I found one on the web that is able to supply 1,5A. I'll also need a full USB to mini-USB cable. I do have two spares here already, so that's taken care of.

2) SD card

The RPI doesn't have any internal memory (aside from RAM). The operating system has to be installed on a SD card for the RPI to boot it. I'll get a 16 GB class 10 Kingston SD card.

3) Keyboard and Mouse

I'll just get a USB cordless keyboard with a touch pad attached.

4) Wifi dongle.

I don't want the ethernet cable running through the living room (the router is far from the living room TV).

5) Joypad and Arcade Control (and a bluetooth dongle for Wiimote support)

I don't have a USB joypad but I have a arcade control I made several years ago (I think it was in 2002, ten years ago!):




It's simply a wooden box with arcade buttons and microswitches soldered to a generic USB joypad. Since it's been some time since I last used it, some solders have gone bad but it can be easily fixed.

Also, cwiid is also available for Arch Linux ARM! I know it's somewhat outdated but it works. I can use my wiimote + classic controller as joypad. For that to work a bluetooth dongle is needed, I do have one but sometimes my wife wants to use it on her laptop, so I'll just get a new one.

6) External HD and External DVD drive.

These are for later. My external HD is being used on my Wii at the moment and at first the 16GB SD card will do the job. A external DVD drive is simply a good addition (and if you buy the MPEG2 license, RPI will turn into a DVD player!)

7) USB Hub with external power source.

To connect all this USB stuff, nothing better than a good quality USB hub with a extrenal power source. The two USB ports of the RPI are limited to 140mA.

8) HDMI cable. Already have one lying round here unused.

What I'll need to get as of right now (prices rounded up):

1) Power supply (R$ 34);
2) 16GB class 10 SD card (R$ 70);
3) Cordless keyboard + touchpad (R$ 132);
4) Wifi dongle (R$ 60)
5) Bluetooth dongle (R$ 20)
6) USB Hub with external power source with 7 ports (R$ 54)

That comes to a total of R$ 370 (US$ 185). With shipping: R$ 428 (US$ 214) (Buying from two different online stores, so I kinda have to pay twice the shipping bill).

Anyway, a RPI + a bunch of stuff needed to get it to do what I want: R$ 186,32 + R$ 428 = R$ 614,32 (US$ 307,16). That's actually pretty expensive. The RPI in Brazil is not a low-budget computer, considering a ASUS netbook with HDMI out here in Brazil costs R$ 900 (US$ 450) and it has everything my RPI will have and more, a R$ 285 (US$ 142,50) difference.

Comparing the two situations:

Advantages of MY future RPI system (emphasis on MY because the RPI cannot be generally compared to a netbook, but considering what I want to use it for, the comparison is valid):

1) The most expensive part are the accessories, which can be used somewhere else, and if my RPI dies, I can just get a new one and hook everything up again, but with the netbook, it's all or nothing;
2) 5 watts of power consumption versus 30 watts for the netbook;
3) Comes with GPIO (not that I'll use it right away, but I'll think of something);
4) How cool is it to have such a tiny computer?!?!?!?

Advantages of the Netbook:

1) It's way faster;
2) Battery "out-of-the-box". You can adapt batteries for the RPI, but you'll need to do it yourself;
3) Comes fully finished and the RPI doesn't even come with a case;
4) Regular x86 architecture, regular Linux distro can be used, and the RPI uses ARM processor, which limits the choice of distros;
5) Has it's own display and the RPI needs a external one;

The hdd and webcam of the netbook are actually not a advantage, because I could buy a good USB hdd and a good webcam for the RPI and it's still gonna be cheaper. Also, I'm not counting the fact that a netbook is a great mobile solution because what I wanna do with the RPI doesn't need mobility. But, in the end, the advantage number 4 for the RPI is what counts!

Anyway, what is missing for my future RPI is the case. I have no idea how I'm gonna solve this yet. I'm aware of this, but I'm terrible with my hands :p. I'll figure something out though.

As soon as I start working on the RPI I'll post my progress here.

Friday, September 28, 2012

Archlinux + Systemd + Fluxbox + Old laptop = Impressive Speed

Alright, around two/three weeks ago I uninstalled wattOS R5 from one of my old laptops and decided I'd get Arch on it, and since I liked Fluxbox on Ubuntu so much, why not do exactly that: Archlinux + Fluxbox on this oldie laptop? Anyway, I'll try to write a guide on getting a basic Archlinux with Systemd set up. Then we'll get to a point where I install the applications (including Fluxbox) I use, you can install whatever you like though, just adapt it for your system.

"Everything" (as far as I can remember) I did I wrote on a text file so I'll post step by step what I did, but be advised, I did this a few weeks ago so I cannot be absolutely sure that EVERY command is listed here and since I don't know the specs of your computer, what's written here may not work for you. With this disclaimer: in case anyone wants to try this out and gets stuck remember that Archwiki is your friend! I didn't make any of this up, I just followed the Archwiki guide.

Also, one more advice: if you really want to do this, read the whole post before attemping to do this!

So here we go!

PRE-INSTALL

0) First download the iso boot it. :)

After booting you'll be presented just with a terminal. Don't be scared, in no time we'll have a system running.

1) First thing we do is loading the proper keyboard layout with the loadkeys command. You can load any keyboard layout listed on /usr/share/kbd/keymaps/. In my case, it's a br-abnt2 keyboard. Simply type:

loadkeys br-abnt2

2) Then we need to partition the drive(s). The tool included on the Arch cd is fdisk. Before using fdisk though, you may want to see what your current partitions are, and for that just use the lsblk command. I just erased all partitions I had and created 2: the root (/) partition and a swap partition. This lappy only has 512MB (shared with video card) of RAM so I need a swap partition. Anyway, just type:

fdisk /dev/sda

and follow the instructions. Fdisk may seem wierd if you have never used it, but with a little patience you'll get there. I'd post every step I took during the execution of fdisk but I didn't take notes of them (sorry...). Alternatively you can boot any livecd of your choice (Ubuntu is a good and popular one, it has gparted, which is a pretty stright forward partitioning program) and partiton your hard drive(s) on a graphical interface program. If you're gonna run Arch, you might as well learn to use fdisk!

3) Since I used fdisk, I now had two partitons: one with 39GB (/dev/sda1) which I had to turn into a ext4 root partition and one with 1GB (/dev/sda2) which I had to turn into my swap partition. Now this is very easy:

mkfs -t ext4 /dev/sda1

The above command creates a ext4 file system on /dev/sda1.

mkswap /dev/sda2

The above command creates swap area on /dev/sda2.

swapon /dev/sda2

The above command activates the swap area.

INSTALLING A BASE SYSTEM

Now we're ready to install a base system. But before that, we'll need to get the internet connection working. The easiest way (and the way I did it) is having a cabled connection to a router running a DHCP server. After getting networking working, we have to mount the root partition somewhere on our basic system, copy stuff there and then chroot into it.

4) Next we mount the hdd on /mnt of our system:

mount /dev/sda1 /mnt

5) Then we ask for a IP address from the DHCP server:

dhclient

If you wish to use a static ip address, check Archwiki for more details.

Now, before proceeding let's test if the internet connection in working:

ping -c 3 google.com

If all goes well, we can proceed.

6) Now we can install a very basic system to our hdd that is mounted on /mnt:

pacstrap /mnt base base-devel grub-bios

7) Next we have to generate a fstab file. To do it:

genfstab -p /mnt >> /mnt/etc/fstab

8) Now we're ready to chroot into our new system! In case you don't know what chroot is, check out Archwiki. Anyway, now we do:

arch-chroot /mnt

9) We're almost there! Now we're on the root of our new system! There's a lot of quick stuff to do:

9.1) Write your hostname to /etc/hostname file. Just type anything you want, mine was hp-laptop (creative right?).

9.2) Symlink /etc/localtime to /usr/share/zoneinfo/Zone/SubZone. Replace Zone and Subzone to your liking. In my case:

ln -s /usr/share/zoneinfo/America/Recife /etc/localtime

9.3) Set locale in /etc/locale.conf. Even though I'm Brazilian I use default english US as my locale (I don't want software translated). So I just wrote "LANG="en_US.UTF-8"" to my /etc/locale.conf, without the outter quotes.

For my Brazilian friends, these might work:

LANG="pt_BR.UTF-8"
LANG="pt_BR ISO-8859-1"


9.4) Add console keymap and font preferences in /etc/vconsole.conf. Check the Archwiki for more details. I used:

KEYMAP=br-abnt2
FONT=default8x16

9.5) Uncomment the selected locale in /etc/locale.gen and generate it with locale-gen:

locale-gen

9.6) Now we have to configure /etc/mkinitcpio.conf and create an initial RAM disk. I used the default one, except that I added consolefont keymap to the end of the HOOKS array. Then we have to run:

mkinitcpio -p linux

Great! RAM disk is created, now we only need to install and configure grub2 so we can reboot and have a very basic system!

9.7) Now, to install grub2 on the MBR (Master boot record) of the hdd:

modprobe dm-mod
grub-install --target=i386-pc --recheck --debug /dev/sda
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo


Now we have to edit /etc/default/grub and add the following to the GRUB_CMDLINE_LINUX line:

init=/bin/systemd

Also, I took quiet out of the GRUB_CMDLINE_LINUX line.

This will make your system run on a systemV/systemd hybrid setup. Later we'll make it systemd pure!

9.8) Now we have to make the grub config file:

grub-mkconfig -o /boot/grub/grub.cfg

Grub2 should be working! Now we only need...

9.9)... to setup a root password!

passwd

9.10) Now we get out of the chroot environment with Crtl+D and unmount the hd file system:

umount /mnt

Now we can reboot!

reboot

Now take that cd out of the drive and grub2 should boot!

RUNNING A SYSTEMD PURE SYSTEM!

10) Ok, so now systemd is getting its info of which daemons to run from the /etc/rc.conf file and we'll fix that. The deafult rc.conf file only has 3 daemons on the DAEMONS array: syslog-ng, network, crond. What we'll do is enable these services on systemd so we can ditch the rc.conf file:

systemclt enable syslog-ng
systemclt enable cronie
systemclt enable dhcpcd@eth0


Like I said, I have a router with a DHCP server, so the last line means exactly that: ask the DHCP server for an ip address. If you're using static ip address, check the Archwiki.

I'd like to spend some time here and explain something really important. In Arch, on the contrary of Debian, Ubuntu, Fedora, etc, the system will only run programs you tell it to run. I mean, on the course of this tutorial we'll install some other daemons and for each one we'll have to enable them manually. I (and I reckon all other Archers :P) like this because everything that's running it's because you told the system to do so.

Now reboot just to check if everything is working (and it should be!)

11) Now remove the init=/bin/systemd entry on /etc/default/grub and run:

grub-mkconfig -o /boot/grub/grub.cfg

12) Configure the package manager (pacman) by editing /etc/pacman.conf. I didn't change the default settings for now. I just ran:

pacman -Syy
pacman -Syu


13) Now, for a pure systemd system:

pacman -Rsn initscripts
pacman -S systemd-sysvcompat


Now reboot. If your computer booted (and it should have), then you're running a pure systemd system. Enjoy the full speed boot!

ADDING A USER, SOUND, VIDEO, ETC.

All right! Now he have a base system booting with grub and systemd. Now we can add a regular user (you shouldn't run as root!), sound, video, wifi, desktop environment / window manager, apps, etc.

14) Firstly, we add our usual user :P. Just run the command below and change the last word "username" for the username that you want.

useradd -m -g users -G audio,games,lp,optical,power,scanner,storage,video -s /bin/bash username

To add a password:

passwd username password

Of course, change "username" for your username and "password" for your password. :P

15) Ok, so you created your username, but having to change to root everytime you need root access is a pain. Let's install sudo:

pacman -S sudo

Now we have to edit the /etc/sudoers file and add the regular user's username to the list of sudoers. Simply run:

visudo

You should always edit the sudoers file using visudo because after editing it, it checks the file for any errors. Also, learn to use vi (or vim), I am begining to and I can already see why people like it so much.

Now, just below this line:

root ALL=(ALL) ALL

Add:

username ALL=(ALL) ALL

Again, change username to your username. Great, now we have sudo installed, so type:

exit

And login using your username and passy. Now we can use sudo everytime we need root access.

16) Ok, now we'll get sound working. But before that I'll explain the very basics of how to use pacman, Arch's awesome package manager. I'll just show the most basic commands: install packages, search packages, remove packages and do system upgrades. You'll get to learn how to use pacman by using it later. So, the basic commands:

To install packages:
pacman -S package1 package2 package3...
You can install any number of packages you want using a single line.

To search for packages to install:
pacman -Ss string
string can be the package name or discription. Each package has a brief discription and this command searches these discriptions. Any matches are then displayed.

To uninstall packages:
pacman -Rsn package1 package2 package3...
The -R is for removal, s for removing any unnecessary dependencies and n for removing the configuration files of all packages removed.

To fully upgrade the system:
pacman -Suy
Remember: Arch is a rolling release bleeding-edge distro. Before updating, check the forums to see if any new package is braking peoples systems. It NEVER happened to me, but some people have complained about it, so you never know.

Back to the tut: simply install the alsa packages by running the command below:

sudo pacman -S alsa-utils alsa-plugins alsa-oss
alsamixer


I can't remember if alsamixer has to be run as root or not. Try as your regular user, if that doesn't work, then sudo it. A ncurses user interface is shown to you, so set your volumes and unmute the channels. Now run:

sudo alsactl store

I had to reboot my laptop at this point so my channels would actually unmute.

17) Now we have to install X server and the video driver! Easy enough:

sudo pacman -S xorg-server xorg-xinit xorg-server-utils mesa mesa-demos

Now we need to find out which graphics card the computer has by doing:

lspci | grep -i vga

Mine is a ATI XPRESS 200M 5955 so I have to install the ATI driver. In my case:

sudo pacman -S xf86-video-ati

To get a list of available drivers do:

sudo pacman -Ss xf86-video | less

Hit q to quit. Now you probably know which driver to install. These are open-source drivers. If you want to install proprietary ones, check the Archwiki for the particular manufacturer of your graphics card.

18) Since I'm installing Arch on a laptop, I need synaptics for the touchpad:

sudo pacman -S xf86-input-synaptics

I used the "default" configuration listed on Archwiki. Simply add those lines to /etc/X11/xorg.conf.d/10-synaptics.conf:

To properly setup your keyboard on X, paste the contents of this link on /etc/X11/xorg.conf.d/10-evdev.conf

The "XkbLayout" and "XkbVariant" values depend on your keyboard mapping. Check Archwiki for more info, but everything you need to know is the /usr/share/X11/xkb/rules/base.lst file. You'll figure it out. At first I used "br" and "nodeadkeys" for "XkbLayout" and "XkbVariant", respectively. But the ^'~ type chacracters did not work well (for portuguese writng, that is). To fix it, I just took the "XkbVariant" out.

19) Now we install 3 more basic X packages and then we're ready to test X:

sudo pacman -S xorg-twm xorg-xclock xterm

Make sure there is no .xinitrc file on your user's home folder:

make sure: rm ~/.xinitrc

Now we can test X by running:

startx

You should see 3 terminals running. Exit the leftmost of them and you'll return to the CLI. If X failed, try to reboot and try again. If it still doesn't run, you (or me!) probably forgot to do (write) something. But everything should be ok.

20) Now we install some fonts to make our future desktop look better :)

sudo pacman -S ttf-dejavu ttf-inconsolata ttf-liberation ttf-ubuntu-font-family

21) Ok, so now I had to get AUR (Arch User Repository) working because my wifi card is really annoying and I need some aur packages to get it working. So, what is AUR you ask, it's a repository with packages made by fellow Archers that are good enough to help us less knownledgeable users to get software that's not on the main arch repos.

To get AUR working, just add this to end of your /etc/pacman.conf file:

[archlinuxfr]
Server = http://repo.archlinux.fr/$arch


Now run:

sudo pacman -S pacman-color yaourt

pacman-color is a cool program: it's pacman, with colors! :P

To use it more easily simply alias it to pacman so it gets executed instead of the regular pacman when you call pacman. Simply add this to the end of the ~/.bashrc file:

alias pacman='sudo pacman-color'

This way, everytime you type pacman, the shell interprets as being "sudo pacman-color". Cool right?

yaourt is the program used to install, update, search and remove aur packages. It has the same syntax of pacman but you should NEVER run it as root!

So, my wifi card is (just ran lspci | grep -i wireless):

Network controller: Broadcom Corporation BCM4318 [AirForce One 54g] 802.11g Wireless LAN Controller (rev 02)

I needed to install the package b43-firmware from aur:

pacman -Suy
yaourt -S b43-firmware


Also, I blacklisted b43legacy module by adding "blacklist b43legacy" (wthout the quotes) to the file /etc/modprobe.d/wifi.conf

Wifi cards are always a pain, I do expect that your wifi card setup isn't as bad as mine. Anyway, the wifi led on the laptop went on but configuring a wifi card on CLI is a pain so I waited till my window manager (Fluxbox!) was installed so I could do it on a graphical environment.

22) Now that we have a basic system with pacman and network we're ready to install Display Managers, Desktop Environments or Window Managers and all kinds of applications! Like I said in the very first paragraph of this post: this is a matter of personal taste. You can use any programs you feel comfortable. Wanna use KDE, install KDE. Wanna use Gnome, install Gnome.

For now, let's focus on the DE/WM and DM. As I already said, I'm gonna use Fluxbox as my WM. To install it:

pacman -S fluxbox

Secondly, let's install the Display Manager. I chose (as always) SLiM. As the name says, it's the slimmest DM I know, and since the only thing a DM does is manage your logins, I see no purpose on having a fancy DM. So, to install SLiM (and some themes that go well with it):

pacman -S slim slim-themes archlinux-themes-slim

Now, to configure SLiM (we will configure Fluxbox once we boot into it) we just have to edit /etc/slim.conf. It's all there, but I usually change just two lines (and remove the # from the begining of the lines, where applicable): default_user (change it to you own instead of the one written there) so that when SLiM boots your username is already typed and current_theme (you can choose themes from /usr/share/slim/themes, but always use the "archlinux-simplyblack" theme).

Next we copy the default .xinitrc file to your user's home dir:

cp /etc/skel/.xinitrc ~/.xinitrc

Then we have to add a line at the end of ~/.xinitrc so that SLiM can launch the WM/DE that we have installed. In this case:

exec ck-launch-session startfluxbox

We have to add the ck-launch-session to get automount to work (as in automounting USB keys, DVDs, etc.).

Only one more step to go, enable SLiM on systemd:

sudo systemctl enable slim.service

If we rebooted the computer now, then SLiM would boot and after logging in SLiM would execute Fluxbox. But, let's stick to command line some more.

23) Since I'm on a notebook, I need a wifi connection manager. I'll use wicd. To install it:

pacman -S wicd wicd-gtk

To make wicd starts after boot, well add it to systemd's services:

sudo systemctl enable wicd.service

24) Now let's make sure our clock will always be synced. Let's install ntpd (NTP Daemon):

pacman -S ntp

Now we edit /etc/ntp.conf

And since I'm in South-America I added the following to my ntp.conf:

server 0.south-america.pool.ntp.org iburst
server 1.south-america.pool.ntp.org iburst
server 2.south-america.pool.ntp.org iburst
server 3.south-america.pool.ntp.org iburst

To know the actual server of your continent check this out.

Now we add ntpd to systemd's services:

sudo systemctl enable ntpd.service

25) This step is optional though. There's one program I found out about recently called preload. This program "learns" which other programs you most often use and preloads some libraries they need to RAM, making them startup faster. Since I'm going for a "minimalistic" install (it could get more minimalistic, but for me this is minimalistic enough), I have some RAM to spare, and since the processor and hdd of this laptop are slow, preload comes in handy. To install it:

pacman -S preload

As usual, we add this to systemd's services:

sudo systemctl enable preload.service

I didn't mess with the config, but if you're willing, it's located in /etc/preload.conf

26) Fantastic! Now the only thing missing are the actual programs, icons, etc. we're going to use! Again, this is a matter of personal taste. If you want chromium as your browser instead of firefox, just install it and leave firefox out. To find out the name of the package of a certain program/icon them/font/etc just use:

pacman -Ss search_string

I'll list the programs I installed like this:

"Category" or "Why do I need it" - package(s) name

Also, Archwiki has a page that lists some common programs you may want. So, let's begin.

Makes it easier configuring the UI - lxappearance

Icon themes - gnome-icon-theme gnome-icon-theme-extras hicolor-icon-theme human-icon-theme tangerine-icon-theme azenis-icon-theme

Cursor themes - xcursor-vanilla-dmz xcursor-vanilla-dmz-aa xcursor-themes xcursor-bluecurve xcursor-flatbed xcursor-premium xcursor-flatbed xcursor-pinux

Bittorrent client - transmission-gtk

Web browser (Uzbl as main and Firefox as fallback) - uzbl-core uzbl-browser firefox

Download manager - fatrat

FTP client - filezilla

Picture viewer (feh can be used to set backgrounds easily) - gpicview feh

Take screenshots (just do import /path/to/file.jpg to take a screenshot, but actually, imagemagick does much more) - imagemagick

Music player - audacious

Video player - vlc

CD/DVD burning - xfburn

Un/compress utilities - p7zip file-roller unrar unzip

Run graphical programs as root - gksu

File manager (PCManFM) + ability to mount samba shares - pcmanfm gamin gvfs gvfs-smb smbclient

PDF reader - evince

Office suite - libreoffice

SSH client - putty

Calculator - galculator

Conky (needs no introduction I guess) - conky

Terminal emulator - roxterm

Text editor (like I said, I'm trying to learn vi(m), for a more usual program, you could get leafpad or mousepad) - gvim

NOTE: givm package now includes vim.

Programming IDE - geany

Task manager - lxtask

Screensaver (and lock screen!) - xscreensaver

Volume icon for the system tray (not needed if you install some fancy DE like gnome or KDE) - volumeicon

Battery indicator (form AUR) - sudo yaourt -S slimebattery-git

Java, flash and other plugins - jre7-openjdk jr7-openjdk-headless icedtea-web-java7 flashplugin gecko-mediaplayer gstreamer0.10-plugins

NOTE: I had to install jr7-openjdk-headless twice on the first time it was in conflict with some other package I can't remember.

Ok! That was a lot of packages. To install all that:

pacman -S lxappearance gnome-icon-theme gnome-icon-theme-extras hicolor-icon-theme human-icon-theme tangerine-icon-theme azenis-icon-theme xcursor-vanilla-dmz xcursor-vanilla-dmz-aa xcursor-themes xcursor-bluecurve xcursor-flatbed xcursor-premium xcursor-flatbed xcursor-pinux transmission-gtk uzbl-core uzbl-browser firefox fatrat filezilla gpicview feh imagemagick audacious vlc xfburn p7zip file-roller unrar unzip gksu pcmanfm gamin gvfs gvfs-smb smbclient evince libreoffice putty galculator conky roxterm gvim geany lxtask xscreensaver volumeicon jre7-openjdk jr7-openjdk-headless icedtea-web-java7 flashplugin gecko-mediaplayer gstreamer0.10-plugins

sudo yaourt -S slimebattery-git


27) One final thing before booting into Fluxbox: to get wicd's icon, slime's icon and volumeicon's icon to show on the system tray and to make xscreensaver launch on startup, one just has to add the following to ~/.fluxbox/startup file (to find out where it should go, just read the file):

wicd-client -t &
xscreensaver -nosplash &
slimebattery --change-icon --interval 60 &
volumeicon &


That "--interval 60" option on slime means that the battery charge level will be updated every 60 seconds.

28) Now we're ready to boot into Fluxbox (or whatever DE/WM ytou chose). Just:

sudo reboot

And login!

29) Great, now you logged in to you DE/WM. Congrats. Now the only thing that needs to be done is configuring your DE/WM. As for configuring Fluxbox, I did something very similar to my post "Fluxbox: I liked it! :)" (post before the previous one). To get more Fluxbox styles, check this page out. To install styles, simply copy them to ~/.fluxbox/styles.

Also, the default menu is very poor. To make a new one, firstly you can do the following:

pacman -S archlinux-xdg-menu
xdg_menu --fullmenu --format fluxbox --root-menu /etc/xdg/menus/arch-applications.menu >~/.fluxbox/menu


And then you edit your ~/.fluxbox/menu to include your custom entries.

30) One last optional thing: after configuring everything, I ran conky and the CPU's frequency was set to 800MHz, but the rated frequency of this laptop's CPU is 1600MHz. After some researching, I found out that CPU scaling is enabled by default in current kernels (remember Arch is bleeding edge!) and it works like this: until your CPU reaches a certain load, the kernel keeps it in a low frequency state and when the load increases, it increases the CPU's frequency, that's called the "on-demand" governor, and that's the default setting set by the kernel. I'm ok with that, since lower frequency means less energy spent. But I wanted to have a way to fix it anyway, I wanted to find a way to set my governor to "performance" (rated frequency at all times). All details are here. So I just needed to install the cpupower daemon and make sure that systemd was told to run it as startup. So, here are the commands:

sudo pacman -S cpupower
sudo systemclt enable cpupower.service


And to switch between "on-demand" and "performance" governors I just added the following to my ~/.fluxbox/keys file.

Mod4 p :ToggleCmd {Exec sudo cpupower frequency-set -g ondemand} {Exec sudo cpupower frequency-set -g performance}

That means that pressing the super key + p switches between the "on-demand" and "performance" governors. Of course, I had to add to add the following to my sudoers file:

myusername ALL=NOPASSWD:/sbin/shutdown,/sbin/reboot,/usr/bin/cpupower

Or else I'd have to keep inputting my password. The shutdown and reboot commands are there also so I can use those commands on Fluxbox's menu without supplying password (see my "Fluxbox: I liked it! :)" post)

31) One final tip: it's possible to issue Fluxbox commands through bash shell using the fluxbox-remote command. I used on a script that sets my VGA-out. Everytime I returned to the native resolution of my LCD screen Fluxbox would display the task bar in the middle of the screen. It can be easily set it back to it's right place by issuing the Reconfigure command on Fluxbox's menu, but I wanted to include this on the script so it would be done automatically. Anyway, here's the command I used on the script:

fluxbox-remote Reconfigure

It took me a while to find this command. I found it on the Arch Forum but I could not find it on the Fluxbox documentation.

32) I think that's it. That's the longest post I ever did, it took me around 4 nights (kinda) to get it done and I hope it helps someone. If you have any doubts about this "tutorial" (it's a lot of info!) you can drop a comment and I'll try to help.

In the end, here's my clean desktop :P


Arch is indeed fast. Not because it's actually faster than other distros, it's just because it runs what you tell it to run, no more, no less. Just so we can get a rough figure, on my post "Fluxbox: I liked it! :)" I wrote the RAM used just after logging in on Xubuntu and on my "Xubuntu turned Fluxbox" lappy. Just so you know, here are the number again:

Xubuntu (with compositing disabled) - 165.1 MB
"Xubuntu turned Fluxbox" - 95.8 MB
Archlinux with Fluxbox described above (and with preload running) - 69.3 MB

This old lappy is blazing fast again. :)

PS: I know that I said I was gonna try Slackware, and I was really gonna, but when I looked it up on the web, I found out that the Slackware team is already almost launching Slackware 14 (rememebr that was two-three weeks ago. Funny though, TODAY, Slackware 14 was released.

Wednesday, September 5, 2012

Arch update. (A.K.A Begone laziness!)

On july 20th, the Arch Linux developers announced that Grub legacy would not be supported anymore. On july 30th they announced that the default format of the main config file, /etc/rc.conf, has been changed. The reason of this change was to "unify the configuration of systemd and initscripts". Since I knew what initscripts were, I asked myself: wtf is systemd? A visit to the Arch wiki answered my question but I was too lazy to change anything. A few weeks passed and while I was watching a show I recently found out about, Linux Action Show, one of the news they were talking (season 23 episode 04) about was that Arch was probably gonna move to systemd. I went on the forums and there was a lot of talk about systemd. How fast it was, how many problems it was causing to some users, etc. I also read the arch-dev-public mailing list (this is the email that apparently started it all, the news that is) and well... I knew I had some work to do. I had to:

1) Ditch Grub legacy and install Grub2;
2) Update my rc.conf and create other needed files;
3) Switch to systemd.

As always, Arch wiki was a great source of information. Everything I needed was there. The switch from Grub legacy to Grub2 was very smooth (I even set a Arch wallpaper on the Grub screen). Updating my rc.conf (and creating the other files) was also smooth, just followed the wiki. I backed up all the files I had to alter but, like I said, these changes were very smooth and I ended up not using the back ups.

Now for systemd: followed the wiki and everything worked, except my samba server. But, 5 minutes later, using our good friend google, I found out that I needed to enable the nmbd daemon (the netbios name server). Easy enough: sudo systemctl enable nmbd.service. I had forgotten about it. A 5 minute fix, I'd also call this a smooth transition.

Arch Linux is a fantastic distro. Well documented and well "put-together". Not a single hitch in such a important upgrade.

One note on systemd: it is fast! My boot time got significantly faster. This is due to the fact that systemd knows which service (daemons) needs which service and starts what it can simultaneously.

And you fellow Archer, who's been lazy to adhere to the new configs Arch has been using, you should just get it over with. Took me around one afternoon to read and actually do all the stuff I described. And who knows when Arch will drop the support for the legacy rc.conf format and systemV initscripts?