云服务器安装纯净版 Debian 系统(从网络安装)

各大云厂商提供了种类繁多的系统镜像,也带来了各种全家桶,这里介绍一种简单的方法来安装Debian官方版纯净系统。

本教程支持且不限于阿里云、腾讯云、微软云、谷歌云。

1、重置为Debian10系统,通过VNC/Console登录控制台

理论上,重置为 Ubuntu 等使用grub启动器的系统也是可以的(未测试),此选项仅为安装维护系统。
如果是云厂提供救援模式(比如腾讯云CVM),可以从控制台进入救援模式后,从第3步开始。

2、安装一个维护系统(若云厂提供救援模式,可忽略此步骤)

某些云厂救援模式证书太老了,可能需要给 wget 命令添加参数 --no-check-certificate
mkdir -p /netboot && cd /netboot

rgeo=`wget -qO- https://ipip.rehi.org/country_code`

if [ "$rgeo" == "CN" ]; then
  repo=https://mirrors.tuna.tsinghua.edu.cn/alpine/edge
else
  repo=https://dl-cdn.alpinelinux.org/alpine/edge
fi

wget $repo/releases/x86_64/netboot/vmlinuz-virt
wget $repo/releases/x86_64/netboot/initramfs-virt
modl=$repo/releases/x86_64/netboot/modloop-virt

cat >> /etc/grub.d/40_custom <<EOF
menuentry "Alpine Linux Minimal" {
    search --set=root --file /netboot/vmlinuz-virt
    linux /netboot/vmlinuz-virt console=tty0 console=ttyS0,115200 ip=dhcp modloop=$modl alpine_repo=$repo/main/
    initrd /netboot/initramfs-virt
}
EOF

sed -i 's/GRUB_DEFAULT=0/GRUB_DEFAULT="Alpine Linux Minimal"/' /etc/default/grub

update-grub
reboot

3、进入维护系统,执行安装脚本(不挂载本地硬盘,以避免写盘失败)

此过程需要下载系统镜像压缩包,解压后写入硬盘。受网络和硬盘写入性能影响,可能会持续2-10分钟,请耐心等待。
# 云厂救援模式请忽略此命令
if type apk >/dev/null 2>&1; then
    apk add tar xz
fi
# 无 Cloud-init,和下一条命令二选一
wget -O- https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-nocloud-amd64.tar.xz | tar -xJOf - | dd of=/dev/vda
# 有 Cloud-init,启动后会自动安装云厂全家桶
wget -O- https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-generic-amd64.tar.xz | tar -xJOf - | dd of=/dev/vda

4、重启后进入新系统,请参阅以下文章

有 Cloud-init 可忽略此步骤

安装 Debian 系统后的几组常用命令 https://www.rehiy.com/post/452

添加新评论