Last active
August 11, 2024 09:03
-
-
Save zengxinhui/f328fdce54f5039689ee3aa4e91fc805 to your computer and use it in GitHub Desktop.
Replace Oracle Cloud Linux with Arch Linux remotely
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[09/23/2023] | |
Refs: | |
1. http://mirror.cs.pitt.edu/archlinux/iso/2023.09.01/archlinux-bootstrap-2023.09.01-x86_64.tar.gz | |
2. https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-virt-3.18.0-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 | |
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/x86_64/alpine-virt-3.18.0-x86_64.iso | |
dd if=alpine-virt-3.18.0-x86_64.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. Move alpine to ram only] | |
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 cfdisk 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 | |
# [1G ram is not enough to hold arch bootstrap. Use HDD for now.] | |
# [or technically you could just use the bootstrap tarball.] | |
mkdir /mnt/tmp | |
cd /mnt/tmp | |
wget http://mirror.cs.pitt.edu/archlinux/iso/2023.09.01/archlinux-bootstrap-2023.09.01-x86_64.tar.gz | |
tar xf archlinux-bootstrap-2023.09.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 to mount again?] | |
mount /dev/sda1 /mnt | |
mount /dev/sda15 /mnt/boot | |
pacstrap /mnt base linux | |
genfstab -U /mnt >> /mnt/etc/fstab | |
umount /mnt/boot | |
umount /mnt | |
exit | |
cd /; arch-chroot /mnt | |
# follow https://wiki.archlinux.org/index.php/installation_guide#Configure_the_system | |
# This is your arch root password. Choose carefully and remember it | |
passwd | |
pacman --noconfirm -S openssh grub efibootmgr vi | |
systemctl enable sshd | |
systemctl enable systemd-networkd | |
cat > ~/.ssh/authorized_keys << EOF | |
<your key here> | |
EOF | |
cat > /etc/systemd/network/en.network << EOF | |
[Match] | |
Name=en* | |
[Network] | |
DHCP=yes | |
DNSSEC=no | |
EOF | |
cat > /etc/systemd/network/eth.network << EOF | |
[Match] | |
Name=eth* | |
[Network] | |
DHCP=yes | |
DNSSEC=no | |
EOF | |
cat > /etc/resolv.conf << EOF | |
nameserver 1.1.1.1 | |
nameserver 4.2.2.2 | |
nameserver 8.8.8.8 | |
EOF | |
# [EFI boot] | |
grub-install --target=x86_64-efi --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 |
Oddly enough, I use neboot. XYZ installs Arch directly, but systemboot fails after installing it in chroot according to the guide
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you still have that problem, check this out.