932 字
5 分钟
一键重装 Linux 服务器:Debian/Ubuntu 自动化部署脚本详解
2022-11-05

项目地址,欢迎 star:https://github.com/leitbogioro/Tools

萌咖的一键重装脚本近期经过更新,已经支持 Debian 11/Ubuntu 20.04 等新系统,加入了对 Oracle ARM 机型的支持,现对该脚本进行了一些优化,以增强重装脚本的适用性和实用性。

脚本特色:

全自动无人值守安装;
支持各主流VPS商家;
重装前可预先指定 ssh 密码、端口、固件、镜像源等参数;
对于 Debian 系统,安装时附带的固件源为国外,国内 VPS 连接速度很慢,长时间连接无速度往往会下载失败,可指定 —cdimage ‘cn’,将源切换到国内中科大的,以提高下载速度;
安装时避免进入低内存模式(Debian 特有)后需要进行手动配置,导致无法自动化部署安装的内存量检测阈值,256M 以上机型即使安装时进入低内存模式,也可以自动化进行,这点对内存少于 1GB 的机型尤为重要。已在搬瓦工 512M 机型做过测试,萌咖原版脚本重装 Debian 11 时,会跳低内存模式手动配置,自动化安装过程无法继续,首先必须手动选择需要加载的硬件驱动,项目多且复杂,选择稍有错误,就会导致驱动安装不全,导致系统安装失败,本脚本可保证低内存模式自动化安装过程顺利进行。

下载

wget --no-check-certificate -qO InstallNET.sh 'https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh' && chmod a+x InstallNET.sh

完整版可指定参数案例:

bash InstallNET.sh -d/u/c(系统种类,debian/ubuntu/centos) 11(系统版本) -v 64(32位或64) -port “ssh 登陆端口” -p “ssh 登录密码” -a(自动安装)/m(在 VNC 里手动安装) -firmware(带固件) —mirror ‘系统镜像源,系统安装完成后的默认软件安装包源也是这个’ —cdimage ‘cn’(此项仅适用于在国内要重装成 Debian 的 VPS)

快速上手:

Debian 8

bash InstallNET.sh -d 8 -v 64 -a

Debian 9

bash InstallNET.sh -d 9 -v 64 -a

Debian 10

bash InstallNET.sh -d 10 -v 64 -a

Debian 11 (选择带固件安装时,推荐国内机器安装源的命令)

清华:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'https://mirrors.tuna.tsinghua.edu.cn/debian/' --cdimage 'cn'

网易:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://mirrors.163.com/debian/' --cdimage 'cn'

腾讯云:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://mirrors.cloud.tencent.com/debian/' --cdimage 'cn'

阿里云:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://mirrors.aliyun.com/debian/' --cdimage 'cn'

Debian 11 (如果你的机器在中国大陆以外,连接速度都不会差,就近选择官方源即可)

日本:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.riken.jp/Linux/debian/debian/'

香港:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.hk.debian.org/debian/'

新加坡:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.sg.debian.org/debian/'

韩国:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.kr.debian.org/debian/'

台湾:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.tw.debian.org/debian/'

美国:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.us.debian.org/debian/'

加拿大:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.ca.debian.org/debian/'

英国:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.uk.debian.org/debian/'

德国:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.de.debian.org/debian/'

法国:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.fr.debian.org/debian/'

俄罗斯:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.ru.debian.org/debian/'

澳大利亚:

bash InstallNET.sh -d 11 -v 64 -a -firmware --mirror 'http://ftp.au.debian.org/debian/'

Debian 当地源的格式基本上都是“http://ftp.地区名称缩写.debian.org/debian/”,如果以上例子里不包含你 VPS 所在地,去 https://zh.wikipedia.org/zh-sg/%E5%9C%8B%E5%AE%B6%E5%9C%B0%E5%8D%80%E4%BB%A3%E7%A2%BC (国家地区代码 - Wiki) 找到对应的,替换掉上面链接里“地区名称缩写”位置,放浏览器里访问一下,如果出现一个文件服务器目录,即可使用。日本的源来自日本理化学研究所,一个科研机构,请放心使用。

通用的 Debian 源链接:http://ftp.debian.org/debian/


Ubuntu 16.04

bash InstallNET.sh -u 16.04 -v 64 -a

Ubuntu 18.04

bash InstallNET.sh -u 18.04 -v 64 -a

Ubuntu 20.04

bash InstallNET.sh -u 20.04 -v 64 -a

Cent OS 6

bash InstallNET.sh -c 6.10 -v 64 -a
一键重装 Linux 服务器:Debian/Ubuntu 自动化部署脚本详解
https://blog.wlens.top/posts/linux-reinstall一款功能强大的服务器系统一键重装脚本/
作者
Lao Wang
发布于
2022-11-05
许可协议
CC BY-NC-SA 4.0