功能强大的linux系统一键DD重装脚本

一、Linux reinstall下载

网站:

    1. https://github.com/leitbogioro/Tools

脚本下载:
wget –no-check-certificate -qO InstallNET.sh ‘https://raw.githubusercontent.com/leitbogioro/Tools/master/Linux_reinstall/InstallNET.sh’ && chmod a+x InstallNET.sh

默认密码是:LeitboGi0ro

相关说明:
支持各大云商,特别支持Oracle ARM机
支持 raid 0,仅限 Debian,要使用 raid 0 请添加 -raid “0”参数。单硬盘请不要添加此参数。有效性尚待测试。
DD Windows 方法和原版萌咖功能一样,该怎么用就怎么用,如果 DD 包无后缀名,默认使用 gz 解压方式,支持 xz 结尾的压缩包,如果要解压 xz 压缩包请添加参数 -filetype “xz”。
支持 RedHat 系新系统,包括 CentOS 9 Stream,RockyLinux 8+,AlmaLinux 8+,Fedora 34+,也支持从 OracleLinux/VzLinux 装到脚本支持的系统。
Debian 9+ 支持 xfs,这也是 Redhat 系默认的文件系统,抛弃老旧的默认 ext2。
如果要指定其他参数,比如镜像地址,系统后面必须带上版本,比如:-debian 11,不然会出错。
默认采用 DHCP 配置网络,如果确认是静态地址,请附带 –dhcp-static 参数,不过脚本仍然会自动检测,如果是 DHCP,还会改回来。
由于 RedHat 7 以后默认采用 firewalld 做防火墙,防火墙不放行的端口都用不了,所以通过强改 firewalld 配置文件来对 RedHat 系列的系统自定 s-s-h 端口号进行支持。此前旧版本仅支持 22 端口,不支持自定。
脚本对当前与运行系统的硬件架构作了判断和对要装的系统硬件架构名称做了自动转换,并且 -v 参数已经被废弃,用 -version 替代,如果不懂,不要再使用这个参数
国内机器不用指定安装源,脚本自动监测并切换到国内源。

注意事项:
脚本完善了对 grub2 的处理,使 Debian 和 Redhat 系可以无限互装而不受影响,萌咖的脚本只支持处理 grub1,这就导致从 Debian 系装到 Redhat 系,grub1 变成了 grub2,导致从 Redhat 系没法再装回 Debian 系。
AMD64 legacy boot 和 AMD64 UEFI boot 以及 ARM64 UEFI boot 的启动项处理参数完全不同,处理错了就是坑,能解决好才是支持主流各 CPU 架构和主板固件启动的基础。
已进行了大量测试,确认 Oracle 机器上跑没问题。
为什么 Debian IPv6 为什么没配置正确(双栈机)?检查一下你原系统是不是 /etc/default/grub 文件里是不是 GRUB_CMDLINE_LINUX=”” 里面带 net.ifnames=0 biosdevname=0 参数?如果带,系统网卡名称会统一变成 eth0 eth1 eth2 这种的,这样会干扰新系统里写入网络配置。有能力的自己在原系统里把相关配置清掉,确保网卡显示的是真实物理网卡的名称,而不是被系统重定向过的,脚本获取手段就是这个,你原系统配置不对,不要怪脚本怎么没在新系统内写入正确的。
多网卡,多ip请进新系统内手工配置,单网卡双栈机自动配置 ipv6 仅限 debian
由于 CentOS 6 的 grub1 脚本语法和其他系统 grub1 grub2 的完全不同,所以不再对装回 CentOS 6 和将 CentOS 6 重装成别的系统的支持。
Redhat 8 要求 2.5GB 内存,Redhat 9 要求 2GB 内存。

二、Linux reinstall使用
先安装依赖:

Debian series(Debian / Ubuntu):
apt update -y
apt install wget -y

Redhat series(CentOS / AlmaLinux / RockyLinux / OracleLinux / Fedora / VzLinux):
yum update –allowerasing -y
yum install wget -y
快速安装系统:

Debian 11系统

bash InstallNET.sh -debian
CentOS 9 stream系统

bash InstallNET.sh -centos
AlmaLinux 9系统

bash InstallNET.sh -almalinux
RockyLinux 9系统

bash InstallNET.sh -rockylinux
Fedora 37系统

bash InstallNET.sh -fedora
Ubuntu 20.04系统

bash InstallNET.sh –ubuntu

三、Linux reinstall参数

Linux reinstall详细的使用示例如下:
bash InstallNET.sh -debian/ubuntu/centos/almalinux/rockylinux/fedora(os type) 11(os version) -version 64(os bit) -port “your server port” -pwd “your server password” -mirror “a valid url for linux image source” -dd/–image “dd image url” -filetype “gz or xz” -timezone “like Asia/Tokyo etc” –dhcp-static/–ip-addr ‘x.x.x.x'(ip address) –ip-mask ‘x.x.x.x'(subnet mask) –ip-gate ‘x.x.x.x'(gateway) -firmware(Debian with hardware drivers)

如果你想安装指定操作系统,请修改为以下的参数:

-debian 9/10/11 : Debian 9 and later

-centos 7/8/9-stream: CentOS 7 and later

-almalinux/alma 8/9: AlmaLinux 8 and later

-rockylinux/rocky 8/9: RockyLinux 8 and later

-fedora 34/35/36/37: Fedora 34 and later

-ubuntu 16.04/18.04/20.04: Ubuntu from 16.04 to 20.04

指定操作系统源:-mirror “a valid DIST mirror url”。有如下官方可供选择:

For Debian, official recommend mirror lists are here:

https://www.debian.org/mirror/list.html
For CentOS, official recommend mirror lists are here:

https://www.centos.org/download/mirrors/
For AlmaLinux, official recommend mirror lists are here:

https://mirrors.almalinux.org/
For RockyLinux, official recommend mirror lists are here:

https://mirrors.rockylinux.org/mirrormanager/mirrors
For Fedora, official recommend mirror lists are here:

https://admin.fedoraproject.org/mirrormanager/mirrors/Fedora
For Ubuntu, official recommend mirror lists are here:

https://launchpad.net/ubuntu/+cdmirrors
指定端口:

-port “”: you can pre-specify s-s-h port of system, range is 1~65535, both Redhat series or Debian series could be supported, 默认端口是’22’.

指定密码:

-pwd “”: you can pre-specify ssh password of system, both Redhat series or Debian series could be supported, 默认密码是’LeitboGi0ro’.

DD系统模式:

-dd/–image “DD image from a valid url”: This parameter is for DD mode in KVM or XEN virtualization platform, current os must be Debian series, for example, if you want to DD windows,。

-filetype “gz/xz”: To determine DD file type, not only “.gz”(default) but also “.xz” can be supported.

指定时区:

-timezone “like Asia/Tokyo etc”.

支持 raid 0,仅限 Debian:

-raid “0”: Only for raid 0 disk partition, if your machine has only one hard drive, don’t assign it!

以安装Debian 11示例如下(默认密码是:LeitboGi0ro):

bash InstallNET.sh -debian 11 -mirror “http://ftp.riken.jp/Linux/debian/debian/”

四、安装Windows系统
脚本并不提供任何Windows系统,你需要自己在网上找一些自己被DD好的Windows系统了。

用法示例:

如果是 KVM or XEN virtualization, Debian series only:

bash InstallNET.sh -dd “DD image download URL”
如果是 physical hardware, Intel network adapter, kimsufi etc:

Change netboot to rescue mode, receive mail, get temporary username and password, log into linux, execute:

wget -O- “DD download URL” | xzcat | dd of=/dev/sda
网上免费的 Windows DD images可以在这里找到:

Windows Server series from TeddySun(https://teddysun.com/):

Username: Administrator
Password: Teddysun.com

Windows Server 2022 Datacenter

Chinese: https://dl.lamp.sh/vhd/zh-cn_win2022.xz
English: https://dl.lamp.sh/vhd/en-us_win2022.xz
Japanese: https://dl.lamp.sh/vhd/ja-jp_win2022.xz

Windows Server 2019 Datacenter

Chinese: https://dl.lamp.sh/vhd/cn_win2019.xz
English: https://dl.lamp.sh/vhd/en_win2019.xz
Japanese: https://dl.lamp.sh/vhd/ja_win2019.xz

Windows Server 2012 R2 Datacenter

Chinese: https://dl.lamp.sh/vhd/cn_win2012r2.xz
English: https://dl.lamp.sh/vhd/en_win2012r2.xz
Japanese: https://dl.lamp.sh/vhd/ja_win2012r2.xz

One thought on “功能强大的linux系统一键DD重装脚本

  1. inst.sh 2023年8月1日 at 下午2:40

    有显示进度的一键dd脚本可以用了《利用可显进度的一键DD脚本1keydd安装win10(同时支持bios,uefi,支持vps,独服,计算实例)》https://www.bilibili.com/video/BV17B4y1b79Y 命令:wget -qO- inst.sh|bash

发表评论