Skip to content

Instantly share code, notes, and snippets.

@JaHIY
Forked from zengxinhui/convert2arch_x64.sh
Last active September 12, 2022 14:30
Show Gist options
  • Save JaHIY/48e8732b90d830ad1ca6183cc8e6c430 to your computer and use it in GitHub Desktop.
Save JaHIY/48e8732b90d830ad1ca6183cc8e6c430 to your computer and use it in GitHub Desktop.
Replace Oracle Cloud Linux with Arch Linux remotely

Refs

  1. http://mirror.cs.pitt.edu/archlinux/iso/2022.03.01/archlinux-bootstrap-2022.03.01-x86_64.tar.gz
  2. https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.1-x86_64.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

Requirement

  • Console access.

Steps

  1. In Ubuntu
cd /
wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.1-x86_64.iso
dd if=alpine-virt-3.13.1-x86_64.iso of=/dev/sda
sync
reboot
  1. In Alpine [Bring up networking]
vi /etc/network/interfaces

add:

auto eth0
iface eth0 inet dhcp

then in shell:

ifup eth0

[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 pacman arch-install-scripts btrfs-progs

[Disk partitioning & mounting]

fdisk /dev/sda

in fdisk:

Press "g". (use gpt table)
Press "n", partition 15, size +512M; Press "t", then "1". (set esp partition 15, size 512M)
Press "n", partition 1. (set root partition 1, size remaining)
Press "w". (save the changes)

then in shell:

mkfs.vfat /dev/sda15
mkfs.btrfs /dev/sda1
mount /dev/sda1 /mnt
mkdir -p /mnt/boot/EFI
mount /dev/sda15 /mnt/boot/EFI

[1G ram is not enough to hold arch bootstrap. Use HDD for now.]

mkdir /mnt/tmp
cd /mnt/tmp
wget -c http://mirror.cs.pitt.edu/archlinux/iso/2022.03.01/archlinux-bootstrap-2022.03.01-x86_64.tar.gz
tar xf archlinux-bootstrap-2022.03.01-x86_64.tar.gz
vi root.x86_64/etc/pacman.d/mirrorlist
arch-chroot root.x86_64/
pacman-key --init
pacman-key --populate archlinux

[Any other way than mount again?]

mount /dev/sda1 /mnt
mount /dev/sda15 /mnt/boot/EFI
pacstrap /mnt base base-devel linux linux-firmware btrfs-progs dhcpcd openssh vim
genfstab -U /mnt >> /mnt/etc/fstab
arch-chroot /mnt
systemctl enable dhcpcd
systemctl enable sshd

[EFI boot]

pacman -S grub efibootmgr amd-ucode
grub-install --efi-directory=/boot/EFI --bootloader-id=GRUB
grub-mkconfig -o /boot/grub/grub.cfg

then follow https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system

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