Build an Arch Linux environment on Raspberry Pi


In this article, I will describe the process of building an Arch Linux environment on Raspberry pi 3 Model B (because my Raspberry Pi is 3 Model B). The version is a little old, but I don't think the installation procedure will change much compared to the latest version of Raspberry Pi 4. This article is for anyone who wants to run Arch Linux on a version 3 or later Raspberry Pi.

What kind of environment will be created in the end?

The environment as shown in the image below is completed. I used Xfce for the desktop environment.


Installation procedure

It consists of 3 parts.

=== Perform with linux prepared in the virtual environment === Chapter 1. Write partition and file system settings to microSD card

=== Working with Raspberry Pi === Chapter 2. Various settings such as locale, keyboard, network, user addition, time, Xorg, desktop environment, etc. Chapter 3. Customization on the desktop environment of your choice

Chapter 1

In this chapter we will build an arch Linux partition and file system on a microSD card. It's almost the same as the official installation procedure, but I think you can follow the sequence. Any OS will do as long as you can use commands such as fdisk, mount, and tar. However, if you want to do it safely without getting hurt, I think it is better to prepare linux on a virtual environment such as VirtualBox or VMware. I did it on windows with Zorin OS 15.2 Lite (free) in the virtual environment of VirtualBox.

The explanation in Chapter 1 will do almost the same as the formula below. Raspberry Pi 3 | Arch Linux ARM Raspberry Pi 4 | Arch Linux ARM

Construction of new partition and file system

I'm currently opening a terminal with Zorin OS 15.2 Lite installed in a virtual environment. Switch to root with su.

First, if the microSD card mounts automatically, you need to unmount it. Check the current mount status with mount. When I check the last line, it is still mounted automatically.

[email protected]:/home/hibi21b# mount
/dev/sdb1 on /media/hibi21b/B1FD-E84D type vfat (rw,nosuid,nodev,relatime,uid=1000,gid=1000,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2)

Unmount with ʻumount / dev / sdb1`. I want to mount the boot directory on / dev / sdb1 later, so I need to remove it.

[email protected]:/home/hibi21b# umount /dev/sdb1

If you are using Zorin OS 15.2 Lite, uncheck Removable Storage as it will be mounted automatically after a certain period of time even if you umount it.


Check for currently available block devices

You can check it with the lsblk command. I'm using a 16GB microSD card (I should have kept it around 128GB).

[email protected]:/home/hibi21b# lsblk
sda      8:0    0   96G  0 disk 
└─sda1   8:1    0   96G  0 part /
sdb      8:16   1   15G  0 disk 
└─sdb1   8:17   1   15G  0 part 
sr0     11:0    1 1024M  0 rom  

Also check with fdisk -l. This time, the block device of the microSD card was / dev / sdb, but / dev / sdc etc. may change, so please read it in that case.

[email protected]:/home/hibi21b# fdisk -l
Disk /dev/sda: 96 GiB, 103079215104 bytes, 201326592 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xee589588

Device     Boot Start       End   Sectors Size Id Type
/dev/sda1  *     2048 201324543 201322496  96G 83 Linux

Disk /dev/sdb: 15 GiB, 16118710272 bytes, 31481856 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xe5e4a4e3

Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1        8192 31481855 31473664  15G  c W95 FAT32 (LBA)

Create a new partition

Do as officially. Wherever there is a <----------, you have to enter it yourself.

[email protected]:/home/hibi21b# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): o    <----------
Created a new DOS disklabel with disk identifier 0x7fa48a0b.

Command (m for help): p    <----------View partition table
Disk /dev/sdb: 15 GiB, 16118710272 bytes, 31481856 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7fa48a0b

Command (m for help): n    <----------
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p    <----------
Partition number (1-4, default 1):     <----------
First sector (2048-31481855, default 2048):     <----------
Last sector, +sectors or +size{K,M,G,T,P} (2048-31481855, default 31481855): +100M   <----------

Created a new partition 1 of type 'Linux' and of size 100 MiB.

Command (m for help): t    <----------
Selected partition 1
Hex code (type L to list all codes): c    <----------
Changed type of partition 'Linux' to 'W95 FAT32 (LBA)'.

Command (m for help): n    <----------
Partition type
   p   primary (1 primary, 0 extended, 3 free)
   e   extended (container for logical partitions)
Select (default p): p    <----------
Partition number (2-4, default 2):     <----------
First sector (206848-31481855, default 206848):     <----------
Last sector, +sectors or +size{K,M,G,T,P} (206848-31481855, default 31481855):     <----------

Created a new partition 2 of type 'Linux' and of size 14.9 GiB.

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

Check / dev / sdb again

You can see that you have a new partition by doing fdisk -l.

[email protected]:/home/hibi21b# fdisk -l

Disk /dev/sdb: 15 GiB, 16118710272 bytes, 31481856 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x7fa48a0b

Device     Boot  Start      End  Sectors  Size Id Type
/dev/sdb1         2048   206847   204800  100M  c W95 FAT32 (LBA)
/dev/sdb2       206848 31481855 31275008 14.9G 83 Linux

Creating and mounting a FAT file system

[email protected]:/home/hibi21b# mkfs.vfat /dev/sdb1
mkfs.fat 4.1 (2017-01-24)
[email protected]:/home/hibi21b# mkdir boot
[email protected]:/home/hibi21b# mount /dev/sdb1 boot

Creating and mounting an ext4 file system

mkfs.ext4 / dev / sdb2 will take some time.

[email protected]:/home/hibi21b# mkfs.ext4 /dev/sdb2
mke2fs 1.44.1 (24-Mar-2018)
Creating filesystem with 3909376 4k blocks and 979200 inodes
Filesystem UUID: 8371c867-4a52-4ebb-9e3a-40d20ac0c161
Superblock backups stored on blocks: 
	32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done   
[email protected]:/home/hibi21b# mkdir root
[email protected]:/home/hibi21b# mount /dev/sdb2 root

Check if it is mounted

Check with mount

[email protected]:/home/hibi21b# mount
/dev/sdb1 on /home/hibi21b/boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdb2 on /home/hibi21b/root type ext4 (rw,relatime)

get tarball

Get the tarball with wget. The tarball you get depends on the version of Raspberry Pi. wget

Please check the formula again Raspberry Pi 3 | Arch Linux ARM Raspberry Pi 4 | Arch Linux ARM

[email protected]:/home/hibi21b# wget
Saving to: ‘ArchLinuxARM-rpi-2-latest.tar.gz’

ArchLinuxARM-rpi-2-latest.tar.gz                  100%[============================================================================================================>] 445.14M  1.24MB/s    in 6m 53s  

2020-05-08 21:23:50 (1.08 MB/s) - ‘ArchLinuxARM-rpi-2-latest.tar.gz’ saved [466758916/466758916]

I got a tarball. Although it is rpi-2, it started normally even with Raspberry Pi 3 Model B.

[email protected]:/home/hibi21b# ls
ArchLinuxARM-rpi-2-latest.tar.gz  boot  Desktop  Documents  Downloads  Music  Pictures  Public  root  Templates  Videos


Officially I use bsdtar, but I used the tar command. I didn't add the tar zxvf Arch ... and the v option because all the details would be displayed in the terminal. The meaning of -C root is to unzip under the root directory (which is the mount point of / dev / sdb2). -C is uppercase.

This will take some time.

[email protected]:/home/hibi21b# tar zxf ArchLinuxARM-rpi-2-latest.tar.gz -C root
tar: Ignoring unknown extended header keyword ''
tar: Ignoring unknown extended header keyword ''
tar: Ignoring unknown extended header keyword ''
[email protected]:/home/hibi21b#

You can see that it has been unzipped.

[email protected]:/home/hibi21b# ls root/
bin  boot  dev  etc  home  lib  lost+found  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var

sync Please refer to the following site for detailed explanations.

sync command|Linux Technician Certified Linux| LPI-Japan

[email protected]:/home/hibi21b# sync


What I'm doing is simple, but the directory name is confusing, so I made a diagram.

[email protected]:/home/hibi21b# mv root/boot/* boot

mv (1).png

[email protected]:/home/hibi21b# ls boot/
bcm2709-rpi-2-b.dtb       bcm2836-rpi-2-b.dtb       config.txt    fixup_cd.dat         kernel7.img   start4x.elf
bcm2710-rpi-2-b.dtb       bcm2837-rpi-3-b.dtb       fixup4cd.dat  fixup.dat            overlays      start_cd.elf
bcm2710-rpi-3-b.dtb       bcm2837-rpi-3-b-plus.dtb  fixup4.dat    fixup_db.dat         start4cd.elf  start_db.elf
bcm2710-rpi-3-b-plus.dtb  bootcode.bin              fixup4db.dat  fixup_x.dat          start4db.elf  start.elf
bcm2710-rpi-cm3.dtb       cmdline.txt               fixup4x.dat   initramfs-linux.img  start4.elf    start_x.elf
[email protected]:/home/hibi21b# ls root/boot/
[email protected]:/home/hibi21b# 


Finally, unmount the boot and root mount points.

[email protected]:/home/hibi21b# mount
/dev/sdb1 on /home/hibi21b/boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,errors=remount-ro)
/dev/sdb2 on /home/hibi21b/root type ext4 (rw,relatime)

[email protected]:/home/hibi21b# umount boot root

This is the end of the work in Chapter 1. Remove the microSD card. It's okay to have the virtual environment closed as well.

Chapter 2

From Chapter 2 onwards, you will be working on the Raspberry Pi. Insert the microSD card into the Raspberry Pi and start it. Officially, the initial password for root is root.

** After setting, please perform reboot at an appropriate timing. ** **


loadkeys jp106 will not be in Japanese layout if you reboot with temporary settings, so it is better to set it in localectl as well.

Console keyboard settings-ArchWiki

[[email protected] ~]# loadkeys jp106
[[email protected] ~]# localectl set-keymap jp106
[[email protected] ~]# localectl //Verification

Change root user password

Now that you can enter the keys correctly, change the password of the root user.

[[email protected] ~]# passwd root

audit If a message like ʻaudit: xxxxxxxappears, it interferes with the work and I didn't like it, so I will stop it with a mask. To cancel it, usesystemctl unmask XXX`.

Arch Linux ARM · View topic --How disable AUDIT messages

[[email protected] ~]# systemctl mask systemd-journald-audit.socket
Created symlink /etc/systemd/system/systemd-journald-audit.socket -> /dev/null
[[email protected] ~]# reboot


Add the system locale. Open the config file with nano /etc/locale.gen and uncomment the following two. You can use vi, but there are fewer accidents if you use nano.

If you select ja_JP.UTF-8 instead of en_US.UTF-8 and reboot, the characters will be garbled, so set ʻen_US.UTF-8`.

Locale --ArchWiki Mastering GNU nano-Qiita

[[email protected] ~]# nano /etc/locale.gen
[[email protected] ~]# locale-gen
[[email protected] ~]# localectl set-locale en_US.UTF-8
[[email protected] ~]# localectl //Check if it is reflected


Here, set the wireless LAN. Those who use wired need to check separately. Examine the wireless interface with ʻiw dev. The result is Interface wlan0, which turns out to be wlan0`.

[[email protected] ~]# iw dev

Use the wpa_passphrase command to encrypt the wifi password and write it to the new config file. The configuration file name should be in the following format.

/etc/wpa_supplicant/wpa_supplicant-interface name.conf For wpa_supplicant, use an underscore and a hyphen before the interface name.

[[email protected] ~]# wpa_passphrase "MYSSID" "passphrase" > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

When you open /etc/wpa_supplicant/wpa_supplicant-wlan0.conf, the password is commented in plain text, so delete that part.

WPA supplicant - ArchWiki

[[email protected] ~]# nano /etc/wpa_supplicant/wpa_supplicant-wlan0.conf

---------In the configuration file
    #psk="passphrase" <---Erase this one line

Enable wireless at boot time.

--systemctl enable wpa_supplicant @ interface name --systemctl enable dhcpcd @ interface name

[[email protected] ~]# systemctl enable [email protected]
Created symlink /etc/systemd/system/[email protected] -> /usr/lib/systemd/system/[email protected]

[[email protected] ~]# systemctl enable [email protected]
Created symlink /etc/systemd/system/[email protected] -> /usr/lib/systemd/system/[email protected]

After reboot, check wlan0 with ʻifconfig or ʻip addr show

DNSSEC After finishing the network settings and trying ping -c5 etc., this works fine. However, ping -c5 does not pass. You can find the cause of this in systemctl status /etc/systemd/resolved.conf. The solution can be found at the following site.

systemd-resolved - ArchWiki Raspberry DNS problems with ArchLinuxARM and DNSSEC | madflex

Disable DNSSEC. Add it to /etc/systemd/resolved.conf.

[[email protected] ~]# echo "DNSSEC=false" >> /etc/systemd/resolved.conf
[[email protected] ~]# cat /etc/systemd/resolved.conf

Please reboot.

Time zone

Check if the time zone: Asia / Tokyo is set with timedatectl.

Time --ArchWiki

[[email protected] ~]# timedatectl set-timezone Asia/Tokyo

Times of Day

Japan Standard Time (JST) Group systemd-timesyncd - ArchWiki

[[email protected] ~]# nano /etc/systemd/timesyncd.conf

---------In the configuration file
#NTP= //Change Uncomment and specify server

[[email protected] ~]# timedatectl set-ntp true
[[email protected] ~]# reboot

Change host name

[[email protected] ~]# nano /etc/hostname

---------In the configuration file
alarmpi  <--Erase
hibi221b <--add to

Then reboot. The host name has changed.

[[email protected] ~]# 

Add / remove users

Create a general user other than the root user.

Add with the ʻuseradd` command.

---m Create home directory ** * Be sure to add ** </ font> ---d Home directory location ---s Login shell is now bash --Finally, specify the user name.

[[email protected] ~]# useradd -m -d /home/hibi221b -s /bin/bash hibi221b

Create a new password for the added general user ** * Please be sure to do it ** </ font>

[[email protected] ~]# passwd hibi221b

Check if a general user of hibi221b has been added

[[email protected] ~]# cat /etc/passwd

By default, a general user called ʻalarmis created. I don't plan to use this user, so I'll delete it. Also delete the alarm user's home directory with-r`.

[[email protected] ~]# ls /home
alarm hibi221b
[[email protected] ~]# userdel -r alarm

alarm Check if the general user has disappeared

[[email protected] ~]# cat /etc/passwd
[[email protected] ~]# ls /home

pacman Now that the network settings are complete, we will use pacman to install the package.

pacman - ArchWiki pacman-key - ArchWiki Pacman Comparison Table-ArchWiki

[[email protected] ~]# pacman-key --init 
[[email protected] ~]# pacman-key --populate archlinuxarm
[[email protected] ~]# pacman -Syu

What you need for x window system, etc.

Xorg - ArchWiki

[[email protected] ~]# pacman -S xorg-server xorg-xinit xorg-apps xorg-twm xterm mesa xf86-video-fbdev xf86-video-amdgpu

sudo Enables you to use sudo. First you need to install vim and sudo. I can open the configuration file with visudo without doing ʻexport EDITOR = vim, but for some reason the key input is not correct, so I think it is better to do ʻexport EDITOR = vim.

[[email protected] ~]# pacman -S vim sudo
[[email protected] ~]# export EDITOR=vim
[[email protected] ~]# visudo

---------In the configuration file
## User privilege specification
root ALL=(ALL) ALL
hibi221b ALL=(ALL) ALL   <----------Add this line

install lightdm

The display manager used lightdm.

LightDM - ArchWiki

[[email protected] ~]# pacman -S lightdm lightdm-gtk-greeter
[[email protected] ~]# systemctl enable lightdm
Created symlink /etc/systemd/system/display-manager.service -> /usr/lib/systemd/system/lightdm.service

launch xfce

This time we will use xfce for the desktop environment.

Xfce - ArchWiki

[[email protected] ~]# pacman -S xfce4 xfce4-goodies

Start with startxfce4, and if the desktop screen below appears, the installation is successful. I have enabled lightdm, so the next time I start it, I will log in as the user I added. (If you forget the password of the general user, select other and log in as the root user.)

[[email protected] ~]# which startxfce4
[[email protected] ~]# startxfce4


Chapter 3

Now, let's configure the settings on the xfce desktop environment. If the screen freezes and you can't do anything, you can restart it with ctrl + ʻAlt + Backspace`.

xscreensaver Since xfce's default screensaver is not used, turn off all currently set screensaver items. The screensaver is run by default even with autostart, so turn it off. (Uncheck screensaver under ʻApplications-> Settings-> Session and Startup-> ʻApplication Autostart.)

Add a new xscreensaver.

[[email protected] ~]$ sudo pacman -S xscreensaver

The one with the moon drawn is the one that is set by default, and I turned off all the items earlier. The red one is the new xscreensaver setting.


Japanese support

Install the package, set it to $ HOME / .xprofile, reboot, select ʻapplication-> Settings-> fcitx-configurationin the upper left, and add Mozc. You can switch to English <-> Japanese by pressingctrl + space` where the cursor is valid.

Fcitx - ArchWiki Fonts-ArchWiki

[[email protected] ~]$ sudo pacman -S fcitx fcitx-mozc fcitx-configtool fcitx-im otf-ipafont
[[email protected] ~]$ vim .xprofile

--------- .Added 3 lines in xprofile config file
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export [email protected]=fcitx

[[email protected] ~]$ reboot


[[email protected] ~]$ sudo pacman -S firefox chromium

yay Install yay, a helper for AUR (Arch User Repository).

Install yay on Arch Linux-Qiita

[[email protected] ~]$ sudo pacman -S base-devel git go
[[email protected] ~]$ git clone
[[email protected] ~]$ cd yay
[[email protected] yay]$ makepkg -si
[[email protected] yay]$ which yay

installation of vscodium

Install open source vscode.

[[email protected] ~]$ git clone
[[email protected] ~]$ cd vscodium-bin
[[email protected] vscodium-bin]$ makepkg -si 
[[email protected] vscodium-bin]$ which vscodium

change icon

Choose your favorite icon from sites such as xfce-look. Download and unzip to $ HOME / .icons. Then select the icon theme you downloaded in ʻApplications-> Settings-> ʻAppearance-> ʻIcons` in the upper left.

McMojave-circle - Eyecandy for your XFCE-DESKTOP -

[[email protected] ~]$ mkdir .icons
[[email protected] ~]$ cd Downloads
[[email protected] Downloads]$ ls
[[email protected] Downloads]$ tar Jxf McMojave-circle-yellow.tar.xz
[[email protected] Downloads]$ ls
McMojave-circle-yellow.tar.xz McMojave-circle-yellow McMojave-circle-yellow-dark
[[email protected] Downloads]$ mv McMojave-circle-yellow McMojave-circle-yellow-dark ../.icons/

Change theme

Choose your favorite theme from sites such as xfce-look. Download and unzip to $ HOME / .themes. Then select the theme you downloaded in ʻApplications-> Settings-> ʻAppearance-> style in the upper left.

material-black COLORS Complete Desktop [GS-3.36 support] - Eyecandy for your XFCE-DESKTOP -

[[email protected] ~]$ mkdir .themes
[[email protected] ~]$ cd Downloads
[[email protected] Downloads]$ ls

[[email protected] Downloads]$ sudo pacman -S unzip

[[email protected] Downloads]$ unzip
[[email protected] Downloads]$ mv Material-Black-Pistachio ../.themes/

Change desktop image

Desktop images are saved by default under / usr / share / backgrounds / xfce, so I think it's easier to manage if you save them in this directory. Select the downloaded image in ʻApplications-> Settings-> Desktop-> Background` in the upper left.

Arch Dark Blue Wallpaper -

[[email protected] Downloads]$ ls
[[email protected] Downloads]$ sudo mv arch_dark_blue.png /usr/share/backgrounds/xfce/

Change the English notation of menu to Japanese

Make ʻApplicationsin the upper left Japanese. I generatedja_JP.UTF-8` in the locale of Chapter 2. Set this to the system locale.

[[email protected] ~]$ su
[[email protected] ~]# localectl set-locale ja_JP.UTF-8
[[email protected] ~]# reboot


After that, customize Launcher with ʻApplications-> Settings-> Panel-> Panel 2-> ʻItems, and you're done.

[[email protected] ~]$ sudo pacman -S neofetch
[[email protected] ~]$ neofetch


Recommended Posts