云服务器安装纯净版 Debian 系统(从网络安装)
各大云厂商提供了种类繁多的系统镜像,也带来了各种全家桶,这里介绍一种简单的方法来安装Debian官方版纯净系统。
启动救援系统
本教程支持且不限于阿里云、腾讯云、微软云、谷歌云。若云厂提供救援模式(如腾讯云),可以从控制台进入救援模式,跳过此步骤。
1、重置为Debian10
系统,通过VNC/Console
登录控制台
理论上,重置为
Ubuntu
等使用grub
启动器的系统也是可以的(未测试),此选项仅为安装救援系统。
2、安装AlpineLinux
救援系统,并设置为从AlpineLinux
启动系统
某些云厂救援模式证书太老了,可能需要给
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
安装新系统到硬盘
进入维护系统,执行安装脚本(不挂载本地硬盘,以避免写盘失败)
常用Debian系统代号及对应版本: bookworm
(12.x)、bullseye
(11.x)、buster
(10.x)
此过程需要下载系统镜像压缩包,解压后写入硬盘。受网络和硬盘写入性能影响,可能会持续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/bookworm/latest/debian-12-nocloud-amd64.tar.xz | tar -xJOf - | dd of=/dev/vda
# 有 Cloud-init,启动后会自动安装云厂全家桶
wget -O- https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.tar.xz | tar -xJOf - | dd of=/dev/vda
重启进入新系统
安装带有 Cloud-init 的版本,可忽略部分后续操作
安装 Debian 系统后的几组常用命令 https://www.rehiy.com/post/452
阿里云上,执行完wget -O- https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-generic-amd64.tar.xz | tar -xJOf - | dd of=/dev/vda重启后,登录系统需要输入密码,这个密码在哪设置的?我试了原服务器的密码不行
空密码