Skip to content

Instantly share code, notes, and snippets.

@kylemanna
Forked from zengxinhui/convert2arch_arm.sh
Last active October 21, 2022 21:03
Show Gist options
  • Save kylemanna/7fb6acd756129c96bb8675a2ea1afe16 to your computer and use it in GitHub Desktop.
Save kylemanna/7fb6acd756129c96bb8675a2ea1afe16 to your computer and use it in GitHub Desktop.
Replace Oracle Cloud Linux with Arch Linux ARM remotely

References

  1. http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
  2. https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.5-aarch64.iso
  3. https://wiki.alpinelinux.org/wiki/Replacing_non-Alpine_Linux_with_Alpine_remotely
  4. https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system
  5. https://archlinuxarm.org/platforms/armv8/generic

Requirement: Console access.

In Oracle Linux 8.0

wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.5-aarch64.iso -qO- | dd bs=1M of=/dev/sda
sync && reboot --force

In Alpine w/ Console access:

Bring up networking

echo -e 'auto eth0\niface eth0 inet dhcp' | tee /etc/network/interfaces
ifup eth0
setup-sshd && mkdir ~/.ssh && vi ~/.ssh/authorized_keys

Per Ref #3

mkdir /media/setup && cp -a /media/sda/* /media/setup
mkdir /lib/setup && cp -a /.modloop/* /lib/setup
/etc/init.d/modloop stop
umount /dev/sda
mv /media/setup/* /media/sda/ && mv /lib/setup/* /.modloop/

Setup apk and bring in pacman

setup-apkrepos
sed -i -e 's:^#\(.*v3.13/community\):\1:' /etc/apk/repositories
apk update && apk add dosfstools e2fsprogs libarchive-tools pacman arch-install-scripts

Disk partitioning & mounting

fdisk /dev/sda #(use gpt table, set esp partition 15 size 512M), set root partition 1 size remaining)
mkfs.ext4 /dev/sda1 && mount /dev/sda1 /mnt
mkfs.vfat /dev/sda15 && mkdir -p /mnt/boot && mount /dev/sda15 /mnt/boot
wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz -qO- | bsdtar -xpf - -C /mnt
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt/
pacman-key --init && pacman-key --populate archlinuxarm

EFI boot

pacman -Syu grub efibootmgr
grub-install --efi-directory=/boot --bootloader-id=GRUB

GRUB config

grub-mkconfig -o /boot/grub/grub.cfg

Secure SSH and setup alarm user

sed -i -e 's:^#\(PasswordAuthentication\)\s\+yes:\1 no:' /etc/ssh/sshd_config
su alarm -c 'mkdir -p ~/.ssh && vi ~/.ssh/authorized_keys'

At this point you should be able to issue 'reboot' and use ssh keyless login to remote into new alarm system.

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