ArchLinux ARM is a very flexible base for a highly customised Linux experience on the Pinebook.
As I personally had some requirements towards my Pinebook that were not covered by any provided image, I decided to use Anarsoul's great ArchLinux image as a base for a custom ArchLinux installation. This process is very simple if you have already have experience with installing ArchLinux on a x64 system - it does not differ much from the normal way how ArchLinux is installed. The short todo list is
I DO NOT TAKE ANY RESPONSIBILITY IF TRYING TO FOLLOW THESE STEPS LEAD TO ANY PROBLEMS, INCLUDING BROKEN HARDWARE OR SERIOUS INJURY AND/OR DEATH.
Still here? Let's go . These steps will lead to an encrypted installation on your eMMC card (that was my usecase because I tend to forget hardware in trains, buses and so on).
1. Flash Anarsoul's ArchLinux image to an SD card and boot it. It's available via the official PineBook installer utility, but the last time I checked the version available via the PineBook installer utility was out of date.
2. Boot it & log-in.
3. Fire up a terminal.
4. Get a root shell (using sudo for everything is possible, too).
5. Connect to your wifi (either via the NetworkManager gui or from within the terminal using wifi-menu).
6. Install arch-install-scripts. Updating everything else on the SD card while we're here doesn't hurt, either.
7. Make sure you take the right device for partioning. The SD card should normally be mmcblk1, the eMMC should normally be mmcblk2.
8. Start partioning. The following commands come basically directly from Anarsoul's scripts. You can adapt sizes, types & everything here if you want to. If step 7 lead to a different result than /dev/mmcblk2, adapt the command below.
9. Create a new empty partition table.
10. Create a boot partition. This partition should start at position 40960 and have a size of (at least) 100M. As I have 64GB eMMC, I like to be more generous and use 1GB.
11. Change the type of the partition to "W95 FAT32 (LBA)".
12. Create the main partition that we'll use for the encryption. I use all remaiming space for mine, so this step is easier. This partition should start were the previous partition ends; you can find out that position by either calculating it (starting position of the previous partition plus two-times its size) or by looking it up (use p to print the current partion layout).
13. Give it type 83 ("Linux").
14. Anarsoul sets a boot flag on one of his partitions, but it was not necessary on my Pinebook. Simply write the changes to disk.
15. Let's create the FAT32 file system on our boot partition. Check with lsblk beforehand what device names/parition names to use.
16. Let's create the encrypted partition.
17. Mount it with the password that you created in step 16.
18. Create an LVM in it. I actually use quite a large swap partition, but as I said, my eMMC is large enough. The previous version contained a typo; the command should be pvcreate.
19. Create the swap.
20. Create whatever filesystem you want for your root partition.
21. Mount root to /mnt, boot to /mnt/boot.
22. Install (at least) the base system. Add the packages from Anarsoul's scripts here. You can already add a desktop environment and other stuff here if you want to. The Arch Wiki's advice for most DEs works flawlessly on ARM, too. Incomplete list of DEs (using only a window manager might be a nice idea on the Pinebook): KDE LXDE LXQt Xfce
23. Generate the fstab for the new system.
24. Switch to the new system.
25. Set your timezone.
26. Generate your locale. Edit /etc/locale.gen and uncomment all the locales you want to use. After that, generate them.
27. Set one of the languages you just generated in /etc/locale.conf. Here's an example.
28. If you want a special keyboard layout, that it in /etc/vconsole.conf. Here's an example.
29. Set a hostname for the computer in /etc/hostname. Here's an example.
28. Set a password for root.
29. Add Anarsoul's repository to /etc/pacman.conf.
30. Now for the fun part: Getting this thingie to boot from our encrypted partition! First we'll need some additional hooks in the initial kernel. So edit /etc/mkinitcpio.conf, look for the HOOKS line and add some hooks (for keymap support, for encryption support, for lvm support). The order is important.
31. Generate the new image.
32. Modify /boot/boot.txt. We need to set kernel options for the cryptdevice. I also set one for the resume even though that is currently not working, but may work in the future. We need to modify the line with setenv bootargs in it. Personally, I use the UUID for the partition, but that's harder to write. Use blkid to find out the UUID of the encrypted partition and then use cryptdevice=UUID=... if you want that. Here's an non-UUID example:
In the same file, adapt all the paths in the big if-fi block so that they point directly at e.g. /Image.gz as the parition will be mounted by u-boot without the prepending /boot/.
33. Compile the file.
34. Leave the chroot.
35. Do the finetuning from Anarsoul's scripts. The last two lines only work if you already installed a desktop environment during step 22.
36. Write uboot to the beginning of the eMMC.
37. Reboot without the SD card.
37. Enter your encryption password to boot.
38. Log in as root, add a normal user, configure your wifi with wifi-menu and install whatever DE you want.
I hope I didn't forget something. Please report any typos or missing steps. Thank you!
Thanks to e-minguez for pointing out errors and typos!
* I'm one of these many people myself often enough.
As I personally had some requirements towards my Pinebook that were not covered by any provided image, I decided to use Anarsoul's great ArchLinux image as a base for a custom ArchLinux installation. This process is very simple if you have already have experience with installing ArchLinux on a x64 system - it does not differ much from the normal way how ArchLinux is installed. The short todo list is
- flash Anarsoul's ArchLinux image to an SD card and boot it,
- connect to your local WiFi,
- install the arch-install-scripts package and
- follow the normal ArchLinux installation instructions, carefully merging them with what
- Anarsoul's shell scripts for creating the SD card image do.
I DO NOT TAKE ANY RESPONSIBILITY IF TRYING TO FOLLOW THESE STEPS LEAD TO ANY PROBLEMS, INCLUDING BROKEN HARDWARE OR SERIOUS INJURY AND/OR DEATH.
Still here? Let's go . These steps will lead to an encrypted installation on your eMMC card (that was my usecase because I tend to forget hardware in trains, buses and so on).
1. Flash Anarsoul's ArchLinux image to an SD card and boot it. It's available via the official PineBook installer utility, but the last time I checked the version available via the PineBook installer utility was out of date.
2. Boot it & log-in.
3. Fire up a terminal.
4. Get a root shell (using sudo for everything is possible, too).
Code:
$ su
5. Connect to your wifi (either via the NetworkManager gui or from within the terminal using wifi-menu).
6. Install arch-install-scripts. Updating everything else on the SD card while we're here doesn't hurt, either.
Code:
# pacman -Syu arch-install-scripts
7. Make sure you take the right device for partioning. The SD card should normally be mmcblk1, the eMMC should normally be mmcblk2.
Code:
# lsblk
8. Start partioning. The following commands come basically directly from Anarsoul's scripts. You can adapt sizes, types & everything here if you want to. If step 7 lead to a different result than /dev/mmcblk2, adapt the command below.
Code:
fdisk /dev/mmcblk2
9. Create a new empty partition table.
Code:
Command (m for help): o
10. Create a boot partition. This partition should start at position 40960 and have a size of (at least) 100M. As I have 64GB eMMC, I like to be more generous and use 1GB.
Code:
n
p
1
40960
+1G
11. Change the type of the partition to "W95 FAT32 (LBA)".
Code:
t
c
12. Create the main partition that we'll use for the encryption. I use all remaiming space for mine, so this step is easier. This partition should start were the previous partition ends; you can find out that position by either calculating it (starting position of the previous partition plus two-times its size) or by looking it up (use p to print the current partion layout).
Code:
n
p
2
[CALCULATED STARTING POSITION]
<ENTER>
13. Give it type 83 ("Linux").
Code:
t
2
83
14. Anarsoul sets a boot flag on one of his partitions, but it was not necessary on my Pinebook. Simply write the changes to disk.
Code:
w
15. Let's create the FAT32 file system on our boot partition. Check with lsblk beforehand what device names/parition names to use.
Code:
# mkfs.fat -n ARCHBOOT -F 32 /dev/mmcblk2p1
16. Let's create the encrypted partition.
Code:
# cryptsetup luksFormat /dev/mmcblk2p2
17. Mount it with the password that you created in step 16.
Code:
# cryptsetup luksOpen /dev/mmcblk2p2 archcrypt
18. Create an LVM in it. I actually use quite a large swap partition, but as I said, my eMMC is large enough. The previous version contained a typo; the command should be pvcreate.
Code:
# pvcreate /dev/mapper/archcrypt
# vgcreate archlvm /dev/mapper/archcrypt
# lvcreate -L 4G archlvm -n swap
# lvcreate -l 100%FREE archlvm -n root
19. Create the swap.
Code:
# mkswap -L archswap /dev/archlvm/swap
20. Create whatever filesystem you want for your root partition.
Code:
# mkfs.ext4 -L archroot /dev/archlvm/root
21. Mount root to /mnt, boot to /mnt/boot.
Code:
# mount /dev/archlvm/root /mnt
# mkdir /mnt/boot
# mount /dev/mmcblk2p1 /mnt/boot
22. Install (at least) the base system. Add the packages from Anarsoul's scripts here. You can already add a desktop environment and other stuff here if you want to. The Arch Wiki's advice for most DEs works flawlessly on ARM, too. Incomplete list of DEs (using only a window manager might be a nice idea on the Pinebook): KDE LXDE LXQt Xfce
Code:
pacstrap /mnt base base-devel dosfstools curl xz iw rfkill netctl dialog wpa_supplicant alsa-utils pv linux-pine64 linux-pine64-headers networkmanager \
dkms-rtl8723cs uboot-pine64-git rtl8723bt-firmware uboot-tools
23. Generate the fstab for the new system.
Code:
# genfstab -U /mnt >> /mnt/etc/fstab
24. Switch to the new system.
Code:
# arch-chroot /mnt
25. Set your timezone.
Code:
# ln -sf /usr/share/zoneinfo/<Continent>/<City> /etc/localtime
26. Generate your locale. Edit /etc/locale.gen and uncomment all the locales you want to use. After that, generate them.
Code:
# locale-gen
27. Set one of the languages you just generated in /etc/locale.conf. Here's an example.
Code:
LANG=de_DE.UTF-8
28. If you want a special keyboard layout, that it in /etc/vconsole.conf. Here's an example.
Code:
KEYMAP=de-latin1
29. Set a hostname for the computer in /etc/hostname. Here's an example.
Code:
averageusers-pinebook
28. Set a password for root.
Code:
# passwd
29. Add Anarsoul's repository to /etc/pacman.conf.
Code:
[pine64-mainline]
SigLevel = Never
Server = https://github.com/anarsoul/PKGBUILDs/releases/download/mainline
30. Now for the fun part: Getting this thingie to boot from our encrypted partition! First we'll need some additional hooks in the initial kernel. So edit /etc/mkinitcpio.conf, look for the HOOKS line and add some hooks (for keymap support, for encryption support, for lvm support). The order is important.
Code:
HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck)
31. Generate the new image.
Code:
# mkinitcpio -p linux-pine64
32. Modify /boot/boot.txt. We need to set kernel options for the cryptdevice. I also set one for the resume even though that is currently not working, but may work in the future. We need to modify the line with setenv bootargs in it. Personally, I use the UUID for the partition, but that's harder to write. Use blkid to find out the UUID of the encrypted partition and then use cryptdevice=UUID=... if you want that. Here's an non-UUID example:
Code:
setenv bootargs console=${console} console=tty0 cryptdevice=/dev/mmcblk2p2:archcrypt root=/dev/archlvm/root resume=/dev/archlvm/swap rw rootwait quiet
In the same file, adapt all the paths in the big if-fi block so that they point directly at e.g. /Image.gz as the parition will be mounted by u-boot without the prepending /boot/.
33. Compile the file.
Code:
# cd /boot
# ./mkscr
34. Leave the chroot.
Code:
# exit
35. Do the finetuning from Anarsoul's scripts. The last two lines only work if you already installed a desktop environment during step 22.
Code:
# cp /var/lib/alsa/asound.state /mnt/var/lib/alsa
# cp /etc/sysctl.d/sysrq.conf /mnt/etc/sysctl.d/
# cp /etc/polkit-1/rules.d/81-blueman.rules /mnt/etc/polkit-1/rules.d/
# cp /etc/X11/xorg.conf.d/modesetting.conf /mnt/etc/X11/xorg.conf.d/
# cp /usr/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache /mnt/usr/lib/gdk-pixbuf-2.0/2.10.0/
36. Write uboot to the beginning of the eMMC.
Code:
# dd if=/mnt/boot/u-boot-sunxi-with-spl-pinebook.bin of=/dev/mmcblk2 bs=8k seek=1
37. Reboot without the SD card.
37. Enter your encryption password to boot.
38. Log in as root, add a normal user, configure your wifi with wifi-menu and install whatever DE you want.
I hope I didn't forget something. Please report any typos or missing steps. Thank you!
Thanks to e-minguez for pointing out errors and typos!
* I'm one of these many people myself often enough.