Skip to content

Instantly share code, notes, and snippets.

@BruceLEO1969
Last active January 5, 2023 09:51
Show Gist options
  • Save BruceLEO1969/36188310748ea39e28ada10711efa9bc to your computer and use it in GitHub Desktop.
Save BruceLEO1969/36188310748ea39e28ada10711efa9bc to your computer and use it in GitHub Desktop.
ARM EC2 Install Arch Linux ARM

ARM EC2 Install Arch ARM

Preparation

  • Create an ARM EC2 instance
  • Add an extra EBS(Arch EBS) to the EC2 created
  • Create GPT part table for that EBS(Arch EBS) and create at least 300M EFI part

EC2 type and EBS size are all as you wish, for me i choose c6g.large and 60G gp3 extra EBS(Arch EBS).The parted Arch EBS be like:

sudo fdisk -l /dev/nvme1n1
Disk /dev/nvme1n1: 60 GiB, 64424509440 bytes, 125829120 sectors
Disk model: Amazon Elastic Block Store
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 654E896E-75B3-7D42-8400-3020BB9D024E

Device           Start       End   Sectors  Size Type
/dev/nvme1n1p1    2048   1026047   1024000  500M EFI System
/dev/nvme1n1p2 1026048 125827071 124801024 59.5G Linux filesystem

Arch Install

Format and mout.

sudo mkfs.vfat -F 32 /dev/nvme1n1p1
sudo mkfs.ext4 /dev/nvme1n1p2
sudo mount /dev/nvme1n1p2 /mnt/
sudo mkdir -p /mnt/boot/
sudo mount /dev/nvme1n1p1 /mnt/boot/

Get the latest Arch Linux ARM image and wirite to EBS:

wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
tar -xpf ArchLinuxARM-aarch64-latest.tar.gz -C /mnt

Post Installation

mount -t proc proc -o nosuid,noexec,nodev "/mnt/proc"
mount -t sysfs sys -o nosuid,noexec,nodev,ro "/mnt/sys"
mount -t devtmpfs -o mode=0755,nosuid udev "/mnt/dev"
mkdir -p "/mnt/dev/pts" "/mnt/dev/shm"
mount -t devpts -o mode=0620,gid=5,nosuid,noexec devpts "/mnt/dev/pts"
mount -t tmpfs -o mode=1777,nosuid,nodev shm "/mnt/dev/shm"
mount -t tmpfs -o nosuid,nodev,mode=0755 run "/mnt/run"
mount -t tmpfs -o mode=1777,strictatime,nodev,nosuid tmp "/mnt/tmp"

chroot /mnt

userdel alarm
echo "nameserver 1.1.1.1" > /etc/resolv.conf

pacman-key --init
pacman-key --populate archlinuxarm
pacman -Syy

#pacman -Syu --noconfirm openssl-1.1

pacman -Syu --noconfirm amzn-ena-aarch64-dkms linux linux-headers base-devel \
    unzip lsof rsync strace httpie gnu-netcat strace arch-install-scripts \
    openssl-1.1 python-pip tmux vim lua git go mosh fish tree \
    bash-completion net-tools dnsutils vnstat htop bc zip \
    the_silver_searcher jq tcpdump fish speedtest-cli \
    thefuck rng-tools exa ipython sysstat inetutils 

When installation step finished just remove /etc/resolv.confsystemd-resolved will take over when Arch OS is up and running.

Boot loader

For me, systemd-boot is my favourite.

bootctl install

Then go to /boot/loader/entries and add arch.conf

title   Arch Linux Arm
linux   /Image
initrd  /initramfs-linux.img
options root=PARTUUID="0dc82096-8cb7-2740-bd48-204f31618a60" rw console=ttyS0

fstab

genfstab / -U won't work as excpeted in chroot, but we can fix it ourself.For me i will get UUID by blkid and the final be like:

UUID=61579a2d-a6b5-4f2b-bd6e-05631f4d5790       /               ext4            rw,relatime     0 1

UUID=18F1-8C13                                  /boot           vfat            rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 2

User and Misc

The installtion step basically done here, just some add user and other personal setting left but won't discuss here.

Stop the EC2 instace and detach all it's ebs, then attach the Arch EBS as /dev/xvda and start EC2, and you get an Arch ARM instace running.

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