#!/usr/bin/env bash set -x # make-chroot.sh # This script will download an Arch Linux rootfs to a reMarkable 2, # update the packages, and enter the chroot. Running it subsequently # will just enter the existing chroot. PREFIX="/home/root" CHROOT_PATH="$PREFIX/arch-chroot" ROOTFS_URL="http://archlinuxarm.org/os/ArchLinuxARM-armv7-latest.tar.gz" # (reMarkable wget can't do https) function mount_bind { mount -o bind "$CHROOT_PATH" "$CHROOT_PATH" mount -o bind /dev "$CHROOT_PATH/dev" mount -o bind /dev/pts "$CHROOT_PATH/dev/pts" mount -o bind /proc "$CHROOT_PATH/proc" mount -o bind /run "$CHROOT_PATH/run" mount -o bind /sys "$CHROOT_PATH/sys" } # Install rootfs to the desired chroot path if [[ ! -e "$CHROOT_PATH" ]] then ROOTFS_FILE="$PREFIX/$(basename "$ROOTFS_URL")" wget -cO "$ROOTFS_FILE" "$ROOTFS_URL" mkdir -p "$CHROOT_PATH" tar xpf "$ROOTFS_FILE" -C "$CHROOT_PATH"/ rm "$ROOTFS_FILE" mkdir -p "$CHROOT_PATH/home/root" echo "nameserver 1.1.1.1" >> "$CHROOT_PATH/etc/resolv.conf" mount_bind chroot "$CHROOT_PATH" /usr/bin/pacman-key --init chroot "$CHROOT_PATH" /usr/bin/pacman-key --populate archlinuxarm chroot "$CHROOT_PATH" /usr/bin/pacman -Syu --noconfirm chroot "$CHROOT_PATH" /usr/bin/pacman -S --noconfirm \ xorg-server-xvfb x11vnc fi # Start X11 and VNC servers, then drop into chroot Bash mount_bind chroot "$CHROOT_PATH" /usr/bin/killall Xvfb x11vnc chroot "$CHROOT_PATH" /usr/bin/Xvfb :0 -screen 0 1404x1872x16 & chroot "$CHROOT_PATH" /usr/bin/x11vnc -listen 127.0.0.1 -display :0 & chroot "$CHROOT_PATH" /bin/bash