0

0

Reinstalling Alpine Linux on a Lighthouse Instance

看不見的法師

看不見的法師

发布时间:2025-07-14 09:40:02

|

1007人浏览过

|

来源于php中文网

原创

reinstalling alpine linux on a lighthouse instance

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.

OneAI
OneAI

将生成式AI技术打包为API,整合到企业产品和服务中

下载
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

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.

相关专题

更多
session失效的原因
session失效的原因

session失效的原因有会话超时、会话数量限制、会话完整性检查、服务器重启、浏览器或设备问题等等。详细介绍:1、会话超时:服务器为Session设置了一个默认的超时时间,当用户在一段时间内没有与服务器交互时,Session将自动失效;2、会话数量限制:服务器为每个用户的Session数量设置了一个限制,当用户创建的Session数量超过这个限制时,最新的会覆盖最早的等等。

308

2023.10.17

session失效解决方法
session失效解决方法

session失效通常是由于 session 的生存时间过期或者服务器关闭导致的。其解决办法:1、延长session的生存时间;2、使用持久化存储;3、使用cookie;4、异步更新session;5、使用会话管理中间件。

740

2023.10.18

cookie与session的区别
cookie与session的区别

本专题整合了cookie与session的区别和使用方法等相关内容,阅读专题下面的文章了解更详细的内容。

88

2025.08.19

default gateway怎么配置
default gateway怎么配置

配置default gateway的步骤:1、了解网络环境;2、获取路由器IP地址;3、登录路由器管理界面;4、找到并配置WAN口设置;5、配置默认网关;6、保存设置并退出;7、检查网络连接是否正常。本专题为大家提供相关的文章、下载、课程内容,供大家免费下载体验。

220

2023.12.07

磁盘配额是什么
磁盘配额是什么

磁盘配额是计算机中指定磁盘的储存限制,就是管理员可以为用户所能使用的磁盘空间进行配额限制,每一用户只能使用最大配额范围内的磁盘空间。php中文网为大家提供各种磁盘配额相关的内容,教程,供大家免费下载安装。

1349

2023.06.21

如何安装LINUX
如何安装LINUX

本站专题提供如何安装LINUX的相关教程文章,还有相关的下载、课程,大家可以免费体验。

702

2023.06.29

linux find
linux find

find是linux命令,它将档案系统内符合 expression 的档案列出来。可以指要档案的名称、类别、时间、大小、权限等不同资讯的组合,只有完全相符的才会被列出来。find根据下列规则判断 path 和 expression,在命令列上第一个 - ( ) , ! 之前的部分为 path,之后的是 expression。还有指DOS 命令 find,Excel 函数 find等。本站专题提供linux find相关教程文章,还有相关

294

2023.06.30

linux修改文件名
linux修改文件名

本专题为大家提供linux修改文件名相关的文章,这些文章可以帮助用户快速轻松地完成文件名的修改工作,大家可以免费体验。

776

2023.07.05

高德地图升级方法汇总
高德地图升级方法汇总

本专题整合了高德地图升级相关教程,阅读专题下面的文章了解更多详细内容。

72

2026.01.16

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
PostgreSQL 教程
PostgreSQL 教程

共48课时 | 7.4万人学习

Git 教程
Git 教程

共21课时 | 2.8万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号