Skip to content

Instantly share code, notes, and snippets.

@muflone
Forked from amishmm/ArchOracleCloud.md
Last active October 12, 2025 21:01
Show Gist options
  • Select an option

  • Save muflone/be0b6c87dee10c1525004dc1871d7aa8 to your computer and use it in GitHub Desktop.

Select an option

Save muflone/be0b6c87dee10c1525004dc1871d7aa8 to your computer and use it in GitHub Desktop.
Install Arch Linux on Oracle Cloud (Free Tier)

Requirement

  • Console / Cloud Shell access (via https://cloud.oracle.com)
  • Go to the instance page and under Resources -> Console connection -> Launch Cloud Shell connection

Steps

  1. In Ubuntu OR any other Free tier Linux OS
# Switch to root account
sudo -i

# Download Alpine Linux and install it on disk
cd
wget https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.2-x86_64.iso
dd if=alpine-virt-3.16.2-x86_64.iso of=/dev/sda status=progress
sync
reboot
  1. In Alpine Linux (via Oracle Console Connection / Cloud Shell)
  • Wait for Alpine Linux to boot
  • Press Enter to see login prompt
  • Login as 'root' with no password.
  1. Bring up networking in Alpine
echo -e 'auto eth0\niface eth0 inet dhcp' > /etc/network/interfaces
/etc/init.d/networking restart
  1. Setup SSH in Alpine
mkdir ~/.ssh
echo 'YOUR SSH PUBLIC KEY' > ~/.ssh/authorized_keys
setup-sshd
```
Leave all the defaults:
````text
Which ssh server? ('openssh', 'dropbear' or 'none') [openssh] 
Allow root ssh login? ('?' for help) [prohibit-password] 
Enter ssh key or URL for root (or 'none') [none] 

Now you can ssh to your instance remotely

ssh root@INSTANCE_IP -o StrictHostKeyChecking=no
  1. Move Alpine from disk to RAM
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/
  1. Setup APK repositories and get the Arch installation scripts, pacman and other required tools
setup-apkrepos
echo 'http://dl-cdn.alpinelinux.org/alpine/v3.16/community' >> /etc/apk/repositories
apk update
apk add arch-install-scripts pacman dosfstools e2fsprogs nano zstd
  1. Partition the disk and mount the partitions
fdisk /dev/sda

in fdisk: (TIP: You may have to first delete all partitions using 'd' and then 'w' (save) and then proceed with following):

Press "g" (use gpt table)
Press "n", partition 2, First sector default, Last sector +512M (set esp/EFI partition 2, size 512M)
Press "t", then "1" (set type as EFI System)
Press "n", partition 1 (set root partition 1, size remaining)
Press "w" (save the changes)

then in shell:

# partprobe is not effective, let's create the nodes
mknod -m 660 /dev/sda1 b 8 1
mknod -m 660 /dev/sda2 b 8 2
mkfs -t ext4 -m 0 -L root /dev/sda1
mkfs -t vfat -n EFI /dev/sda2
mount /dev/sda1 /mnt
mkdir -p /mnt/boot/EFI
mount /dev/sda2 /mnt/boot/EFI
  1. Prepare Arch bootstrap (1GB RAM is not enough so we use HDD)
mkdir /mnt/tmp
cd /mnt/tmp
wget -c https://geo.mirror.pkgbuild.com/iso/latest/archlinux-bootstrap-x86_64.tar.zst
zstd -d --stdout archlinux-bootstrap-x86_64.tar.zst | tar xv
# uncomment mirrors
sed -i 's/#Server/Server/g' root.x86_64/etc/pacman.d/mirrorlist
arch-chroot root.x86_64
# now we are inside Arch Installation process (as if booted through Arch ISO / Boot medium)
pacman-key --init
pacman-key --populate archlinux
  1. Install Arch on /mnt
mount /dev/sda1 /mnt
mount /dev/sda2 /mnt/boot/EFI
pacstrap /mnt base linux linux-firmware amd-ucode e2fsprogs openssh nano grub efibootmgr
genfstab -U /mnt >> /mnt/etc/fstab
  1. Configure the Arch system
arch-chroot /mnt
# now we are inside our actual Arch system which we will be using in future

# setup root password incase of serial console (see below) based recovery is required
passwd

# Setup swap (1GB)
dd if=/dev/zero of=/swapfile bs=1M count=1024 status=progress
chmod 600 /swapfile
mkswap /swapfile
echo '/swapfile none swap defaults 0 0' >> /etc/fstab

# Configure the services
systemctl enable systemd-networkd systemd-timesyncd sshd
systemctl set-default multi-user.target

# Basic Arch configuration
ln -sf /usr/share/zoneinfo/UTC /etc/localtime
hwclock --systohc
# Enable en_US-UTF-8 locale
sed -i 's/#en_US.UTF-8/en_US.UTF-8/' /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' >> /etc/locale.conf
echo 'YOUR HOSTNAME' >> /etc/hostname

# sshd: PermitRootLogin with authorized_keys
echo 'PermitRootLogin prohibit-password' > /etc/ssh/sshd_config.d/21-root-login.conf
mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo 'YOUR SSH PUBLIC KEY' >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
  1. Configure Networking (DHCP)
echo -e 'search localdomain\nnameserver 1.1.1.1\nnameserver 1.0.0.1' > /etc/resolv.conf
cat << EOF > /etc/systemd/network/20-ethernet.network
[Match]
Name=en*
Name=eth*

[Network]
# How to enable IPv6 on Oracle Cloud? - https://youtu.be/yxm3Bn7uHyw
# Also open port 546 on IPv6. Nftables example:
# nft add rule ip6 filter INPUT udp dport dhcpv6-client accept
DHCP=yes
IPv6AcceptRA=yes
IPForward=no

[DHCPv4]
UseDNS=false
UseNTP=false

[DHCPv6]
UseDNS=false
UseNTP=false

[IPv6AcceptRA]
UseDNS=false
UseDomains=false
EOF
  1. Setup the Serial Console (ttyS0)

This step is optional but helpful to get instance Console (ttyS0) / Cloud Shell access (via https://cloud.oracle.com) in case the system is not accessible via SSH or not booting.

echo 'GRUB_TERMINAL_INPUT="console serial"' >> /etc/default/grub
echo 'GRUB_TERMINAL_OUTPUT="gfxterm serial"' >> /etc/default/grub
echo 'GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"' >> /etc/default/grub
echo 'GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT/quiet/}"' >> /etc/default/grub
echo 'GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} console=tty0 console=ttyS0,115200"' >> /etc/default/grub
  1. Configure EFI boot
grub-install --efi-directory=/boot/EFI --bootloader-id=GRUB
# create fallback boot loader too
mkdir -p /boot/EFI/EFI/BOOT
cp -dp /boot/EFI/EFI/GRUB/grubx64.efi /boot/EFI/EFI/BOOT/BOOTX64.EFI
grub-mkconfig -o /boot/grub/grub.cfg

Also follow Arch Installation guide for any other steps that you may require: https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system

  1. Exit from chroot, reboot and boot to your Arch!
exit
exit
reboot

Enjoy!

References

  1. https://wiki.alpinelinux.org/wiki/Replacing_non-Alpine_Linux_with_Alpine_remotely
  2. https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.2-x86_64.iso
  3. https://wiki.archlinux.org/title/Install_Arch_Linux_from_existing_Linux
  4. https://geo.mirror.pkgbuild.com/iso/latest/archlinux-bootstrap-x86_64.tar.zst
  5. https://wiki.archlinux.org/title/Working_with_the_serial_console
  6. https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system
  7. https://youtu.be/yxm3Bn7uHyw (Enable IPv6 for Oracle Cloud Infrastructure)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment