
Start by creating an instance with Debian or your preferred operating system. Log into the instance.
Download the Arch Linux ISO for booting. Although Alpine's boot ISO can be used, the process may not be as seamless, but feel free to experiment with it.
wget https://mirrors.cqu.edu.cn/archlinux/iso/latest/archlinux-2022.02.01-x86_64.iso -O /archlinux.iso
Next, download the 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
Add the following entry to /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, access your VNC session via the web page and reboot the instance. Select the newly added entry in the Grub menu.
Once inside the Arch Linux boot disc shell, remount /dev/vda1 in read-write mode, clear everything except the boot disc and Alpine Linux minirootfs, mount /dev/vda1 to /mnt, and then extract the minirootfs. We will retain the boot disc as a fallback option to resolve any issues via the new Grub configuration.
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_dev/* mount /dev/vda1 /mnt mv /tmp/archlinux.iso /mnt/ mv /tmp/alpine.tar.gz /mnt/ tar -xf /mnt/alpine.tar.gz -C /mnt
Proceed to chroot into the new environment.
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
Configure the 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 the package list, upgrade existing packages, and install the base system.
apk update apk upgrade apk add alpine-base
Install Grub, ensuring to set rootfstype=ext4 in the Linux command line to prevent /dev/vda1 mounting issues.
apk add grub-bios echo 'GRUB_CMDLINE_LINUX="rootfstype=ext4"' >> /etc/default/grub
To avoid unnecessary firmware installations, install linux-firmware-none. We will also install linux-virt.
/boot/grub/grub.cfg is automatically generated, so running grub-mkconfig is unnecessary.
grub-install /dev/vda apk add linux-firmware-none apk add linux-virt
Install e2fsprogs for fsck.ext4.
apk add e2fsprogs
Configure fstab.
echo "/dev/vda1 / ext4 defaults 0 1" > /etc/fstab
Set up the network configuration.
cat > /etc/network/interfaces << EOF auto lo iface lo inet loopback <p>auto eth0 iface eth0 inet dhcp EOF
Configure 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
Finally, reset the root password.
passwd
Reboot the instance to enjoy your freshly installed Alpine Linux.
以上就是Reinstalling Alpine Linux on a Lighthouse Instance的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号