[关闭]
@yangxuan 2018-05-14T12:57:25.000000Z 字数 10979 阅读 72012

Raspberrypi 3 install & configure Archlinux(XFCE,f2fs)

raspberrypi Archlinux
yangxuan8282@gmail.com


screenshot

UPDATE_2018-05-14: When I began to write this blog, that was my first time to install archlinux arm, it takes me one day to make everthing works. Until now most parts should still works for rpi, so there is no major update since then.
Now there is an esay way to install archlinux arm just like the raspbian image, I wrote a scripts to generate the image, and you can just flash it to sd card with Etcher or dd. However I still strongly recommended you learn install it manually first, because this will help you later.
Here is the links: https://github.com/yangxuan8282/gen-rpi_os. Just run sudo ./gen-chroot alarm on raspberrypi ( the running os can be raspbian, archlinux arm or any other arm linux distros ). The UI maybe looks different than screenshots in this blog, that's because I forgot how did I tweaks last time, but most function should work, include bluetooth and Wi-Fi.

UPDATE_2018-02-09: Maybe I have missed some packages when I wrote this blog, I have upload a list of all necessary packages you need, check this gist.

1.Install(prepare SD card)

(The installation is based on use f2fs as RPi rootfs, if you don't need f2fs, please check archlinux arm installation page)

On Linux PC:

  1. lsblk
  1. sudo fdisk /dev/sdX

clear partitions on the drive (o)

create first partition (n, p, 1, enter, +100M, t, c)

create second partition (n, p, 2, enter, enter), then write and exit (w)

  1. sudo mkfs.vfat /dev/sdX1
  1. sudo mkdir /mnt/boot
  1. sudo mount /dev/sdX1 /mnt/boot

(you need to install f2fs-tools)

  1. sudo mkfs.f2fs /dev/sdX2
  1. sudo mkdir /mnt/root
  1. sudo mount -t f2fs /dev/sdX2 /mnt/root
  1. wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-2-latest.tar.gz

there is ArchLinuxARM-rpi-2-latest.tar.gz and ArchLinuxARM-rpi-3-latest.tar.gz exist, both work for pi 3, the latter one have a 64-bit kernel and aarch64 rootfs, but the performance seems not good as the first one, so I will still use ArchLinuxARM-rpi-2-latest.tar.gz

  1. sudo su

you need to install bsdtar instead of gnu tar

  1. bsdtar -xpf ArchLinuxARM-rpi-2-latest.tar.gz -C /mnt/root
  1. sync
  1. mv /mnt/root/boot/* /mnt/boot

we need to increase /tmp size in case got issues like: No space left on device when building packages

  1. nano /mnt/root/etc/fstab

add:

  1. tmpfs /tmp tmpfs rw,nodev,nosuid,size=2G 0 0

with latest version archlinux arm, we don't need to modified /boot/cmdline.txt and /etc/fstab anymore to support f2fs for rootfs, just remember to install f2fs-tools after boot for fsck.f2fs

if you have a class 10 SD card, you can add below in /boot/config.txt ( this won't brick your devices, it will just take advantage of your high speed card ):

  1. nano /mnt/boot/config.txt

add:

dtparam=sd_overclock=100

unmount:

  1. umount /mnt/boot /mnt/root

2.Init

insert the SD card into your pi 3, and power on

either connect to a monitor, or setup headless use ssh: ssh alarm@alarmpi

login: alarm

passwd: alarm

  1. su root

type password root

  1. pacman-key --init
  1. pacman -Syu

if you rootfs use f2fs file system, you will need to install f2fs-tools

  1. pacman -S f2fs-tools
  1. pacman -S sudo
  1. visudo -f /etc/sudoers.d/myOverrides

add:

alarm  ALL=NOPASSWD: ALL

the default editor is vi, press i to edit, when you done want to exit, first press esc, then input :wq to save and exit

switch to user alarm:

  1. su alarm

3.packer

  1. sudo pacman -S packer

change packer default editor:

  1. sudo nano /usr/bin/packer

Ctrl + w to find:

${EDITOR:-vi} "$2"

change to:

${EDITOR:-nano} "$2"
  1. sudo pacman -S git base-devel

when you try to install an aur packages, you may need to edit PKGBUILDs change arch=('i686' 'x86_64') to arch=('any')

4.Desktop

  1. sudo pacman -S xorg-server xf86-video-fbdev xorg-xrefresh

sample output:

Enter a number (default=1):

press Enter to use default provider

(optional, but recommanded) xf86-video-fbturbo

  1. sudo pacman -S make gcc git-core automake autoconf pkg-config libtool
  1. cd ~
  1. git clone https://github.com/robclark/libdri2.git
  1. git clone https://github.com/ssvb/xf86-video-fbturbo
  1. cd ~/libdri2
  1. ./autogen.sh --prefix=/usr
  1. sudo make install
  1. cd ~/xf86-video-fbturbo
  1. autoreconf -vi
  1. ./configure --prefix=/usr
  1. make
  1. sudo make install
  1. sudo cp xorg.conf /usr/share/X11/xorg.conf.d/99-fbturbo.conf

if you have flickering cursor issues with fbturbo, please check some fixes section

XFCE4:

  1. sudo pacman -S xfce4 xfce4-goodies xarchiver pavucontrol
  1. sudo pacman -S sddm
  1. sudo sh -c "sddm --example-config > /etc/sddm.conf"

SDDM theme:

  1. packer -S archlinux-themes-sddm

SDDM autostart:

  1. sudo systemctl enable sddm
  1. sudo systemctl start sddm

you can see sddm now, login with: alarm:alarm

autologin:

  1. sudo nano /etc/sddm.conf

modified:

[Autologin]
Session=xfce.desktop
User=alarm
......
Current=archlinux-simplyblack

icon:

  1. packer -S paper-icon-theme-git

theme:

  1. packer -S arc-gtk-theme

font:

  1. packer -S ttf-roboto

terminal font:

  1. packer -S ttf-roboto-mono

wallpaper link

menu icon from icons8

if you prefer official icons, you can find it in Raspbian Jessie, /usr/share/raspberrypi-artwork/raspitr.png

5.Audio/Bluetooth

  1. packer -S pulseaudio-alsa pulseaudio-bluetooth pavucontrol bluez blueman pi-bluetooth
  1. systemctl start bluetooth.service
  1. systemctl enable bluetooth.service
  1. sudo systemctl enable brcm43438.service
  1. sudo systemctl start brcm43438.service

connect bluetooth keyboard:https://wiki.archlinux.org/index.php/bluetooth_keyboard

connect bluetooth headset : https://wiki.archlinux.org/index.php/Bluetooth_headset

6.Wi-Fi

  1. sudo pacman -Syu networkmanager network-manager-applet gnome-keyring
  1. systemctl enable NetworkManager
  1. systemctl start NetworkManager
  1. sudo ifconfig wlan0 up
  1. ifconfig wlan0

check if wlan0 is up

then edit your wireless network in NetworkManager

7.Locale

  1. sudo nano /etc/locale.gen

uncomment:

en_US.UTF-8 UTF-8
  1. sudo locale-gen
  1. sudo nano /etc/profile

add:

export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8

8.FFmpeg with MMAL

FFmpeg with MMAL support make you can watch 480p on Youtube with Chromium, and improve local player (like mpv) performance.
You should install it before Chromium and mpv.

  1. mkdir ffmpeg_build
  1. cd ffmpeg_build
  1. mkdir $(date +%Y-%m-%d)
  1. cd $(date +%Y-%m-%d)
  1. wget https://raw.githubusercontent.com/archlinuxarm/PKGBUILDs/master/extra/ffmpeg/PKGBUILD
  1. nano PKGBUILD

find:

arch=('i686' 'x86_64')

change to

arch=('any')

find:

...
--enable-x11grab \

add:

--enable-mmal \

so it look like this:

--enable-x11grab \
--enable-mmal \
...

don't leave space after '\'

next step take about 2 hours, save your time, let's speedup it:

  1. sudo nano /etc/makepkg.conf

add:

MAKEFLAGS="-j4"

in ARCHITECTURE, COMPILE FLAGS section

find:

COMPRESSXZ=

change to:

COMPRESSXZ=(xz -c -z - --threads=4)

save and exit : Ctrl + x, then press y

makepkg && install FFmpeg

I would suggest you makepkg in a screen session:

  1. sudo pacman -S screen
  1. screen -S build
  1. makepkg
  1. sudo pacman -U *.pkg.tar.xz

Skip package from being upgraded:

  1. sudo nano /etc/pacman.conf

add:

IgnorePkg = ffmpeg

For multiple packages use a space-separated list, or use additional IgnorePkg lines.

UPDATE 2016-08-19:

if you got some issues like this:

...
libavcodec/libopenjpegdec.o: In function `libopenjpeg_decode_frame':
libopenjpegdec.c:(.text+0x210): undefined reference to `opj_create_decompress'
libopenjpegdec.c:(.text+0x230): undefined reference to `opj_set_error_handler'
...
/usr/bin/ld: libavcodec/libavcodec.so.57: hidden symbol `opj_setup_decoder' isn't defined
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
make: *** [library.mak:100: libavcodec/libavcodec.so.57] Error 1
make: *** Waiting for unfinished jobs....

you should uninstall openjpeg2 first:

  1. sudo pacman -Rdd openjpeg2

-Rdd means remove packages skip dependency version checks

then after build and install ffmpeg reinstall it:

  1. sudo pacman -S openjpeg2

sources

9.Chromium

the lastest version 52.0.2743.116-1 should work, so just:

  1. sudo pacman -S chromium

10.Disable screen saver blanking

  1. xset q

if you got:

xset:  unable to open display ""

type:

  1. export DISPLAY=:0

then disable DPMS and prevent screen from blanking:

  1. xset s off -dpms

source: wiki

11.Window tiling

Windows Manager -> Advanced -> Wrap workspaces when reaching the screen edge

uncheck: With a dragged windows

Windows Manager Tweaks -> Accessibility

check: Automatically tile windows when moving toward the screen edge

12.Conky

  1. packer -S conky-lua conky-manager

then select the widgets from Conky Manager, select Gotham for example

check

~/.conky/Gotham/Gotham

you can edit the file manually in a text editor

here is some reference: time/date

13.Powerline

What is Powerline?

from their github page:

Powerline is a statusline plugin for vim, and provides statuslines and prompts for several other applications, including zsh, bash, tmux, IPython, Awesome, i3 and Qtile.

and they have some screenshot on that page

Install:

  1. sudo pip install powerline-status
  1. packer -S powerline-fonts-git tmux

bash:

  1. sudo nano ~/.bashrc

add:

# Powerline
if [ -f `which powerline-daemon` ]; then
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /usr/lib/python3.5/site-packages/powerline/bindings/bash/powerline.sh
fi

bash git branch info:

  1. mkdir ~/.config/powerline
  1. cp /usr/lib/python3.5/site-packages/powerline/config_files/config.json ~/.config/powerline
  1. sudo nano ~/.config/powerline/config.json

find:

                "shell": {
                        ...
                        "theme": "default",

change to :

                        "theme": "default_leftonly",

restart powerline daemon:

  1. powerline-daemon --replace

tmux:

  1. sudo nano ~/.tmux.conf

add:

source /usr/lib/python3.5/site-packages/powerline/bindings/tmux/powerline.conf
set-option -g default-terminal "screen-256color"

vim:

  1. packer -S gvim
  1. sudo nano ~/.vimrc

add:

set  rtp+=/usr/lib/python3.5/site-packages/powerline/bindings/vim
set laststatus=2
set t_Co=256

14.backup/migration

For f2fs rootfs, rsync is a better way to migrate full system than dd, it allows for a different size, partition table and filesystem to be used, and won't got permissions issues like use cp -a.

  1. sudo pacman -Syu rsync
  1. sudo rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup/folder

If you rootfs is ext4, maybe you can try this scripts from raspberrypi official forums user jinx. It should also works on archlinux arm.

15.Samba

Creating a share:

  1. sudo pacman -S samba
  1. sudo cp /etc/samba/smb.conf.default /etc/samba/smb.conf
  1. sudo pdbedit -a -u username
  1. sudo systemctl start smbd nmbd
  1. sudo systemctl enable smbd nmbd

access samba shares through Thunar:

  1. sudo pacman -S gvfs-smb

16.aria2

  1. sudo pacman -S aria2
  1. mkdir -p ~/.config/aria2
  1. nano ~/.config/aria2/aria2.conf

add:

continue=true
dir=/home/alarm
input-file=/home/alarm/.config/aria2/session.lock
max-concurrent-downloads=1
max-connection-per-server=5
bt-enable-lpd=true
bt-require-crypto=true
listen-port=65298
dht-listen-port=65298
seed-time=120
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
rpc-listen-port=6800
disable-ipv6=true
file-allocation=none
save-session=/home/alarm/.config/aria2/session.lock
save-session-interval=300

save and exit with CTRL + X, y

  1. sudo wget -O /etc/systemd/user/aria2.service https://raw.githubusercontent.com/gutenye/systemd-units/master/aria2/aria2.service
  1. touch ~/.config/aria2/session.lock
  1. systemctl --user enable aria2

(optional) web frontend:

  1. sudo pacman -S nginx
  1. cd /usr/share/nginx/html
  1. git clone --depth=1 https://github.com/ziahamza/webui-aria2
  1. systemctl start nginx
  1. systemctl enable nginx

visit http://alarmpi/webui-aria2/

(optional) command line interface:

  1. packer -S diana-git

add download:

  1. diana add url

list current downloads:

  1. diana list

some fixes

  1. nano /boot/config.txt

add:

dtparam=audio=on
hdmi_drive=2
  1. sudo nano /etc/modules-load.d/raspberrypi.conf

remove:

bcm2708-rng
  1. sudo /boot/config.txt

add:

dtparam=audio=on

solution from here

fbturbo did improve performance a lot especially for web browsing and video play, but you may got flickering cursor when the pages load, this is annoy, let's fix it

the solution is use fbturbo from JamesH65 instead of ssvb:

if you have installed fbturbo, then you should uninstall it first:

  1. cd ~/xf86-video-fbturbo
  1. sudo make uninstall

get the repos:

  1. mkdir fbturbo_build
  1. cd fbturbo_build
  1. git clone --depth=1 -b raspi_hwcursor_pi2 https://github.com/JamesH65/xf86-video-fbturbo

the rest part is same as section 4

if you read dmesg may find some output like this:

[  326.481641] raspberrypi-firmware soc:firmware: Request 0x00008011 returned status 0x80000001

to be frankly, I haven't found a solution yet, but this doesn't affect your system, so just ignore this warning.


more screenshot:

both BT&Wi-Fi work

Conky

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注