Create an instance with Debian or whatever flavour of your choice. Log in.
Download Arch Linux ISO for booting. Alpine's own boot iso will not work as smooth but you are always welcomed to try.
wget https://mirrors.cqu.edu.cn/archlinux/iso/latest/archlinux-2022.02.01-x86_64.iso -O /archlinux.iso
Download Alpine Linux minirootfs.
wget https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.15/releases/x86_64/alpine-minirootfs-3.15.0-x86_64.tar.gz -O /alpine.tar.gz
Put this in /boot/grub/grub.cfg
after the default Debian session.
menuentry "Archlinux Live (x86_64)" {
insmod iso9660
set isofile=/archlinux.iso
loopback lo0 ${isofile}
linux (lo0)/arch/boot/x86_64/vmlinuz-linux img_dev=/dev/vda1 img_loop=${isofile} earlymodules=loop
initrd (lo0)/arch/boot/x86_64/initramfs-linux.img
}
Now open your VNC session on the web page and reboot the instance. Choose the newly created entry in Grub.
Inside the Arch Linux boot disc shell, remount /dev/vda1
read-write, remove anything but the boot disc and Alpine Linux minirootfs, mount /dev/vda1
to /mnt
, then extract the minirootfs.
We will keep the boot disc in case anything goes wrong, we can boot it in the new Grub to fix things.
mount -o rw,remount /dev/vda1
mv /run/archiso/img_dev/archlinux.iso /tmp/
mv /run/archiso/img_dev/alpine.tar.gz /tmp/
rm -rf /run/archiso/img_devpas/*
mount /dev/vda1 /mnt
mv /tmp/archlinux.iso /mnt/
mv /tmp/alpine.tar.gz /mnt/
tar -xf /mnt/alpine.tar.gz -C /mnt
Chroot.
mount -t proc /proc /mnt/proc
mount --rbind --make-rslave /dev /mnt/dev
mount --rbind --make-rslave /sys /mnt/sys
cp -L /etc/resolv.conf /mnt/etc/resolv.conf
chroot /mnt /bin/sh
Set up Alpine repository.
source /etc/profile
cat > /etc/apk/repositories << EOF
https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.15/main
https://mirrors.tuna.tsinghua.edu.cn/alpine/v3.15/community
EOF
Update, upgrade, and install the base package.
apk update
apk upgrade
apk add alpine-base
Install Grub. Make sure to set rootfstype=ext4
in Linux cmdline or /dev/vda1
mounting will fail.
apk add grub-bios
echo 'GRUB_CMDLINE_LINUX="rootfstype=ext4"' >> /etc/default/grub
Install linux-firmware-none
to avoid unnecessary firmware installation.
We are also using linux-virt
.
/boot/grub/grub.cfg
is automatically created. No need to run grub-mkconfig
.
grub-install /dev/vda
apk add linux-firmware-none
apk add linux-virt
Install e2fsprogs
for fsck.ext4
.
apk add e2fsprogs
Setup fstab
.
echo "/dev/vda1 / ext4 defaults 0 1" > /etc/fstab
Setup network.
cat > /etc/network/interfaces << EOF
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
EOF
Setup OpenRC runlevels.
for i in bootmisc hostname hwclock loadkmap loopback modules networking swap sysctl syslog urandom; do
ln -s /etc/init.d/$i /etc/runlevels/boot/
done
for i in devfs dmesg hwdrivers mdev; do
ln -s /etc/init.d/$i /etc/runlevels/sysinit/
done
for i in acpid sshd; do
ln -s /etc/init.d/$i /etc/runlevels/default/
done
for i in killprocs mount-ro savecache; do
ln -s /etc/init.d/$i /etc/runlevels/shutdown/
done
Reset root password.
passwd
Now reboot to your glorious Alpine Linux.
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。