Skip to content

Instantly share code, notes, and snippets.

@zengxinhui
Last active March 8, 2024 23:41
Show Gist options
  • Star 59 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save zengxinhui/01afb43b8d663a4232a42ee9858be45e to your computer and use it in GitHub Desktop.
Save zengxinhui/01afb43b8d663a4232a42ee9858be45e to your computer and use it in GitHub Desktop.
Replace Oracle Cloud Linux with Arch Linux ARM remotely
[09/23/2023]
Refs:
1. http://os.archlinuxarm.org/os/ArchLinuxARM-aarch64-latest.tar.gz
2. https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/aarch64/alpine-virt-3.18.0-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
See also:
1. Convert to Debian https://gist.github.com/zengxinhui/ee0ad6b7c7f99e2ead6cd0d2bd6641fd
2. Convert to arch x64 https://gist.github.com/zengxinhui/f328fdce54f5039689ee3aa4e91fc805
3. Convert to arch arm https://gist.github.com/zengxinhui/01afb43b8d663a4232a42ee9858be45e
Requirement:
Console access.
# Prepare alpine linux, which can be configured to run from ram only.
# Alpine is leveraged to do the conversion.
# In any linux(ubuntu/debian/arch tested) become root first:
sudo su -
cd /tmp && wget https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/aarch64/alpine-virt-3.18.0-aarch64.iso
dd if=alpine-virt-3.18.0-aarch64.iso of=/dev/sda && sync && reboot
# In Alpine with console:
# [Bring up networking]
ip li set eth0 up
udhcpc eth0
# [Setup SSH, answer RET, yes, RET]
setup-sshd
# [set temp password]
passwd
# [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
# [enable community]
vi /etc/apk/repositories
apk update
apk add dosfstools e2fsprogs findmnt pacman arch-install-scripts
# [Disk partitioning & mounting]
# (use gpt table, set esp partition 15 size 256M), set root partition 1 size remaining)
# g, n, 15, RET, +256m, t, 1, n, RET, RET, RET, p, w
fdisk /dev/sda
ls /dev/sda*
# if sda1 or sda15 is missing, do "/etc/init.d/devfs restart"
mkfs.vfat /dev/sda15
mkfs.ext4 /dev/sda1
mount -t ext4 /dev/sda1 /mnt
mkdir /mnt/boot
mount /dev/sda15 /mnt/boot
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
cd /; arch-chroot /mnt/
# This is your arch root password. Choose carefully and remember it
# do the same for user `alarm` if you prefer to use that account and lots of `sudo`
passwd
cat > ~/.ssh/authorized_keys << EOF
<your key here>
EOF
cat > /etc/resolv.conf << EOF
nameserver 1.1.1.1
nameserver 4.2.2.2
nameserver 8.8.8.8
EOF
pacman-key --init
pacman-key --populate archlinuxarm
pacman --noconfirm -Syu grub efibootmgr vi
# [EFI boot]
grub-install --efi-directory=/boot --bootloader-id=GRUB
vi /etc/default/grub
# Better console. Comparison below:
# GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet"
# GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 console=ttyS0,115200"
# Or use perl/sed to replace
# perl -pi.bak -e "s/quiet/console=ttyS0,115200/" /etc/default/grub
# sed -i.bak -e "s/quiet/console=ttyS0,115200/" /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
exit
reboot
@KaspianDev
Copy link

has anyone had luck installing fedora cloud on this?

@talesam
Copy link

talesam commented Jun 26, 2023

just a doubt, I have to create an instance with Oracle Linux 8, is that it?

The only change I would make is to switch ext4 to BTRFS + ZSTD

@0x09AF
Copy link

0x09AF commented Jul 28, 2023

Followed this guide and with a few tiny mods got Arch up and running. I had one or a few reboots in the process.

When I issued poweroff - Arch powered off but the instance said Running in my Oracle account. I stopped the instance, and the next time I tried running it - it wouldn't boot up, no pings, no SSH. The console shows me Shell> only.

Is the intention here that Alpine is running 24/7 and when it stops - your Arch OS is gone or did I just miss a step somewhere and it's an easy recover?


Played with it for a while. I can get to the UEFI shell and launch EFI/GRUB/grubaa64.efi directly, but this is not a long-term solution. Right now I have a functioning system but whenever I need to power it up I need to create a serial connection and launch OS manually. I even created /boot/startup.nsh but that didn't help

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