Skip to content

Instantly share code, notes, and snippets.

@mogenson
Last active September 28, 2018 14:25
Show Gist options
  • Save mogenson/cb176caafe9a047c704dea4d24501039 to your computer and use it in GitHub Desktop.
Save mogenson/cb176caafe9a047c704dea4d24501039 to your computer and use it in GitHub Desktop.
Pocket 2 Arch Linux Installation Guide

GPD Pocket 2 Arch Linux Installation Guide

This following instructions install Arch Linux on a GPD Pocket 2. This installation uses systemd for boot. It sets up a 30GB root partition and an encrypted user partition that is decrypted and mounted on login. Let's get started.

Download and write the Arch Linux installation ISO to a flash drive. Insert flash drive, press power, hold F12, and select flash drive to boot.

Rotate console:
echo 1 > /sys/class/graphics/fbconv/rotate_all

Connect to Wi-Fi:
wifi-menu
systemctl restart dhcpcd.service

Partition disk:
gdisk /dev/mmcblk0

o ↵ to create a new empty GUID partition table (GPT)
y ↵ to confirm

n ↵ add a new partition
↵ to select default partition number of 1
↵ to select default start at first sector
+512M ↵ make that size partition for booting
ef00 ↵ Partition type EFI

n ↵ to add new partition
↵ to select default partition number of 2
↵ to select default start of sector
+30G ↵ make that size partition for root
8300 ↵ to make partition type for root

n ↵ to add new partition
↵ to select default partition number of 3
↵ to select default start of sector
↵ to select default end of sector
8300 ↵ to make partition type for home

p ↵ if you want to check the partition layout
w ↵ to write changes to disk
y ↵ to confirm

Create filesystems:

  • mkfs.fat -F32 /dev/mmcblk0p1
    • for bootloader partition
  • mkfs.ext4 /dev/mmcblk0p2
    • for root partition
  • cryptsetup luksFormat /dev/mmcblk0p3
    • encrypt user partition
    • you must enter the same password you will use for user login
  • cryptsetup open /dev/mmcblk0p3 luks_partition
    • the luks_partition label is only temporary
  • mkfs.ext4 /dev/mapper/mike_home
    • for user partition
  • cryptsetup close luks_partition

Mount partitions:
mount /dev/mmcblk0p2 /mnt
mkdir /mnt/boot
mkdir /mnt/home
mount /dev/mmcblk0p1 /mnt/boot

Install:
pacstrap /mnt base base-devel dialog wpa_supplicant pam_mount intel-ucode

Create /etc/fstab:
genfstab -pU /mnt > /mnt/etc/fstab

Start chroot:
arch-chroot /mnt

Create initramfs:
mkinitcpio -P

Install bootloader:
bootctl install

Copy PARTUUID labels for block devices to bootloader conf:
blkid > /boot/loader/entries/arch.conf

Keep only the PARTUUID for /dev/mmcblk0p2 and edit arch.conf:

title	Arch Linux
linux	/vmlinuz-linux
initrd	/intel-ucode.img
initrd	/initramfs-linux.img
options	root=PARTUUID=70c1cc2d-d307-b94d-8008-38edf777b735 rw fbcon=rotate:1
  • the fbcon=rotate:1 kernel parameter will make console screen rotation permanent

Edit /boot/loader/loader.conf:

default arch
editor no

Change root password:
passwd

Add user:
useradd -m -g users -G wheel,storage mike
passwd mike

  • must be same password used for cryptsetup

Give user sudo power:
visudo

  • uncomment %wheel ALL= (ALL) ALL

Use pam_mount to decrypt and mount /dev/mmcblk0p3 on login:

Edit the end of /etc/security/pam_mount.conf.xml:

<mkmountpoint enable="1" remove="true" />

<volume
        user="mike"
        fstype="crypt"
        path="/dev/mmcblk0p3"
        mountpoint="/home/mike"
        options="fsck,noatime,discard"
/>

</pam_mount>

Edit /etc/pam.d/system-login:

#%PAM-1.0

auth       required   pam_tally.so         onerr=succeed file=/var/log/faillog
auth       required   pam_shells.so
auth       requisite  pam_nologin.so
auth       optional   pam_mount.so
auth       include    system-auth

account    required   pam_access.so
account    required   pam_nologin.so
account    include    system-auth

password   optional   pam_mount.so
password   include    system-auth

session    optional   pam_loginuid.so
session    optional   pam_keyinit.so       force revoke
session    [success=1 default=ignore]  pam_succeed_if.so  service = systemd-user quiet
session    optional   pam_mount.so
session    include    system-auth
session    optional   pam_motd.so          motd=/etc/motd
session    optional   pam_mail.so          dir=/var/spool/mail standard quiet
-session   optional   pam_systemd.so
session    required   pam_env.so

Set hostname:
echo myhostname > /etc/hostname

Set timezone:
ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime

Edit /etc/locale.gen:

  • uncomment en_US.UTF-8 UTF-8 and en_US ISO-8859-1

Generate locale:
locale-gen

Create /etc/locale.conf:
echo "LANG=en_US.UTF-8" > /etc/locale.conf

Edit /etc/hosts with hostname from /etc/hostname:

127.0.0.1	localhost
::1		localhost
127.0.1.1	myhostname.localdomain	myhostname

Exit chroot:
exit

Unmount partitions:
umount -R /mnt

Turn off, remove flash drive, reboot and login to user:
poweroff

Install a desktop enviroment/window manager and customize computer to your preference.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment