- Console / Cloud Shell access (via https://cloud.oracle.com)
- Go to the instance page and under Resources -> Console connection -> Launch Cloud Shell connection
- In Ubuntu OR any other Free tier Linux OS
# 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
sync
reboot
- 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.
- Bring up networking in Alpine
vi /etc/network/interfaces
add:
auto eth0
iface eth0 inet dhcp
then in shell:
/etc/init.d/networking restart
- Setup SSH in Alpine
# in setup-sshd type 'yes' to 'Allow root ssh login?'
# OR if you want to be more secure then setup ssh authorized_keys
setup-sshd
# setup root password for remote login
passwd
Now you can ssh to your instance remotely
ssh root@INSTANCE_IP
- 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/
- Setup APK repositories and get the Arch installation scripts, pacman and other required tools
setup-apkrepos
# enable community repository to fetch pacman etc.
vi /etc/apk/repositories
apk update
apk add arch-install-scripts pacman dosfstools e2fsprogs
- 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 15, First sector default, Last sector +512M (set esp/EFI partition 15, 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
mkfs.vfat /dev/sda15
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt
mkdir -p /mnt/boot/EFI
mount /dev/sda15 /mnt/boot/EFI
- Prepare Arch bootstrap (1GB RAM is not enough so we use HDD)
mkdir /mnt/tmp
cd /mnt/tmp
wget -c https://mirror.cs.pitt.edu/archlinux/iso/2022.09.03/archlinux-bootstrap-2022.09.03-x86_64.tar.gz
tar xf archlinux-bootstrap-2022.09.03-x86_64.tar.gz
# uncomment any one mirror
vi 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
- Install Arch on /mnt
mount /dev/sda1 /mnt
mount /dev/sda15 /mnt/boot/EFI
pacstrap /mnt base linux linux-firmware amd-ucode e2fsprogs openssh vim grub efibootmgr
genfstab -U /mnt >> /mnt/etc/fstab
- 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 (4GB)
dd if=/dev/zero of=/swapfile bs=1M count=4096 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/YOURREGION/YOURCITY /etc/localtime
hwclock --systohc
# uncomment your locale(s)
vim /etc/locale.gen
locale-gen
echo 'LANG=en_US.UTF-8' >> /etc/locale.conf
echo 'TYPE_YOUR_HOSTNAME_HERE' >> /etc/hostname
# sshd: PermitRootLogin with authorized_keys
sed -i -e 's/^#PermitRootLogin/PermitRootLogin/g' /etc/ssh/sshd_config
mkdir -p /root/.ssh
chmod 700 /root/.ssh
echo 'ssh-ed25519 TYPE_YOUR_SSH_KEY_HERE root@localhost' >> /root/.ssh/authorized_keys
chmod 600 /root/.ssh/authorized_keys
- Configure Networking (DHCP)
echo -e 'search localdomain\nnameserver 1.1.1.1\nnameserver 1.0.0.1' >> /etc/resolv.conf
vim /etc/systemd/network/20-ethernet.network
add:
[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
- 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.
vim /etc/default/grub
append:
GRUB_TERMINAL_INPUT="console serial"
GRUB_TERMINAL_OUTPUT="gfxterm serial"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT/quiet/}"
GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} console=tty0 console=ttyS0,115200"
- 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
- Reboot and boot to your Arch!
Enjoy!
- https://wiki.alpinelinux.org/wiki/Replacing_non-Alpine_Linux_with_Alpine_remotely
- https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-virt-3.16.2-x86_64.iso
- https://wiki.archlinux.org/title/Install_Arch_Linux_from_existing_Linux
- https://mirror.cs.pitt.edu/archlinux/iso/2022.09.03/archlinux-bootstrap-2022.09.03-x86_64.tar.gz
- https://wiki.archlinux.org/title/Working_with_the_serial_console
- https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system
- https://youtu.be/yxm3Bn7uHyw (Enable IPv6 for Oracle Cloud Infrastructure)