From 859ff9c5bf6fd00089411af7b47454ea39657b91 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Thu, 21 Sep 2023 00:12:49 +0800 Subject: [PATCH] =?UTF-8?q?alpine:=20=E6=B7=BB=E5=8A=A0=E4=BD=8E=E5=86=85?= =?UTF-8?q?=E5=AD=98=E5=AE=89=E8=A3=85=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reinstall.sh | 2 +- trans.sh | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/reinstall.sh b/reinstall.sh index ce6cabe..2ee7aa3 100644 --- a/reinstall.sh +++ b/reinstall.sh @@ -673,7 +673,7 @@ check_ram() { fi case "$distro" in - alpine) ram_installer=0 ;; # 未测试 + alpine) ram_installer=256 ;; # 192 无法启动 netboot debian) ram_installer=384 ;; *) ram_installer=1024 ;; esac diff --git a/trans.sh b/trans.sh index 78a5432..e040a65 100644 --- a/trans.sh +++ b/trans.sh @@ -290,6 +290,44 @@ insert_into_file() { } install_alpine() { + hack_lowram=true + if $hack_lowram; then + # 预先加载需要的模块 + if rc-service modloop status; then + modules="ext4 vfat nls_utf8 nls_cp437 crc32c" + for mod in $modules; do + modprobe $mod + done + fi + + # 删除 modloop ,释放内存 + rc-service modloop stop + rm -f /lib/modloop-lts /lib/modloop-virt + + # 复制一份原版,防止再次运行时出错 + if [ -e /sbin/setup-disk.orig ]; then + cp -f /sbin/setup-disk.orig /sbin/setup-disk + else + cp -f /sbin/setup-disk /sbin/setup-disk.orig + fi + + # 格式化系统分区、mount 后立即开启 swap + # shellcheck disable=SC2016 + insert_into_file /sbin/setup-disk after 'mount -t \$ROOTFS \$root_dev "\$SYSROOT"' <>/mnt/etc/fstab +EOF + fi + # 网络 # 坑1 udhcpc下,ip -4 addr 无法知道是否是 dhcp # 坑2 udhcpc不支持dhcpv6