RPi:ArchLinuxOld: Difference between revisions

From Wiki³
m (Kyau moved page RPi:ArchLinux to RPi:ArchLinuxOld without leaving a redirect)
 
(79 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{DISPLAYTITLE:Raspberry Pi - Arch Linux Install Notes}}
{{DISPLAYTITLE:Raspberry Pi - Arch Linux Install Notes}}
<div id="tocalign">__TOC__</div>
<div id="tocalign">__TOC__</div>
<span class="plainlinks">


= Image SD Card =
= Image SD Card =
Download and image your SD Card with the image located at [http://archlinuxarm.org/platforms/armv6/raspberry-pi Arch Linux ARM].
Download and image your SD Card with the image located at <span class="plainlinks">[http://archlinuxarm.org/platforms/armv6/raspberry-pi Arch Linux ARM]</span>.


'''Linux'''
'''Linux'''
Line 12: Line 11:
'''Windows'''
'''Windows'''


Download and install [https://launchpad.net/win32-image-writer Win32DiskImager].
Download and install <span class="plainlinks">[https://launchpad.net/win32-image-writer Win32DiskImager]</span>.


= Initial Boot & Configuration =
= Initial Boot & Configuration =
First we need to update the system to make sure everything is current. Login to the system using the {{Mono|root}} account with the default password of {{Mono|root}} and run {{Mono|[https://www.archlinux.org/pacman/pacman.8.html pacman]}} to update the system. After this it is safe to reboot to enact the changes.
Go ahead and plug the SD Card back into the Raspberry Pi (RPi) and boot it up. You will eventually be greeted with the Arch Linux login prompt. Login to the system using the {{Mono|root}} account with the default password of {{Mono|root}}. Before you do anything it would be a good idea to change the root password.
 
{{Code|passwd}}
 
== System Update ==
First we need to update the system to make sure everything is current. Before you do so it would be a good idea to edit the {{Mono|/etc/pacman.d/mirrorlist}} in order to select a mirror that is closest to your location. I have found that the default auto-selection mirror doesn't work that well. Un-comment the mirror that best suits your location.
 
{{Code|vi /etc/pacman.d/mirrorlist}}
{{Note|1=
<nowiki>#Server = http://mirror.archlinuxarm.org/armv6h/$repo
...
Server = http://ca.us.mirror.archlinuxarm.org/armv6h/$repo</nowiki>}}
 
You can also take this time to enable the {{Mono|Color}} option in the {{Mono|/etc/pacman.conf}} if you like.
 
{{Code|vi /etc/pacman.conf}}
{{Note|1=
<nowiki># Misc options
#UseSyslog
Color
#TotalDownload
CheckSpace
#VerbostPkgLists</nowiki>}}
 
Run <span class="plainlinks">{{Mono|[https://www.archlinux.org/pacman/pacman.8.html pacman]}}</span> to update the system. After this it is safe to reboot to enact the changes.


{{Code|pacman -Syu}}
{{Code|pacman -Syu}}
Line 21: Line 44:
{{Code|systemctl reboot}}
{{Code|systemctl reboot}}


Now that the system is up to date we can install {{Mono|[https://aur.archlinux.org/packages/packer/ packer]}} and update the RPi firmware/kernel to the latest version. In addition to this we will be installing {{Mono|[https://github.com/bavison/arm-mem arm-mem]}}, which contains special modified versions of certain system functions (memcpy/memset/strcpy) to increase overall performace on the RPi, and a few utilities. Then again reboot the machine to enact the changes.
Now that the system is up to date we can install <span class="plainlinks">{{Mono|[https://aur.archlinux.org/packages/packer/ packer]}}</span> and update the RPi firmware/kernel to the latest version. In addition to this we will be installing <span class="plainlinks">{{Mono|[https://github.com/bavison/arm-mem arm-mem]}}</span> which are ARM-accelerated versions of selected functions from string.h. Then again reboot the machine to enact the changes.


{{Code|pacman -S packer arm-mem-git linux-headers-raspberrypi-latest linux-raspberrypi-latest vim colordiff}}
{{Code|pacman -S packer arm-mem-git linux-raspberrypi-latest linux-raspberrypi-latest-headers vim}}


{{Code|systemctl reboot}}
{{Code|systemctl reboot}}
== Configuration ==


Upon login you should be able to see that you are now running the latest available kernel version. I now take the time to setup the actual system itself as if you just rebooted into a fresh Arch Linux installation.
Upon login you should be able to see that you are now running the latest available kernel version. I now take the time to setup the actual system itself as if you just rebooted into a fresh Arch Linux installation.


Begin by setting the hostname. I will be using the hostname {{Mono|archey}}.
=== Wireless ===
 
After you have the RPi running the Linux kernel 3.x you will now have 8188eu wireless support. Next setup the wireless adapter for your local network.
 
{{Code|cd /etc/netctl}}
 
{{Code|cp examples/wireless-wpa wireless-home}}
 
{{Code|vim wireless-home}}
 
Fill in your ESSID and Key, save the file and then change the permissions.
 
{{Code|chmod 640 wireless-home}}
 
Next you can start up the interface and test your network connectivity (after unplugging your LAN connection).
 
{{Code|netctl start wireless-home}}
 
{{Code|ping google.com}}
 
If all goes well go ahead and enable it permanently.
 
{{Code|netctl enable wireless-home}}
 
=== Hostname ===
 
Begin by setting the hostname. I will be using the hostname {{Mono|archey.kyau.net}}.
 
{{Code|hostnamectl set-hostname archey.kyau.net}}


{{Code|hostnamectl set-hostname archey}}
=== Timezone ===


Set the timezone. For me this is {{Mono|US/Pacific}}.
Set the timezone. For me this is {{Mono|US/Pacific}}.
Line 37: Line 90:
{{Code|timedatectl set-timezone US/Pacific}}
{{Code|timedatectl set-timezone US/Pacific}}


Setup the appropriate locale. First edit the {{Mono|/etc/locale.gen}} file and un-comment the lines that correspond to your language selection. Generate the needed locales and finally set the with the system.
=== Locale ===
 
Setup the appropriate locale. First edit the {{Mono|/etc/locale.gen}} file and un-comment the lines that correspond to your language selection. Generate the needed locales, set you keymap and finally set the with the system.


{{Code|vim /etc/locale.gen}}
{{Code|vim /etc/locale.gen}}
Line 44: Line 99:
en_US.UTF-8}}
en_US.UTF-8}}
{{Code|locale-gen}}
{{Code|locale-gen}}
{{Code|localectl set-keymap us}}


{{Code|localectl set-locale LANG{{=}}"en_US.UTF-8"}}
{{Code|localectl set-locale LANG{{=}}"en_US.UTF-8"}}
=== Time/Date Syncing ===


Finally we can install and enable {{Mono|ntp}}. This is not required but as the RPi does not have a hardware clock it is useful to use a time syncing service.
Finally we can install and enable {{Mono|ntp}}. This is not required but as the RPi does not have a hardware clock it is useful to use a time syncing service.
Line 51: Line 110:
{{Code|pacman -S ntp}}
{{Code|pacman -S ntp}}


{{Code|systemctl enable ntp}}
{{Code|systemctl enable ntpd}}
 
== User Management ==
 
With the system configuration out of the way it is time to create a user account, install {{Mono|sudo}}, give the user full access to {{Mono|sudo}} and then log off the {{Mono|root}} account. I will be using the username {{Mono|kyau}} for the extent of this write-up. Finally we can also change the root password.
 
{{Code|useradd -m -g users -s /bin/bash kyau}}
 
{{Code|passwd kyau}}
 
{{Code|pacman -S sudo}}
 
{{Code|visudo}}
{{Note|1=
kyau ALL=(ALL) NOPASSWD: ALL}}
 
{{Code|passwd}}
 
At this point you can again safely shutdown the RPi. Once you see only the red LED lit you can safely pull the power.
 
{{Code|systemctl poweroff}}
 
= Parition Management =
 
Next you will need to decide what you will be using as the main drive. If all you have is an SD Card use the second option. However if you plan on experimenting with overclocking or you happen to have an external USB hard drive or USB flash drive that is of adequate size it will be better in the long run to use this as your main drive instead. No matter which method you use you will always need an SD Card for at bare minimum the {{Mono|/boot}} partition.
 
== Main Drive: USB Drive (OC-Friendly) ==
 
If you are going to be using a USB hard drive you should really consider moving the Arch install to the USB hard drive. This will increase overall speed of the RPi and give you the option of overclocking as you will no longer be limited by SD corruption. Start by plugging your SD Card and USB hard drive into a separate Linux machine.
 
=== Partitioning ===
 
Pull up a list of all partition table information and locate the USB hard drive.
 
{{Code|fdisk -l}}
 
Then launch fdisk on the USB hard drive. In my case this happens to be {{Mono|/dev/sdb}}.
 
{{Code|fdisk /dev/sdb}}
 
Start by refreshing the drive to a DOS partition table, then create three partitions: a 15GB root partition, a 1GB swap partition, and finally the rest of the drive for the media partition.
 
{{Note|1=
<nowiki>Welcome to fdisk (util-linux 2.23.2).
 
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
 
 
Command (m for help): o
Building a new DOS disklabel with disk identifier 0x2c00a6a4.
 
Command (m for help): n
Partition type:
  p  primary (0 primary, 0 extended, 4 free)
  e  extended
Select (default p): p
Partition number (1-4, default 1):
First sector (256-976754644, default 256):
Using default value 256
Last sector, +sectors or +size{K,M,G} (256-976754644, default 976754644): +15G
Partition 1 of type Linux and of size 15 GiB is set
 
Command (m for help): n
Partition type:
  p  primary (1 primary, 0 extended, 3 free)
  e  extended
Select (default p): p
Partition number (2-4, default 2):
First sector (3932416-976754644, default 3932416):
Using default value 3932416
Last sector, +sectors or +size{K,M,G} (3932416-976754644, default 976754644): +1G
Partition 2 of type Linux and of size 1 GiB is set
 
Command (m for help): n
Partition type:
  p  primary (2 primary, 0 extended, 2 free)
  e  extended
Select (default p): p
Partition number (3,4, default 3):
First sector (4194560-976754644, default 4194560):
Using default value 4194560
Last sector, +sectors or +size{K,M,G} (4194560-976754644, default 976754644):
Using default value 976754644
Partition 3 of type Linux and of size 3.6 TiB is set</nowiki>}}
 
Next change the partition type of the swap partition.
 
{{Note|1=
<nowiki>Command (m for help): t
Partition number (1-3, default 3): 2
Hex code (type L to list all codes): 82
Changed type of partition 'Linux' to 'Linux swap / Solaris'</nowiki>}}
 
Finally write the changes to the drive and format the partitions.
 
{{Note|1=
<nowiki>Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.</nowiki>}}
 
{{Code|mkfs.ext4 /dev/sdb1}}
 
{{Code|mkfs.ext4 /dev/sdb3}}
 
{{Code|mkswap /dev/sdb2}}
 
=== Clone the Current System ===
 
Then mount the old and new system partitions and copy over the existing Linux installation.
 
{{Code|mount /dev/sdb1 /mnt/usb}}
 
{{Code|mount /dev/sdd5 /mnt/tmp}}
 
{{Code|cd /mnt/tmp && cp -a * /mnt/usb}}
 
When finished un-mount both partitions and then mount the {{Mono|/boot}} partition from the SD Card.
 
{{Code|cd && umount /mnt/&#123;usb,tmp&#125;}}
 
{{Code|mount -t vfat -o rw,noauto,async,user,umask{{=}}1000 /dev/sdd1 /mnt/tmp}}
 
You will need to edit the {{Mono|cmdline.txt}} file and modify the boot line to boot off of the USB Drive instead of the the SD Card. If the USB Drive is the only external drive plugged into the RPi this will be {{Mono|/dev/sda}}.
 
{{Code|vi /mnt/tmp/cmdline.txt}}
{{Note|1=
<nowiki>ipv6.disable=1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=noop rootwait</nowiki>}}
 
You can now un-mount the SD Card and re-plug them into your RPi and continue.
 
{{Code|cd && umount /mnt/tmp}}
 
=== Finalizing ===
 
Note that when booting off of USB there is an initial delay to initialize the USB drive right after you see the RPi logo. After you boot back into your RPi login and edit the {{Mono|/etc/fstab}} to reflect the new partitions.
 
{{Code|sudo vim /etc/fstab}}
{{Note|1=
<nowiki>#
# /etc/fstab: static file system information
#
# <file system> <dir>  <type>  <options>                      <dump>  <pass>
/dev/sda1      /      ext4    defaults,noatime                0      0
/dev/mmcblk0p1  /boot  vfat    defaults                        0      0
/dev/sda2      none    swap    defaults                        0      0
/dev/sda3      /media  ext4    defaults,noatime,nosuid,user    0      0
tmpfs          /tmp    tmpfs  nodev,nosuid,size=2G            0      0</nowiki>}}
 
Then go ahead and reboot.
 
{{Code|sudo systemctl reboot}}
 
== Main Drive: SD Card ==
 
At this point remove the SD Card from your RPi and plug it into another Linux machine. Given that we used a pre-made image to install Arch Linux onto our SD Card, it came with pre-defined partitions that are not sized to your entire SD Card. To fix this we will be making a backup of the install, then resizing the partition and finally re-formatting it with a different filesystem than before for better SD Card performance.
 
Use the {{Mono|fdisk}} command to display all of your devices and locate the device node of the newly inserted SD Card (it should look similar to below).
 
{{Code|sudo fdisk -l}}
{{Note|1=
<nowiki> &nbsp; Device Boot      Start        End      Blocks  Id  System
/dev/sdc1            2048      186367      92160    c  W95 FAT32 (LBA)
/dev/sdc2          186368    3667967    1740800    5  Extended
/dev/sdc5          188416    3667967    1739776  83  Linux</nowiki>}}
 
=== Backup Current Installation ===
 
First mount the SD Card to a temporary directory, then copy over (with permissions) the entire contents of the partition to a temporary folder.
 
{{Code|sudo mkdir -p {/mnt/rpi,/mnt/rpi-backup/rpi,/mnt/rpi-backup/boot} }}
 
{{Code|sudo mount /dev/sdc5 /mnt/rpi}}
 
{{Code|cd /mnt/rpi}}
 
{{Code|sudo cp -a * /mnt/rpi-backup/rpi/}}
 
When finished un-mount the partition before continuing.
 
{{Code|cd && sudo umount /mnt/rpi}}
 
=== Expand the Linux Partition ===
 
Remembering the device node from earlier, go ahead and open it up in {{Mono|fdisk}}.
 
{{Code|sudo fdisk /dev/sdc}}
 
Remove the Linux and Extended partitions.
 
{{Output|<nowiki>Command (m for help): d
Partition number (1,2,5, default 5): 5
Partition 5 is deleted
 
Command (m for help): d
Partition number (1,2, default 2): 2
Partition 2 is deleted</nowiki>}}
 
Create new partitions using the entirety of the SD Card.
 
{{Output|<nowiki>Command (m for help): n
Partition type:
  p  primary (1 primary, 0 extended, 3 free)
  e  extended
Select (default p): e
Partition number (2-4, default 2):
First sector (186368-61405183, default 186368):
Using default value 186368
Last sector, +sectors or +size{K,M,G} (186368-61405183, default 61405183):
Using default value 61405183
Partition 2 of type Extended and of size 29.2 GiB is set
 
Command (m for help): n
Partition type:
  p  primary (1 primary, 1 extended, 2 free)
  l  logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (188416-61405183, default 188416):
Using default value 188416
Last sector, +sectors or +size{K,M,G} (188416-61405183, default 61405183):
Using default value 61405183
Partition 5 of type Linux and of size 29.2 GiB is set</nowiki>}}
 
Write the changes to the partition table to exit {{Mono|fdisk}}.
 
{{Output|<nowiki>Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.</nowiki>}}
 
=== F2FS ===
F2FS (Flash-Friendly File System) is a file system created by Samsung intended for NAND-based flash memory. In my experience I have better results using this as apposed to ext3/4. If you are modifying the SD Card from an Arch Linux machine simply install the package for F2FS.
 
{{Code|sudo pacman -S f2fs-tools}}
 
Format the new Linux partition on the SD Card with F2FS.
 
{{Code|sudo mkfs.f2fs /dev/sdc5}}
 
Mount the new partition, edit the {{Mono|/etc/fstab}} in the backup to reflect changing to F2Fs and then copy back the Arch Linux installation.
 
{{Code|sudo mount /dev/sdc5 /mnt/rpi}}
 
{{Code|cd /mnt/rpi-backup/rpi}}
 
{{Code|sudo vim etc/fstab}}
{{Note|1=
<nowiki># <file system> <dir>  <type>  <options>      <dump>  <pass>
/dev/mmcblk0p5  /      f2fs    defaults,noatime,discard        0      0
/dev/mmcblk0p1  /boot  vfat    defaults        0      0</nowiki>}}
 
{{Code|sudo cp -a * /mnt/rpi/}}
 
Un-mount the Linux partition. Mount the FAT32 boot partition.
 
{{Code|cd && sudo umount /mnt/rpi}}
 
{{Code|sudo mount -t vfat -o rw,noauto,async,user,umask{{=}}1000 /dev/sdc1 /mnt/rpi}}
 
Edit the {{Mono|cmdline.txt}} file to change the filesystem type from {{Mono|ext4}} to {{Mono|f2fs}}. The file should now look something like the following.
 
{{Note|1=
<nowiki>... console=tty1 root=/dev/mmcblk0p5 rootfstype=f2fs elevator=noop rootwait</nowiki>}}
 
You can now return the SD Card to the RPi and turn it back on. Your RPi will boot into the new F2FS partition which if you check {{Mono|df}} you should confirm it has been expanded to accommodate all the space available on the SD Card.
 
= User Setup =
 
Next I download and restore my RPi home directory backup.
 
{{Code|wget http://kyau.net/kyau-rpi.tar.bz2}}
 
{{Code|tar zxvf kyau-rpi.tar.bz2}}
 
{{Code|rm kyau-rpi.tar.bz2}}
 
Re-login to enact all the changes.
 
= Xorg Install =
 
With the RPi fully configured let's move on to installing Xorg. Before we begin we must install the base development package group in order to build packages on the RPi.
 
{{Code|sudo pacman -S base-devel git}}
 
Then proceed by installing the base for Xorg along with the proper video driver for the RPi.
 
{{Code|sudo pacman -S xorg-server xorg-xinit xorg-server-utils mesa xf86-video-fbdev}}
 
Next install a window manager and some basic applications, themes and fonts.
 
{{Code|sudo pacman -S openbox}}
 
{{Code|sudo pacman -S lxappearance lxappearance-obconf obconf rxvt-unicode terminus-font}}
 
{{Code|sudo pacman -S mirage thunar tumbler thunar-archive-plugin file-roller unrar zip unzip}}
 
{{Code|sudo pacman -S gnome-icon-theme gnome-icon-theme-extras}}
 
{{Code|sudo packer -S gtk-engine-mist elementary-icon-theme gtk-theme-elementary-bzr}}
 
Here you will encounter the first package that refuses to compile, the following message is roughly what you will see.
 
{{Note|1=
<nowiki>==> ERROR: docbook-to-man is not available for the 'armv6h' architecture.</nowiki>}}
 
The solution is actually really quite simple, rerun the install command and this time choose to edit the PKGBUILD of that package. Modify the arch line to look like the following.
 
{{Note|1=
<nowiki>arch=(i686 x86_64 armv6h)</nowiki>}}
 
The package should now build properly, you will encounter this a couple of times during the following steps use this exact method to remedy the problem every time.
 
Packages that need you to edit the PKGBUILD: gtk-engine-mist gtk-theme-elementary-bzr
 
= XBMC =
 
Now that the Arch Linux baseline is finished let's get to installing XBMC.
 
{{Code|sudo packer -S xbmc-rbp-git}}
 
The latest version they forgot to fix some permissions on the RPi with Arch. Let's add these now, create the following file and dump the contents into it.
 
{{Code|sudo vim /etc/udev/rules.d/raspberrypi.rules}}
{{Note|1=
<nowiki>SUBSYSTEM=="vchiq|input", MODE="0777"
KERNEL=="mouse*|mice|event*", MODE="0777"</nowiki>}}
 
== Autologin ==
 
With XBMC installed we can now configure Arch Linux to autologin to your user account.
 
{{Code|sudo mkdir /etc/systemd/system/getty@tty1.service.d}}
 
{{Code|sudo vim /etc/systemd/system/getty\@tty1.service.d/autologin.conf}}
{{Note|1=
<nowiki>[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin kyau --noclear %I 38400 linux
Type=simple</nowiki>}}
 
== Start X at Login ==
 
Finally let's get Xorg starting upon login.
 
{{Code|vim ~/.bash_profile}}
{{Note|1=
<nowiki># Start X at Login
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx</nowiki>}}
 
== Auto-Launch XBMC ==
 
First we will need a utility called {{Mono|fbset}}.
 
{{Code|sudo pacman -S fbset}}
 
The following is a pasted copy of the script I use to launch XBMC on start, I run this script from {{Mono|~/.config/openbox/autostart}}. Modify it accordingly to update your resolution upon exiting XBMC.
 
{{Note|1=
<nowiki>#!/bin/bash
 
xbmc-standalone
sudo fbset -depth 16 -xres 1920 -yres 1080
(sleep 1 && xrefresh)
exit 0</nowiki>}}
 
= Synergy =
 
Synergy is an application that allows you to utilize a single keyboard and mouse on a host computer to then operate multiple client computers from the single host. It is intended for scenarios where each client has its own monitor and will allow you to seamlessly scroll between screens/machines.
 
Install synergy on your host machine. If you need assistance with this there is a great video over at [https://www.youtube.com/watch?feature=player_embedded&v=1TR29vxoxno YouTube].
 
== Host ==
 
Open synergy and click "Configure Server".
 
Then drag one of the monitors in the upper left onto the grid location that represents that client monitors actual position in relation to your host machine.
 
Double click on the new client monitor.
 
Name the screen: archey
 
== Client ==
 
Install {{Mono|synergy}}.
 
{{Code|sudo pacman -S synergy}}
 
Then use {{Mono|synergy}} to connect as a client to your host machine (mine happens to be named {{Mono|chloe}}).
 
{{Code|synergyc --name archey chloe}}
 
If you wish to launch synergy on boot merely add the previous line to your {{Mono|~/.config/openbox/autostart}}.
 
{{Code|vim ~/.config/openbox/autostart}}
{{Note|1=
<nowiki># Set Background Color
xsetroot -solid steelblue4
# Connect to Synergy
(sleep 5 && synergyc --log ~/synergy.log --no-tray --name archey chloe)
# Autostart XBMC
xbmc-start &</nowiki>}}
 
= Samba =
 
If you want the Windows computers on your network to be able to access the media shares you will need to install Samba.
 
{{Code|sudo pacman -S samba}}
 
Then copy the default config file and edit it to reflect your workgroup and a share for {{Mono|/media}}.
 
{{Code|sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf}}
 
{{Code|sudo vim /etc/samba/smb.conf}}
{{Note|1=
<nowiki>[global]
 
# workgroup = NT-Domain-Name or Workgroup-Name
  workgroup = KYAU
 
# server string is the equivalent of the NT Description field
  server string = Archey Media Server
 
...
 
[media]
  comment = Media Library
  path = /media
  public = yes
  read only = yes
  write list = @users</nowiki>}}
 
Setup samba to load on boot and then launch it now.
 
{{Code|sudo systemctl enable smbd}}
 
{{Code|sudo systemctl enable nmbd}}
 
{{Code|sudo systemctl start smbd}}
 
{{Code|sudo systemctl start nmbd}}
 
Finally don't forget to add your user to Samba and change the permissions for your shared folder.
 
{{Code|sudo pdbedit -a -u kyau}}
 
{{Code|sudo chown -R kyau:users /media/}}
 
= Raspberry Pi Tweaks =
 
If you are looking to get more out of your RPi consider doing any or all of the tweaks listed in this section.
 
== RPi Config ==
 
The following is my RPi {{Mono|config.txt}} in its default mode (no overclocking enabled). You will need to un-comment and edit in your license keys and modify the {{Mono|gpu_mem}} parameter accordingly.
 
{{Code|cat /boot/config.txt}}
{{Note|1=
<nowiki>## Memory
 
# Disable ARM access to GPU's L2 cache. Needs corresponding L2 disabled kernel.
#disable_l2cache=1
 
# GPU memory in megabyte. Sets the memory split between the ARM and GPU.
# ARM gets the remaining memory.
gpu_mem=256
 
# Disable adjusting the refresh rate of RAM every 500ms (measuring RAM
# temperature)
#disable_pvt=1
 
 
## CMA - Dynamic Memory Split
 
# When GPU has less than cma_lwm (low water mark) memory available it will
# request some from ARM.
#cma_lwm=16
 
# When GPU has more than cma_hwm (high water mark) memory available it will
# release some to ARM.
#cma_hwm=32


#cma_offline_start=16
## Camera
# Turn off the red camera LED when recording video or taking a still picture.
#disable_camera_led=1
## Video
# Disable overscan if your display has a black border of unused pixels visible
# and your display can output without overscan.
#disable_overscan=1
# Overscan adjusting. Positive numbers if console goes off screen and negative
# if there is too much border.
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# Force a console size, default is display's size minus overscan.
#framebuffer_width=1280
#framebuffer_height=720
# Console framebuffer depth in bits per pixel.
#framebuffer_depth=16
# Disable alpha channel. (helps with 32-bit)
#framebuffer_ignore_alpha=1
# Enable test sound/image during boot for manufacturing test.
#test_mode=1
# Signal strength of the HDMI interface.
#config_hdmi_boost=4
# Rotates the display clockwise on the screen or flips the display.
#display_rotate=1
## Licensed Codecs
# License key to allow hardware MPEG-2 decoding.
#decode_MPG2=0x12345678
# License key to allow hardware VC-1 decoding.
#decode_WVC1=0x12345678
## Boot
# Avoids the rainbow splash screen on boot
disable_splash=1
## Overclocking
##None
#arm_freq=700
#core_freq=250
#sdram_freq=400
#over_voltage=0
##Modest
#arm_freq=800
#core_freq=300
#sdram_freq=400
#over_voltage=0
##Medium
#arm_freq=900
#core_freq=333
#sdram_freq=450
#over_voltage=2
##High
#arm_freq=950
#core_freq=450
#sdram_freq=450
#over_voltage=6
##Turbo
#arm_freq=1000
#core_freq=500
#sdram_freq=500
#over_voltage=6
# vim:ft=conf</nowiki>}}
== XBMC ==
For a noticable difference in performance create the file {{Mono|~/.xbmc/userdata/advancedsettings.xml}} and paste in the following.
{{Code|vim ~/.xbmc/userdata/advancedsettings.xml}}
{{Note|1=
<nowiki><advancedsettings>
    <videolibrary>
        <cleanonupdate>true</cleanonupdate>
    </videolibrary>
    <network>
        <cachemembuffersize>5282880</cachemembuffersize>
    </network>
    <fanartheight>560</fanartheight>
    <thumbsize>256</thumbsize>
    <gui>
        <algorithmdirtyregions>3</algorithmdirtyregions>
        <nofliptimeout>0</nofliptimeout>
    </gui>
    <lookandfeel>
        <enablerssfeeds>false</enablerssfeeds>
    </lookandfeel>
    <bginfoloadermaxthreads>2</bginfoloadermaxthreads>
</advancedsettings></nowiki>}}




</span>
[[Category:Raspberry Pi]]
[[Category:Raspberry Pi]]

Latest revision as of 13:19, 27 July 2017

Image SD Card

Download and image your SD Card with the image located at Arch Linux ARM.

Linux

dd bs=1M if=/path/to/archlinux-hf-2013-07-22.img of=/dev/sdX

Windows

Download and install Win32DiskImager.

Initial Boot & Configuration

Go ahead and plug the SD Card back into the Raspberry Pi (RPi) and boot it up. You will eventually be greeted with the Arch Linux login prompt. Login to the system using the root account with the default password of root. Before you do anything it would be a good idea to change the root password.

passwd

System Update

First we need to update the system to make sure everything is current. Before you do so it would be a good idea to edit the /etc/pacman.d/mirrorlist in order to select a mirror that is closest to your location. I have found that the default auto-selection mirror doesn't work that well. Un-comment the mirror that best suits your location.

vi /etc/pacman.d/mirrorlist

Icon#Server = http://mirror.archlinuxarm.org/armv6h/$repo ... Server = http://ca.us.mirror.archlinuxarm.org/armv6h/$repo

You can also take this time to enable the Color option in the /etc/pacman.conf if you like.

vi /etc/pacman.conf

Icon# Misc options #UseSyslog Color #TotalDownload CheckSpace #VerbostPkgLists

Run pacman to update the system. After this it is safe to reboot to enact the changes.

pacman -Syu

systemctl reboot

Now that the system is up to date we can install packer and update the RPi firmware/kernel to the latest version. In addition to this we will be installing arm-mem which are ARM-accelerated versions of selected functions from string.h. Then again reboot the machine to enact the changes.

pacman -S packer arm-mem-git linux-raspberrypi-latest linux-raspberrypi-latest-headers vim

systemctl reboot

Configuration

Upon login you should be able to see that you are now running the latest available kernel version. I now take the time to setup the actual system itself as if you just rebooted into a fresh Arch Linux installation.

Wireless

After you have the RPi running the Linux kernel 3.x you will now have 8188eu wireless support. Next setup the wireless adapter for your local network.

cd /etc/netctl

cp examples/wireless-wpa wireless-home

vim wireless-home

Fill in your ESSID and Key, save the file and then change the permissions.

chmod 640 wireless-home

Next you can start up the interface and test your network connectivity (after unplugging your LAN connection).

netctl start wireless-home

ping google.com

If all goes well go ahead and enable it permanently.

netctl enable wireless-home

Hostname

Begin by setting the hostname. I will be using the hostname archey.kyau.net.

hostnamectl set-hostname archey.kyau.net

Timezone

Set the timezone. For me this is US/Pacific.

timedatectl set-timezone US/Pacific

Locale

Setup the appropriate locale. First edit the /etc/locale.gen file and un-comment the lines that correspond to your language selection. Generate the needed locales, set you keymap and finally set the with the system.

vim /etc/locale.gen

Iconen_US ISO-8859-1 en_US.UTF-8

locale-gen

localectl set-keymap us

localectl set-locale LANG="en_US.UTF-8"

Time/Date Syncing

Finally we can install and enable ntp. This is not required but as the RPi does not have a hardware clock it is useful to use a time syncing service.

pacman -S ntp

systemctl enable ntpd

User Management

With the system configuration out of the way it is time to create a user account, install sudo, give the user full access to sudo and then log off the root account. I will be using the username kyau for the extent of this write-up. Finally we can also change the root password.

useradd -m -g users -s /bin/bash kyau

passwd kyau

pacman -S sudo

visudo

Iconkyau ALL=(ALL) NOPASSWD: ALL

passwd

At this point you can again safely shutdown the RPi. Once you see only the red LED lit you can safely pull the power.

systemctl poweroff

Parition Management

Next you will need to decide what you will be using as the main drive. If all you have is an SD Card use the second option. However if you plan on experimenting with overclocking or you happen to have an external USB hard drive or USB flash drive that is of adequate size it will be better in the long run to use this as your main drive instead. No matter which method you use you will always need an SD Card for at bare minimum the /boot partition.

Main Drive: USB Drive (OC-Friendly)

If you are going to be using a USB hard drive you should really consider moving the Arch install to the USB hard drive. This will increase overall speed of the RPi and give you the option of overclocking as you will no longer be limited by SD corruption. Start by plugging your SD Card and USB hard drive into a separate Linux machine.

Partitioning

Pull up a list of all partition table information and locate the USB hard drive.

fdisk -l

Then launch fdisk on the USB hard drive. In my case this happens to be /dev/sdb.

fdisk /dev/sdb

Start by refreshing the drive to a DOS partition table, then create three partitions: a 15GB root partition, a 1GB swap partition, and finally the rest of the drive for the media partition.

IconWelcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): o Building a new DOS disklabel with disk identifier 0x2c00a6a4. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): First sector (256-976754644, default 256): Using default value 256 Last sector, +sectors or +size{K,M,G} (256-976754644, default 976754644): +15G Partition 1 of type Linux and of size 15 GiB is set Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): First sector (3932416-976754644, default 3932416): Using default value 3932416 Last sector, +sectors or +size{K,M,G} (3932416-976754644, default 976754644): +1G Partition 2 of type Linux and of size 1 GiB is set Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): First sector (4194560-976754644, default 4194560): Using default value 4194560 Last sector, +sectors or +size{K,M,G} (4194560-976754644, default 976754644): Using default value 976754644 Partition 3 of type Linux and of size 3.6 TiB is set

Next change the partition type of the swap partition.

IconCommand (m for help): t Partition number (1-3, default 3): 2 Hex code (type L to list all codes): 82 Changed type of partition 'Linux' to 'Linux swap / Solaris'

Finally write the changes to the drive and format the partitions.

IconCommand (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

mkfs.ext4 /dev/sdb1

mkfs.ext4 /dev/sdb3

mkswap /dev/sdb2

Clone the Current System

Then mount the old and new system partitions and copy over the existing Linux installation.

mount /dev/sdb1 /mnt/usb

mount /dev/sdd5 /mnt/tmp

cd /mnt/tmp && cp -a * /mnt/usb

When finished un-mount both partitions and then mount the /boot partition from the SD Card.

cd && umount /mnt/{usb,tmp}

mount -t vfat -o rw,noauto,async,user,umask=1000 /dev/sdd1 /mnt/tmp

You will need to edit the cmdline.txt file and modify the boot line to boot off of the USB Drive instead of the the SD Card. If the USB Drive is the only external drive plugged into the RPi this will be /dev/sda.

vi /mnt/tmp/cmdline.txt

Iconipv6.disable=1 selinux=0 plymouth.enable=0 smsc95xx.turbo_mode=N dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 root=/dev/sda1 rootfstype=ext4 elevator=noop rootwait

You can now un-mount the SD Card and re-plug them into your RPi and continue.

cd && umount /mnt/tmp

Finalizing

Note that when booting off of USB there is an initial delay to initialize the USB drive right after you see the RPi logo. After you boot back into your RPi login and edit the /etc/fstab to reflect the new partitions.

sudo vim /etc/fstab

Icon# # /etc/fstab: static file system information # # <file system> <dir> <type> <options> <dump> <pass> /dev/sda1 / ext4 defaults,noatime 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 0 /dev/sda2 none swap defaults 0 0 /dev/sda3 /media ext4 defaults,noatime,nosuid,user 0 0 tmpfs /tmp tmpfs nodev,nosuid,size=2G 0 0

Then go ahead and reboot.

sudo systemctl reboot

Main Drive: SD Card

At this point remove the SD Card from your RPi and plug it into another Linux machine. Given that we used a pre-made image to install Arch Linux onto our SD Card, it came with pre-defined partitions that are not sized to your entire SD Card. To fix this we will be making a backup of the install, then resizing the partition and finally re-formatting it with a different filesystem than before for better SD Card performance.

Use the fdisk command to display all of your devices and locate the device node of the newly inserted SD Card (it should look similar to below).

sudo fdisk -l

Icon   Device Boot Start End Blocks Id System /dev/sdc1 2048 186367 92160 c W95 FAT32 (LBA) /dev/sdc2 186368 3667967 1740800 5 Extended /dev/sdc5 188416 3667967 1739776 83 Linux

Backup Current Installation

First mount the SD Card to a temporary directory, then copy over (with permissions) the entire contents of the partition to a temporary folder.

sudo mkdir -p {/mnt/rpi,/mnt/rpi-backup/rpi,/mnt/rpi-backup/boot}

sudo mount /dev/sdc5 /mnt/rpi

cd /mnt/rpi

sudo cp -a * /mnt/rpi-backup/rpi/

When finished un-mount the partition before continuing.

cd && sudo umount /mnt/rpi

Expand the Linux Partition

Remembering the device node from earlier, go ahead and open it up in fdisk.

sudo fdisk /dev/sdc

Remove the Linux and Extended partitions.

Command (m for help): d Partition number (1,2,5, default 5): 5 Partition 5 is deleted Command (m for help): d Partition number (1,2, default 2): 2 Partition 2 is deleted

Create new partitions using the entirety of the SD Card.

Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): e Partition number (2-4, default 2): First sector (186368-61405183, default 186368): Using default value 186368 Last sector, +sectors or +size{K,M,G} (186368-61405183, default 61405183): Using default value 61405183 Partition 2 of type Extended and of size 29.2 GiB is set Command (m for help): n Partition type: p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5) Select (default p): l Adding logical partition 5 First sector (188416-61405183, default 188416): Using default value 188416 Last sector, +sectors or +size{K,M,G} (188416-61405183, default 61405183): Using default value 61405183 Partition 5 of type Linux and of size 29.2 GiB is set

Write the changes to the partition table to exit fdisk.

Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

F2FS

F2FS (Flash-Friendly File System) is a file system created by Samsung intended for NAND-based flash memory. In my experience I have better results using this as apposed to ext3/4. If you are modifying the SD Card from an Arch Linux machine simply install the package for F2FS.

sudo pacman -S f2fs-tools

Format the new Linux partition on the SD Card with F2FS.

sudo mkfs.f2fs /dev/sdc5

Mount the new partition, edit the /etc/fstab in the backup to reflect changing to F2Fs and then copy back the Arch Linux installation.

sudo mount /dev/sdc5 /mnt/rpi

cd /mnt/rpi-backup/rpi

sudo vim etc/fstab

Icon# <file system> <dir> <type> <options> <dump> <pass> /dev/mmcblk0p5 / f2fs defaults,noatime,discard 0 0 /dev/mmcblk0p1 /boot vfat defaults 0 0

sudo cp -a * /mnt/rpi/

Un-mount the Linux partition. Mount the FAT32 boot partition.

cd && sudo umount /mnt/rpi

sudo mount -t vfat -o rw,noauto,async,user,umask=1000 /dev/sdc1 /mnt/rpi

Edit the cmdline.txt file to change the filesystem type from ext4 to f2fs. The file should now look something like the following.

Icon... console=tty1 root=/dev/mmcblk0p5 rootfstype=f2fs elevator=noop rootwait

You can now return the SD Card to the RPi and turn it back on. Your RPi will boot into the new F2FS partition which if you check df you should confirm it has been expanded to accommodate all the space available on the SD Card.

User Setup

Next I download and restore my RPi home directory backup.

wget http://kyau.net/kyau-rpi.tar.bz2

tar zxvf kyau-rpi.tar.bz2

rm kyau-rpi.tar.bz2

Re-login to enact all the changes.

Xorg Install

With the RPi fully configured let's move on to installing Xorg. Before we begin we must install the base development package group in order to build packages on the RPi.

sudo pacman -S base-devel git

Then proceed by installing the base for Xorg along with the proper video driver for the RPi.

sudo pacman -S xorg-server xorg-xinit xorg-server-utils mesa xf86-video-fbdev

Next install a window manager and some basic applications, themes and fonts.

sudo pacman -S openbox

sudo pacman -S lxappearance lxappearance-obconf obconf rxvt-unicode terminus-font

sudo pacman -S mirage thunar tumbler thunar-archive-plugin file-roller unrar zip unzip

sudo pacman -S gnome-icon-theme gnome-icon-theme-extras

sudo packer -S gtk-engine-mist elementary-icon-theme gtk-theme-elementary-bzr

Here you will encounter the first package that refuses to compile, the following message is roughly what you will see.

Icon==> ERROR: docbook-to-man is not available for the 'armv6h' architecture.

The solution is actually really quite simple, rerun the install command and this time choose to edit the PKGBUILD of that package. Modify the arch line to look like the following.

Iconarch=(i686 x86_64 armv6h)

The package should now build properly, you will encounter this a couple of times during the following steps use this exact method to remedy the problem every time.

Packages that need you to edit the PKGBUILD: gtk-engine-mist gtk-theme-elementary-bzr

XBMC

Now that the Arch Linux baseline is finished let's get to installing XBMC.

sudo packer -S xbmc-rbp-git

The latest version they forgot to fix some permissions on the RPi with Arch. Let's add these now, create the following file and dump the contents into it.

sudo vim /etc/udev/rules.d/raspberrypi.rules

IconSUBSYSTEM=="vchiq|input", MODE="0777" KERNEL=="mouse*|mice|event*", MODE="0777"

Autologin

With XBMC installed we can now configure Arch Linux to autologin to your user account.

sudo mkdir /etc/systemd/system/getty@tty1.service.d

sudo vim /etc/systemd/system/getty\@tty1.service.d/autologin.conf

Icon[Service] ExecStart= ExecStart=-/usr/bin/agetty --autologin kyau --noclear %I 38400 linux Type=simple

Start X at Login

Finally let's get Xorg starting upon login.

vim ~/.bash_profile

Icon# Start X at Login [[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx

Auto-Launch XBMC

First we will need a utility called fbset.

sudo pacman -S fbset

The following is a pasted copy of the script I use to launch XBMC on start, I run this script from ~/.config/openbox/autostart. Modify it accordingly to update your resolution upon exiting XBMC.

Icon#!/bin/bash xbmc-standalone sudo fbset -depth 16 -xres 1920 -yres 1080 (sleep 1 && xrefresh) exit 0

Synergy

Synergy is an application that allows you to utilize a single keyboard and mouse on a host computer to then operate multiple client computers from the single host. It is intended for scenarios where each client has its own monitor and will allow you to seamlessly scroll between screens/machines.

Install synergy on your host machine. If you need assistance with this there is a great video over at YouTube.

Host

Open synergy and click "Configure Server".

Then drag one of the monitors in the upper left onto the grid location that represents that client monitors actual position in relation to your host machine.

Double click on the new client monitor.

Name the screen: archey

Client

Install synergy.

sudo pacman -S synergy

Then use synergy to connect as a client to your host machine (mine happens to be named chloe).

synergyc --name archey chloe

If you wish to launch synergy on boot merely add the previous line to your ~/.config/openbox/autostart.

vim ~/.config/openbox/autostart

Icon# Set Background Color xsetroot -solid steelblue4 # Connect to Synergy (sleep 5 && synergyc --log ~/synergy.log --no-tray --name archey chloe) # Autostart XBMC xbmc-start &

Samba

If you want the Windows computers on your network to be able to access the media shares you will need to install Samba.

sudo pacman -S samba

Then copy the default config file and edit it to reflect your workgroup and a share for /media.

sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf

sudo vim /etc/samba/smb.conf

Icon[global] # workgroup = NT-Domain-Name or Workgroup-Name workgroup = KYAU # server string is the equivalent of the NT Description field server string = Archey Media Server ... [media] comment = Media Library path = /media public = yes read only = yes write list = @users

Setup samba to load on boot and then launch it now.

sudo systemctl enable smbd

sudo systemctl enable nmbd

sudo systemctl start smbd

sudo systemctl start nmbd

Finally don't forget to add your user to Samba and change the permissions for your shared folder.

sudo pdbedit -a -u kyau

sudo chown -R kyau:users /media/

Raspberry Pi Tweaks

If you are looking to get more out of your RPi consider doing any or all of the tweaks listed in this section.

RPi Config

The following is my RPi config.txt in its default mode (no overclocking enabled). You will need to un-comment and edit in your license keys and modify the gpu_mem parameter accordingly.

cat /boot/config.txt

Icon## Memory # Disable ARM access to GPU's L2 cache. Needs corresponding L2 disabled kernel. #disable_l2cache=1 # GPU memory in megabyte. Sets the memory split between the ARM and GPU. # ARM gets the remaining memory. gpu_mem=256 # Disable adjusting the refresh rate of RAM every 500ms (measuring RAM # temperature) #disable_pvt=1 ## CMA - Dynamic Memory Split # When GPU has less than cma_lwm (low water mark) memory available it will # request some from ARM. #cma_lwm=16 # When GPU has more than cma_hwm (high water mark) memory available it will # release some to ARM. #cma_hwm=32 #cma_offline_start=16 ## Camera # Turn off the red camera LED when recording video or taking a still picture. #disable_camera_led=1 ## Video # Disable overscan if your display has a black border of unused pixels visible # and your display can output without overscan. #disable_overscan=1 # Overscan adjusting. Positive numbers if console goes off screen and negative # if there is too much border. #overscan_left=16 #overscan_right=16 #overscan_top=16 #overscan_bottom=16 # Force a console size, default is display's size minus overscan. #framebuffer_width=1280 #framebuffer_height=720 # Console framebuffer depth in bits per pixel. #framebuffer_depth=16 # Disable alpha channel. (helps with 32-bit) #framebuffer_ignore_alpha=1 # Enable test sound/image during boot for manufacturing test. #test_mode=1 # Signal strength of the HDMI interface. #config_hdmi_boost=4 # Rotates the display clockwise on the screen or flips the display. #display_rotate=1 ## Licensed Codecs # License key to allow hardware MPEG-2 decoding. #decode_MPG2=0x12345678 # License key to allow hardware VC-1 decoding. #decode_WVC1=0x12345678 ## Boot # Avoids the rainbow splash screen on boot disable_splash=1 ## Overclocking ##None #arm_freq=700 #core_freq=250 #sdram_freq=400 #over_voltage=0 ##Modest #arm_freq=800 #core_freq=300 #sdram_freq=400 #over_voltage=0 ##Medium #arm_freq=900 #core_freq=333 #sdram_freq=450 #over_voltage=2 ##High #arm_freq=950 #core_freq=450 #sdram_freq=450 #over_voltage=6 ##Turbo #arm_freq=1000 #core_freq=500 #sdram_freq=500 #over_voltage=6 # vim:ft=conf

XBMC

For a noticable difference in performance create the file ~/.xbmc/userdata/advancedsettings.xml and paste in the following.

vim ~/.xbmc/userdata/advancedsettings.xml

Icon<advancedsettings> <videolibrary> <cleanonupdate>true</cleanonupdate> </videolibrary> <network> <cachemembuffersize>5282880</cachemembuffersize> </network> <fanartheight>560</fanartheight> <thumbsize>256</thumbsize> <gui> <algorithmdirtyregions>3</algorithmdirtyregions> <nofliptimeout>0</nofliptimeout> </gui> <lookandfeel> <enablerssfeeds>false</enablerssfeeds> </lookandfeel> <bginfoloadermaxthreads>2</bginfoloadermaxthreads> </advancedsettings>