Skip to content

Instantly share code, notes, and snippets.

@hdm9527
Forked from zengxinhui/convert2arch_arm.sh
Created April 7, 2023 12:59
Show Gist options
  • Save hdm9527/546abf4fdadd99f62659ee499372a5f2 to your computer and use it in GitHub Desktop.
Save hdm9527/546abf4fdadd99f62659ee499372a5f2 to your computer and use it in GitHub Desktop.
Replace Oracle Cloud Linux with Arch Linux ARM remotely
Refs:
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.
1. In Oracle Linux 8.0
cd /tmp
wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/aarch64/alpine-virt-3.13.5-aarch64.iso
dd if=alpine-virt-3.13.5-aarch64.iso of=/dev/sda
sync
reboot
2. In Alpine w/ Console access:
# [Bring up networking]
vi /etc/network/interfaces, add:
auto eth0
iface eth0 inet dhcp
ifup eth0
# [Setup SSH]
setup-sshd
adduser tempuser
passwd tempuser
# [At this point it's easier to use SSH to copy & paste]
# [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
vi /etc/apk/repositories, enable community
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.vfat /dev/sda15
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt
mkdir -p /mnt/boot/efi
mount /dev/sda15 /mnt/boot/efi
cd /mnt
wget http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
bsdtar -xpf /mnt/ArchLinuxARM-aarch64-latest.tar.gz -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/efi --bootloader-id=GRUB
# [grub config]
grub-mkconfig -o /boot/grub/grub.cfg
# [workaround: grub of alarm doesn't detect linux]
echo "linux (hd0,gpt1)/boot/Image.gz root=/dev/sda1" >> /boot/grub/grub.cfg
echo "initrd (hd0,gpt1)/boot/initramfs-linux.img" >> /boot/grub/grub.cfg
echo boot >> /boot/grub/grub.cfg
vi /etc/ssh/sshd_config and update to "PasswordAuthentication no"
change to user 'alarm', create ~/.ssh and ~/.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