Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kylemanna
Forked from zengxinhui/convert2arch_x64.sh
Last active October 21, 2022 06:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kylemanna/032f74be4896e581afdc446b48609828 to your computer and use it in GitHub Desktop.
Save kylemanna/032f74be4896e581afdc446b48609828 to your computer and use it in GitHub Desktop.
Replace Oracle Cloud Linux with Arch Linux remotely

Covert

Update

Refs:

  1. http://mirror.cs.pitt.edu/archlinux/iso/2021.02.01/archlinux-bootstrap-2021.02.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.

In Ubuntu / Oracle Linux

wget https://dl-cdn.alpinelinux.org/alpine/v3.13/releases/x86_64/alpine-virt-3.13.1-x86_64.iso -O- | dd of=/dev/sda bs=1M sync reboot -f

Alpine

Bring up networking

vi /etc/network/interfaces auto eth0 iface eth0 inet dhcp ifup eth0

Setup SSH

setup-sshd
mkdir .ssh
cat > .ssh/authorized_keys

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

Disk partitioning & mounting

Use gpt table, set esp partition #15 size 260M), set root partition 1 size remaining

fdisk /dev/sda
mkfs.vfat /dev/sda15
mkfs.ext4 /dev/sda1
mount /dev/sda1 /mnt
mkdir -p /mnt/boot
mount /dev/sda15 /mnt/boot

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

mkdir /mnt/tmp
cd /mnt/tmp
wget https://mirror.arizona.edu/archlinux/iso/latest/archlinux-bootstrap-x86_64.tar.gz -O- | tar zxvf -
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
pacstrap /mnt base linux linux-firmware
genfstab -U /mnt >> /mnt/etc/fstab

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

EFI Boot

mkdir /dev/block ; ln -sfrv /dev/sda15 /dev/block/8:15
bootctl install
sed -e 's:options.*:options root=/dev/sda1 rw:' /usr/share/systemd/bootctl/arch.conf > /boot/loader/entries/arch.conf

Reboot

exit # Exit chroot
cd /
umount /dev/sda*
sync
reboot

Later

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