diff --git a/README.en.md b/README.en.md index 3b3b840..6d419e6 100644 --- a/README.en.md +++ b/README.en.md @@ -37,7 +37,9 @@ curl -O https://raw.fgit.cf/bin456789/reinstall/main/reinstall.sh ## Download (Current system is Windows) -First, disable the `Real-time Protection` feature of `Windows Defender`. +[Unable to download?](#if-the-script-cannot-be-downloaded-under-windows) + +Before proceeding, please disable the 'Real-time protection' feature in `Windows Defender`. This feature may prevent `certutil` from downloading any files. For users outside China: @@ -51,13 +53,14 @@ For users in China: certutil -urlcache -f -split https://raw.fgit.cf/bin456789/reinstall/main/reinstall.bat ``` -[Unable to download?](#if-the-script-cannot-be-downloaded-under-windows) - ## Usage -- The following examples are for running on Linux; for Windows, run `reinstall.bat` with the same parameters. +All features can be used on both Linux and Windows. -### Usage 1: Install Linux +- on Linux, execute `bash reinstall.sh` +- on Windows, execute `reinstall.bat` + +### Feature 1: Install Linux - For machines with static IP, install CentOS, Alma, Rocky, Fedora, Debian, Ubuntu, and add the --ci parameter to force the use of the cloud image. @@ -82,7 +85,7 @@ Parameters: --ci Force the use of the cloud image ``` -### Usage 2: DD +### Feature 2: DD - Supports gzip, xz formats. @@ -92,7 +95,7 @@ Parameters: bash reinstall.sh dd --img https://example.com/xxx.xz ``` -### Usage 3: Reboot to Alpine Rescue System (Live OS) +### Feature 3: Reboot to Alpine Rescue System (Live OS) - Can be connected via SSH to perform manual DD, modify partitions, manually install Arch / Gentoo, etc. @@ -102,7 +105,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz bash reinstall.sh alpine --hold=1 ``` -### Usage 4: Reboot to [netboot.xyz](https://netboot.xyz/) +### Feature 4: Reboot to [netboot.xyz](https://netboot.xyz/) - Can install more systems using background VNC. @@ -112,7 +115,7 @@ bash reinstall.sh netboot.xyz ![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif) -### Usage 5: Install Windows ISO +### Feature 5: Install Windows ISO ```bash bash reinstall.sh windows \ @@ -124,7 +127,7 @@ bash reinstall.sh windows \ Parameters: -`--iso` Original image link, no need to integrate VirtIO, Xen, AWS, GCP drivers. +`--iso` Original image link `--image-name` Specify the image to install, case-insensitive, should be enclosed in quotes on both sides, for example: @@ -147,17 +150,23 @@ Use `Dism++` File menu > Open Image File, select the iso to be installed to get - Windows Server Annual Channel - Hyper-V Server - Azure Stack HCI -2. BIOS can be used for 32/64 bit, UEFI machines can only use 64-bit. -3. If the machine has a static IP, the IP will be automatically set after installation. -4. Can bypass Windows 11 hardware restrictions. -5. Supports Azure ARM (Hyper-V), does not support Oracle ARM (KVM). -6. The process `wsappx` will occupy CPU for a long time after installing the image `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`. +2. The script will install the following drivers as needed: + - KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)) + - XEN ([XEN PV](https://xenproject.org/windows-pv-drivers/), [AWS PV](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html)) + - AWS ([ENA Network Adapter](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html), [NVMe Storage Controller](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html)) + - GCP ([gVNIC Network Adapter](https://cloud.google.com/compute/docs/networking/using-gvnic), [GGA Graphics](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) + - Azure ([MANA Network Adapter](https://learn.microsoft.com/zh-cn/azure/virtual-network/accelerated-networking-mana-windows)) +3. Vista (Server 2008) and 32-bit systems may lack drivers. +4. If the machine has a static IP, the IP will be automatically set after installation. +5. Can bypass Windows 11 hardware restrictions. +6. Supports Azure ARM (Hyper-V), does not support Oracle ARM (KVM). +7. The process `wsappx` will occupy CPU for a long time after installing the image `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`. This is an issue with the image, and the solution is to install the `VCLibs` library. -7. The following website provides iso links. +8. The following website provides iso links. diff --git a/README.md b/README.md index d230b3b..bb44aaf 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,9 @@ curl -O https://raw.fgit.cf/bin456789/reinstall/main/reinstall.sh ## 下载(当前系统是 Windows) -先关闭 `Windows Defender` 的 `实时保护` 功能 +[无法下载?](#如果-windows-下无法下载脚本) + +请先关闭 `Windows Defender` 的 `实时保护` 功能。该功能会阻止 `certutil` 下载任何文件 国外: @@ -51,14 +53,14 @@ certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinsta certutil -urlcache -f -split https://raw.fgit.cf/bin456789/reinstall/main/reinstall.bat ``` -[无法下载?](#如果-windows-下无法下载脚本) - ## 使用 -- 以下用法以 Linux 下运行为例 -- Windows 下运行 `reinstall.bat`,参数相同 +所有功能均可在 Linux / Windows 下使用 -### 用法 1: 安装 Linux +- Linux 下运行 `bash reinstall.sh` +- Windows 下运行 `reinstall.bat` + +### 功能 1: 安装 Linux - 静态 IP 的机器安装 centos、alma、rocky、fedora、debian、ubuntu,需添加参数 --ci 强制使用云镜像 @@ -83,7 +85,7 @@ bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本) --ci 强制使用云镜像 ``` -### 用法 2: DD +### 功能 2: DD - 支持 gzip、xz 格式 @@ -93,7 +95,7 @@ bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本) bash reinstall.sh dd --img https://example.com/xxx.xz ``` -### 用法 3: 重启到 Alpine 救援系统 (Live OS) +### 功能 3: 重启到 Alpine 救援系统 (Live OS) - 可用 ssh 连接,进行手动 DD、修改分区、手动安装 Arch / Gentoo 等操作 @@ -103,7 +105,7 @@ bash reinstall.sh dd --img https://example.com/xxx.xz bash reinstall.sh alpine --hold=1 ``` -### 用法 4: 重启到 [netboot.xyz](https://netboot.xyz/) +### 功能 4: 重启到 [netboot.xyz](https://netboot.xyz/) - 可使用后台 VNC 安装更多系统 @@ -113,7 +115,7 @@ bash reinstall.sh netboot.xyz ![netboot.xyz](https://netboot.xyz/images/netboot.xyz.gif) -### 用法 5: 安装 Windows ISO +### 功能 5: 安装 Windows ISO ```bash bash reinstall.sh windows \ @@ -125,7 +127,7 @@ bash reinstall.sh windows \ 参数: -`--iso` 原版镜像链接,无需集成 VirtIO、Xen、AWS、GCP 驱动 +`--iso` 原版镜像链接 `--image-name` 指定要安装的映像,不区分大小写,两边要有引号,例如: @@ -148,17 +150,23 @@ bash reinstall.sh windows \ - Windows Server Annual Channel - Hyper-V Server - Azure Stack HCI -2. BIOS 可使用 32/64 位,UEFI 机器只可使用 64 位 -3. 如果机器是静态 IP,安装后会自动设置 IP -4. 可绕过 Windows 11 硬件限制 -5. 支持 Azure ARM (Hyper-V),不支持甲骨文 ARM (KVM) -6. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 此镜像安装后 `wsappx` 进程会长期占用 CPU +2. 脚本会按需安装以下驱动: + - KVM ([Virtio](https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/)) + - XEN ([XEN PV](https://xenproject.org/windows-pv-drivers/)、[AWS PV](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html)) + - AWS ([ENA 网卡](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html)、[NVME 存储控制器](https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html)) + - GCP ([gVNIC 网卡](https://cloud.google.com/compute/docs/networking/using-gvnic)、[GGA 显卡](https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display)) + - Azure ([MANA 网卡](https://learn.microsoft.com/zh-cn/azure/virtual-network/accelerated-networking-mana-windows)) +3. Vista (Server 2008) 和 32 位系统可能会缺少驱动 +4. 静态 IP 的机器,安装后会自动配置好 IP +5. 可绕过 Windows 11 硬件限制 +6. 支持 Azure ARM (Hyper-V),不支持甲骨文 ARM (KVM) +7. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso` 此镜像安装后 `wsappx` 进程会长期占用 CPU 这是镜像的问题,解决方法是安装 `VCLibs` 库 -7. 以下网站可找到 iso 链接 +8. 以下网站可找到 iso 链接 diff --git a/trans.sh b/trans.sh index 11f38e3..e12ac9d 100644 --- a/trans.sh +++ b/trans.sh @@ -1914,16 +1914,8 @@ install_windows() { nt_ver="$(peres -v /iso/setup.exe | grep 'Product Version:' | cut -d: -f2 | xargs | cut -d. -f 1,2)" echo "NT Version: $nt_ver" - is_nt_6_1() { - [ "$nt_ver" = 6.1 ] - } - - is_win11() { - echo $image_name | grep -iEw '^Windows 11' - } - # 跳过 win11 硬件限制 - if is_win11; then + if [[ "$image_name" = "Windows 11"* ]]; then wiminfo "$install_wim" "$image_name" --image-property WINDOWS/INSTALLATIONTYPE=Server fi @@ -1968,15 +1960,28 @@ install_windows() { [ "$arch_wim" = x86_64 ]; then # aws nitro # 只有 x64 位驱动 + # 可能不支持 vista # https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/aws-nvme-drivers.html # https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/enhanced-networking-ena.html - if is_nt_6_1; then - download https://s3.amazonaws.com/ec2-windows-drivers-downloads/NVMe/1.3.2/AWSNVMe.zip $drv/AWSNVMe.zip - download https://s3.amazonaws.com/ec2-windows-drivers-downloads/ENA/x64/2.2.3/AwsEnaNetworkDriver.zip $drv/AwsEnaNetworkDriver.zip - else - download https://s3.amazonaws.com/ec2-windows-drivers-downloads/NVMe/Latest/AWSNVMe.zip $drv/AWSNVMe.zip - download https://s3.amazonaws.com/ec2-windows-drivers-downloads/ENA/Latest/AwsEnaNetworkDriver.zip $drv/AwsEnaNetworkDriver.zip - fi + + nvme_ver=$( + case "$nt_ver" in + 6.0 | 6.1) echo 1.3.2 ;; + *) echo Latest ;; + esac + ) + + ena_ver=$( + case "$nt_ver" in + 6.0 | 6.1) echo 2.2.3 ;; + 6.2 | 6.3) echo 2.6.0 ;; + *) echo Latest ;; + esac + ) + + download https://s3.amazonaws.com/ec2-windows-drivers-downloads/NVMe/$nvme_ver/AWSNVMe.zip $drv/AWSNVMe.zip + download https://s3.amazonaws.com/ec2-windows-drivers-downloads/ENA/$ena_ver/AwsEnaNetworkDriver.zip $drv/AwsEnaNetworkDriver.zip + unzip -o -d $drv/aws/ $drv/AWSNVMe.zip unzip -o -d $drv/aws/ $drv/AwsEnaNetworkDriver.zip @@ -1984,15 +1989,18 @@ install_windows() { [ "$arch_wim" = x86_64 ]; then # aws xen # 只有 64 位驱动 - # 未测试 + # 可能不支持 vista # https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/WindowsGuide/xen-drivers-overview.html apk add msitools - if is_nt_6_1; then - download https://s3.amazonaws.com/ec2-windows-drivers-downloads/AWSPV/8.3.5/AWSPVDriver.zip $drv/AWSPVDriver.zip - else - download https://s3.amazonaws.com/ec2-windows-drivers-downloads/AWSPV/Latest/AWSPVDriver.zip $drv/AWSPVDriver.zip - fi + aws_pv_ver=$( + case "$nt_ver" in + 6.0 | 6.1) echo 8.3.5 ;; + *) echo Latest ;; + esac + ) + + download https://s3.amazonaws.com/ec2-windows-drivers-downloads/AWSPV/$aws_pv_ver/AWSPVDriver.zip $drv/AWSPVDriver.zip unzip -o -d $drv $drv/AWSPVDriver.zip msiextract $drv/AWSPVDriverSetup.msi -C $drv @@ -2057,6 +2065,14 @@ install_windows() { # 没有 win6.0 文件夹 sys_gce=win$nt_ver fi + + elif [ "$(dmidecode -s chassis-asset-tag)" = "7783-7084-3265-9085-8269-3286-77" ] && + [ "$arch_wim" != arm64 ]; then + # azure + # 有 x86 x64,没 arm64 + # https://learn.microsoft.com/azure/virtual-network/accelerated-networking-mana-windows + download https://aka.ms/manawindowsdrivers $drv/azure.zip + unzip $drv/azure.zip -d $drv/azure/ fi # 修改应答文件 @@ -2072,18 +2088,20 @@ install_windows() { fi # shellcheck disable=SC2010 - if ei_cfg="$(ls -d /os/installer/sources/* | grep -i ei.cfg)"; then + if ei_cfg="$(ls -d /os/installer/sources/* | grep -i ei.cfg)" && + grep -i EVAL "$ei_cfg"; then # 评估版 iso 需要删除 autounattend.xml 里面的 # 否则会出现 Windows Cannot find Microsoft software license terms - if grep -i EVAL "$ei_cfg"; then - sed -i "s|||" /tmp/autounattend.xml - fi + sed -i "/%Key%/d" /tmp/autounattend.xml else - # vista 需密钥,密钥与 edition 可以不一致 + # vista 需密钥,密钥可与 edition 不一致 + # 其他系统要空密钥 if [[ "$image_name" = 'Windows Vista'* ]]; then - vista_gvlk=VKK3X-68KWM-X2YGT-QR4M6-4BWMV - sed -i "s||$vista_gvlk|" /tmp/autounattend.xml + key=VKK3X-68KWM-X2YGT-QR4M6-4BWMV + else + key= fi + sed -i "s/%key%/$key/" /tmp/autounattend.xml fi # 挂载 boot.wim @@ -2114,6 +2132,7 @@ install_windows() { } [ -d $drv/aws ] && cp_drivers $drv/aws [ -d $drv/xen ] && cp_drivers $drv/xen -ipath "*/$arch_xen/*" + [ -d $drv/azure ] && cp_drivers $drv/azure [ -d $drv/gce ] && { [ "$arch_wim" = x86 ] && gvnic_suffix=-32 || gvnic_suffix= cp_drivers $drv/gce/gvnic -ipath "*/$sys_gce$gvnic_suffix/*" diff --git a/windows.xml b/windows.xml index 7a6e1d3..3d5e79d 100644 --- a/windows.xml +++ b/windows.xml @@ -6,8 +6,7 @@ true - OnError - + %key% @@ -18,7 +17,6 @@ %image_name% - OnError %disk_id% %installto_partitionid%