mirror of
https://github.com/bin456789/reinstall.git
synced 2025-07-06 19:19:52 +00:00
Compare commits
3 Commits
6b35479515
...
4346f4b460
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4346f4b460 | ||
![]() |
71ad989672 | ||
![]() |
0b2eed1750 |
12
README.en.md
12
README.en.md
@ -39,7 +39,7 @@ The system requirements for the target system are as follows:
|
|||||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 40, 41 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (Rolling) | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 512 MB | 5 GB |
|
||||||
@ -132,7 +132,7 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
oracle 8|9
|
oracle 8|9
|
||||||
almalinux 8|9
|
almalinux 8|9
|
||||||
centos 9|10
|
centos 9|10
|
||||||
fedora 40|41
|
fedora 41|42
|
||||||
nixos 24.11
|
nixos 24.11
|
||||||
debian 9|10|11|12
|
debian 9|10|11|12
|
||||||
opensuse 15.6|tumbleweed
|
opensuse 15.6|tumbleweed
|
||||||
@ -163,9 +163,9 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
- `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali).
|
- `--hold 2` Prevent reboot after installation completes, allowing SSH login to modify system content; the system is mounted at `/os` (this feature is not supported on Debian/Kali).
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> When installing Debian/Kali, x86 architectures can monitor the installation progress through VNC in the background, while ARM architectures can use the serial console.
|
> When installing Debian/Kali, x86 architectures can monitor the installation progress through VNC from server provider, while ARM architectures can use the serial console.
|
||||||
>
|
>
|
||||||
> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console).
|
> When installing other systems, can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
|
||||||
> <br />Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
|
> <br />Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@ -219,7 +219,7 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
|||||||
- `--hold 2` Prevent reboot after the DD process finishes, allowing SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted.
|
- `--hold 2` Prevent reboot after the DD process finishes, allowing SSH login to modify system content. The Windows system will be mounted at `/os`, but Linux systems will **NOT** be automatically mounted.
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC in the background, serial console).
|
> Can monitor the progress through various methods (SSH, HTTP 80 port, VNC from server provider, serial console).
|
||||||
> <br />Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
|
> <br />Even if errors occur during the installation process, you can still install to Alpine via SSH by running `/trans.sh alpine`
|
||||||
|
|
||||||
### Feature 3: Reboot to <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS (RAM OS)
|
### Feature 3: Reboot to <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS (RAM OS)
|
||||||
@ -400,7 +400,7 @@ bash reinstall.sh windows \
|
|||||||
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
- AWS ([ENA Network Adapter][aws-ena], [NVME Storage Controller][aws-nvme])
|
||||||
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
- GCP ([gVNIC Network Adapter][gcp-gvnic], [GGA Display Adapter][gcp-gga])
|
||||||
- Azure ([MANA Network Adapter][azure-mana])
|
- Azure ([MANA Network Adapter][azure-mana])
|
||||||
- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
- Intel ([VMD Storage Controller][intel-vmd], Network Adapter: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||||
|
|
||||||
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||||
|
12
README.md
12
README.md
@ -39,7 +39,7 @@
|
|||||||
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.redhat.com/favicon.ico" /> RHEL <img width="16" height="16" src="https://almalinux.org/fav/favicon.ico" /> AlmaLinux <img width="16" height="16" src="https://rockylinux.org/favicon.png" /> Rocky <img width="16" height="16" src="https://www.oracle.com/asset/web/favicons/favicon-32.png" /> Oracle | 8, 9 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://opencloudos.org/qq.ico" /> OpenCloudOS | 8, 9, Stream 23 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.centos.org/assets/icons/favicon.svg" /> CentOS Stream | 9, 10 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 40, 41 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://fedoraproject.org/favicon.ico" /> Fedora | 41, 42 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://www.openeuler.org/favicon.ico" /> openEuler | 20.03 LTS - 24.03 LTS, 25.03 | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
| <img width="16" height="16" src="https://static.opensuse.org/favicon.ico" /> openSUSE | Leap 15.6, Tumbleweed (滚动) | 512 MB \* | 5 GB |
|
||||||
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 512 MB | 5 GB |
|
| <img width="16" height="16" src="https://github.com/user-attachments/assets/99a542b6-6482-4086-addf-f192c06fef73" /> NixOS | 24.11 | 512 MB | 5 GB |
|
||||||
@ -132,7 +132,7 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
oracle 8|9
|
oracle 8|9
|
||||||
almalinux 8|9
|
almalinux 8|9
|
||||||
centos 9|10
|
centos 9|10
|
||||||
fedora 40|41
|
fedora 41|42
|
||||||
nixos 24.11
|
nixos 24.11
|
||||||
debian 9|10|11|12
|
debian 9|10|11|12
|
||||||
opensuse 15.6|tumbleweed
|
opensuse 15.6|tumbleweed
|
||||||
@ -163,9 +163,9 @@ bash reinstall.sh anolis 7|8|23
|
|||||||
- `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali)
|
- `--hold 2` 安装结束后不重启,此时可以 SSH 登录修改系统内容,系统挂载在 `/os` (此功能不支持 Debian/Kali)
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 安装 Debian/Kali 时,x86 可通过后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。
|
> 安装 Debian/Kali 时,x86 可通过商家后台 VNC 查看安装进度,ARM 可通过串行控制台查看安装进度。
|
||||||
>
|
>
|
||||||
> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
|
> 安装其它系统时,可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
|
||||||
> <br />即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
|
> <br />即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
@ -219,7 +219,7 @@ bash reinstall.sh dd --img "https://example.com/xxx.xz"
|
|||||||
- `--hold 2` DD 结束后不重启,此时可以 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
|
- `--hold 2` DD 结束后不重启,此时可以 SSH 登录修改系统内容,Windows 系统会挂载在 `/os`,Linux 系统**不会**自动挂载
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> 可通过多种方式(SSH、HTTP 80 端口、后台 VNC、串行控制台)查看安装进度。
|
> 可通过多种方式(SSH、HTTP 80 端口、商家后台 VNC、串行控制台)查看安装进度。
|
||||||
> <br />即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
|
> <br />即使安装过程出错,也能通过 SSH 运行 `/trans.sh alpine` 安装到 Alpine。
|
||||||
|
|
||||||
### 功能 3: 重启到 <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS(内存系统)
|
### 功能 3: 重启到 <img width="16" height="16" src="https://www.alpinelinux.org/alpine-logo.ico" /> Alpine Live OS(内存系统)
|
||||||
@ -400,7 +400,7 @@ bash reinstall.sh windows \
|
|||||||
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
- AWS ([ENA 网卡][aws-ena], [NVME 存储控制器][aws-nvme])
|
||||||
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
- GCP ([gVNIC 网卡][gcp-gvnic], [GGA 显卡][gcp-gga])
|
||||||
- Azure ([MANA 网卡][azure-mana])
|
- Azure ([MANA 网卡][azure-mana])
|
||||||
- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha1], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha1], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
- Intel ([VMD 存储控制器][intel-vmd], 网卡: [7][intel-nic-7-sha256], [8][intel-nic-8], [8.1][intel-nic-8.1], [10][intel-nic-10], [11][intel-nic-11], [2008 R2][intel-nic-7-sha256], [2012][intel-nic-2012], [2012 R2][intel-nic-2012-r2], [2016][intel-nic-2016], [2019][intel-nic-2019], [2022][intel-nic-2022], [2025][intel-nic-2025])
|
||||||
|
|
||||||
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
[virtio-virtio]: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/
|
||||||
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
[virtio-aliyun]: https://www.alibabacloud.com/help/ecs/user-guide/install-the-virtio-driver-1
|
||||||
|
32
reinstall.sh
32
reinstall.sh
@ -52,7 +52,7 @@ Usage: $reinstall_____ anolis 7|8|23
|
|||||||
oracle 8|9
|
oracle 8|9
|
||||||
almalinux 8|9
|
almalinux 8|9
|
||||||
centos 9|10
|
centos 9|10
|
||||||
fedora 40|41
|
fedora 41|42
|
||||||
nixos 24.11
|
nixos 24.11
|
||||||
debian 9|10|11|12
|
debian 9|10|11|12
|
||||||
opensuse 15.6|tumbleweed
|
opensuse 15.6|tumbleweed
|
||||||
@ -200,13 +200,25 @@ get_os_part() {
|
|||||||
awk '($2=="/") { print $1 }' /proc/mounts
|
awk '($2=="/") { print $1 }' /proc/mounts
|
||||||
}
|
}
|
||||||
|
|
||||||
|
umount_all() {
|
||||||
|
# windows defender 打开时,cygwin 运行 mount 很慢,但 cat /proc/mounts 很快
|
||||||
|
if mount_lists=$(mount | grep -w "on $1" | awk '{print $3}' | grep .); then
|
||||||
|
# alpine 没有 -R
|
||||||
|
if umount --help 2>&1 | grep -wq -- '-R'; then
|
||||||
|
umount -R "$1"
|
||||||
|
else
|
||||||
|
echo "$mount_lists" | tac | xargs -n1 umount
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
cp_to_btrfs_root() {
|
cp_to_btrfs_root() {
|
||||||
mount_dir=$tmp/reinstall-btrfs-root
|
mount_dir=$tmp/reinstall-btrfs-root
|
||||||
if ! grep -q $mount_dir /proc/mounts; then
|
if ! grep -q $mount_dir /proc/mounts; then
|
||||||
mkdir -p $mount_dir
|
mkdir -p $mount_dir
|
||||||
mount "$(get_os_part)" $mount_dir -t btrfs -o subvol=/
|
mount "$(get_os_part)" $mount_dir -t btrfs -o subvol=/
|
||||||
fi
|
fi
|
||||||
cp -rf "$@" $tmp/reinstall-btrfs-root
|
cp -rf "$@" "$mount_dir"
|
||||||
}
|
}
|
||||||
|
|
||||||
is_host_has_ipv4_and_ipv6() {
|
is_host_has_ipv4_and_ipv6() {
|
||||||
@ -1584,8 +1596,8 @@ Continue with DD?
|
|||||||
rocky) ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$basearch.qcow2 ;;
|
rocky) ci_image=$ci_mirror/Rocky-$releasever-GenericCloud-Base.latest.$basearch.qcow2 ;;
|
||||||
fedora)
|
fedora)
|
||||||
# 不加 / 会跳转到 https://dl.fedoraproject.org,纯 ipv6 无法访问
|
# 不加 / 会跳转到 https://dl.fedoraproject.org,纯 ipv6 无法访问
|
||||||
# curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/41/Cloud/x86_64/images
|
# curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/42/Cloud/x86_64/images
|
||||||
# curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/41/Cloud/x86_64/images/
|
# curl -L -6 https://d2lzkl7pfhq30w.cloudfront.net/pub/fedora/linux/releases/42/Cloud/x86_64/images/
|
||||||
filename=$(curl -L $ci_mirror/ | grep -oP "Fedora-Cloud-Base-Generic.*?.qcow2" |
|
filename=$(curl -L $ci_mirror/ | grep -oP "Fedora-Cloud-Base-Generic.*?.qcow2" |
|
||||||
sort -uV | tail -1 | grep .)
|
sort -uV | tail -1 | grep .)
|
||||||
ci_image=$ci_mirror/$filename
|
ci_image=$ci_mirror/$filename
|
||||||
@ -1775,7 +1787,7 @@ verify_os_name() {
|
|||||||
'rocky 8|9' \
|
'rocky 8|9' \
|
||||||
'redhat 8|9' \
|
'redhat 8|9' \
|
||||||
'oracle 8|9' \
|
'oracle 8|9' \
|
||||||
'fedora 40|41' \
|
'fedora 41|42' \
|
||||||
'nixos 24.11' \
|
'nixos 24.11' \
|
||||||
'debian 9|10|11|12' \
|
'debian 9|10|11|12' \
|
||||||
'opensuse 15.6|16.0|tumbleweed' \
|
'opensuse 15.6|16.0|tumbleweed' \
|
||||||
@ -2093,9 +2105,10 @@ check_ram() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# 用于兜底,不太准确
|
# 用于兜底,不太准确
|
||||||
|
# cygwin 要装 procps-ng 才有 free 命令
|
||||||
if [ -z $ram_size ]; then
|
if [ -z $ram_size ]; then
|
||||||
ram_size=$(free -m | grep ^Mem: | awk '{print $2}')
|
ram_size_k=$(grep '^MemTotal:' /proc/meminfo | awk '{print $2}')
|
||||||
ram_size=$((ram_size + 64 + 4))
|
ram_size=$((ram_size_k / 1024 + 64 + 4))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z $ram_size ] || [ $ram_size -le 0 ]; then
|
if [ -z $ram_size ] || [ $ram_size -le 0 ]; then
|
||||||
@ -2978,8 +2991,9 @@ mkdir_clear() {
|
|||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# alpine 没有 -R
|
# 再次运行时,有可能 mount 了 btrfs root,因此先要 umount_all
|
||||||
# { umount $dir || umount -R $dir || true; } 2>/dev/null
|
# 但目前不需要 mount ,因此用不到
|
||||||
|
# umount_all $dir
|
||||||
rm -rf $dir
|
rm -rf $dir
|
||||||
mkdir -p $dir
|
mkdir -p $dir
|
||||||
}
|
}
|
||||||
|
204
trans.sh
204
trans.sh
@ -704,26 +704,27 @@ is_have_rdnss() {
|
|||||||
[ -n "$rdnss" ]
|
[ -n "$rdnss" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# dd 完检测到镜像是 windows 时会改写此方法
|
||||||
is_windows() {
|
is_windows() {
|
||||||
for dir in /os /wim; do
|
[ "$distro" = windows ]
|
||||||
[ -d $dir/Windows/System32 ] && return 0
|
|
||||||
done
|
|
||||||
return 1
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 15063 或之后才支持 rdnss
|
# 15063 或之后才支持 rdnss
|
||||||
is_windows_support_rdnss() {
|
is_windows_support_rdnss() {
|
||||||
|
[ "$build_ver" -ge 15063 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
get_windows_version_from_dll() {
|
||||||
|
local dll=$1
|
||||||
|
[ -f "$dll" ] || error_and_exit "File not found: $dll"
|
||||||
|
|
||||||
apk add pev
|
apk add pev
|
||||||
for dir in /os /wim; do
|
local ver
|
||||||
dll=$dir/Windows/System32/kernel32.dll
|
ver="$(peres -v "$dll" | grep 'Product Version:' | awk '{print $NF}')"
|
||||||
if [ -f $dll ]; then
|
echo "Version: $ver" >&2
|
||||||
build_ver="$(peres -v $dll | grep 'Product Version:' | cut -d. -f3)"
|
IFS=. read -r nt_ver_major nt_ver_minor build_ver rev_ver _ < <(echo "$ver")
|
||||||
echo "Windows Build Version: $build_ver"
|
nt_ver="$nt_ver_major.$nt_ver_minor"
|
||||||
apk del pev
|
apk del pev
|
||||||
[ "$build_ver" -ge 15063 ] && return 0 || return 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
error_and_exit "Not found kernel32.dll"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
is_elts() {
|
is_elts() {
|
||||||
@ -2029,6 +2030,8 @@ EOF
|
|||||||
cat -n net.cfg
|
cat -n net.cfg
|
||||||
# 正常应该是 -D gentoo,但 alpine 的 cloud-init 包缺少 gentoo 配置
|
# 正常应该是 -D gentoo,但 alpine 的 cloud-init 包缺少 gentoo 配置
|
||||||
cloud-init devel net-convert -p net.cfg -k yaml -d out -D alpine -O networkd
|
cloud-init devel net-convert -p net.cfg -k yaml -d out -D alpine -O networkd
|
||||||
|
|
||||||
|
# 注意名字是 10-cloud-init-eth*.network,fix-eth-name.sh 会此文件名查找配置文件
|
||||||
cp out/etc/systemd/network/10-cloud-init-eth*.network $os_dir/etc/systemd/network/
|
cp out/etc/systemd/network/10-cloud-init-eth*.network $os_dir/etc/systemd/network/
|
||||||
|
|
||||||
# 删除网卡名匹配
|
# 删除网卡名匹配
|
||||||
@ -2358,7 +2361,7 @@ create_part() {
|
|||||||
|
|
||||||
# 向下取整 MiB
|
# 向下取整 MiB
|
||||||
# gpt 最后 33 个扇区是备份分区表,不可用
|
# gpt 最后 33 个扇区是备份分区表,不可用
|
||||||
# parted 会忽略最后不足 1MiB 的部分
|
# parted 结束位置填 100% 时也会忽略最后不足 1MiB 的部分,我们模仿它
|
||||||
max_can_use_m=$((total_sector_count_except_backup_gpt * sector_size / 1024 / 1024))
|
max_can_use_m=$((total_sector_count_except_backup_gpt * sector_size / 1024 / 1024))
|
||||||
|
|
||||||
echo "expect_m: $expect_m"
|
echo "expect_m: $expect_m"
|
||||||
@ -2781,9 +2784,15 @@ modify_windows() {
|
|||||||
# https://learn.microsoft.com/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup
|
# https://learn.microsoft.com/windows-hardware/manufacture/desktop/add-a-custom-script-to-windows-setup
|
||||||
|
|
||||||
# 判断用 SetupComplete 还是组策略
|
# 判断用 SetupComplete 还是组策略
|
||||||
state_ini=$os_dir/Windows/Setup/State/State.ini
|
# 默认视为 IMAGE_STATE_COMPLETE,除非有 State.ini,因为 dd 镜像可能精简了 State.ini
|
||||||
cat $state_ini
|
# 但最好还是从注册表获取
|
||||||
if grep -q IMAGE_STATE_COMPLETE $state_ini; then
|
image_state=IMAGE_STATE_COMPLETE
|
||||||
|
if state_ini=$(find_file_ignore_case $os_dir/Windows/Setup/State/State.ini); then
|
||||||
|
cat -n $state_ini
|
||||||
|
image_state=$(grep -i '^ImageState=' $state_ini | cut -d= -f2 | tr -d '\r')
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$image_state" = IMAGE_STATE_COMPLETE ]; then
|
||||||
use_gpo=true
|
use_gpo=true
|
||||||
else
|
else
|
||||||
use_gpo=false
|
use_gpo=false
|
||||||
@ -3556,8 +3565,12 @@ modify_os_on_disk() {
|
|||||||
# find /mnt/c -iname windows -type d -maxdepth 1
|
# find /mnt/c -iname windows -type d -maxdepth 1
|
||||||
# find: /mnt/c/pagefile.sys: Permission denied
|
# find: /mnt/c/pagefile.sys: Permission denied
|
||||||
# find: /mnt/c/swapfile.sys: Permission denied
|
# find: /mnt/c/swapfile.sys: Permission denied
|
||||||
# shellcheck disable=SC2010
|
# shellcheck disable=SC1090
|
||||||
if ls -d /os/*/ | grep -i '/windows/' 2>/dev/null; then
|
# find_file_ignore_case 也在这个文件里面
|
||||||
|
. <(wget -O- $confhome/windows-driver-utils.sh)
|
||||||
|
if ntoskrnl_exe=$(find_file_ignore_case /os/Windows/System32/ntoskrnl.exe 2>/dev/null); then
|
||||||
|
# 其他地方会用到
|
||||||
|
is_windows() { true; }
|
||||||
# 重新挂载为读写、忽略大小写
|
# 重新挂载为读写、忽略大小写
|
||||||
umount /os
|
umount /os
|
||||||
mount -t ntfs3 -o nocase /dev/$part /os
|
mount -t ntfs3 -o nocase /dev/$part /os
|
||||||
@ -3565,6 +3578,8 @@ modify_os_on_disk() {
|
|||||||
if mount | grep ' /os ' | grep -wq ro; then
|
if mount | grep ' /os ' | grep -wq ro; then
|
||||||
error_and_exit "Can't mount windows partition /dev/$part as rw."
|
error_and_exit "Can't mount windows partition /dev/$part as rw."
|
||||||
fi
|
fi
|
||||||
|
# 获取版本号,其他地方会用到
|
||||||
|
get_windows_version_from_dll "$ntoskrnl_exe"
|
||||||
modify_windows /os
|
modify_windows /os
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
@ -4846,6 +4861,7 @@ dd_qcow() {
|
|||||||
# 将前1M从内存 dd 到硬盘
|
# 将前1M从内存 dd 到硬盘
|
||||||
umount /installer/
|
umount /installer/
|
||||||
dd if=/first-1M of=/dev/$xda
|
dd if=/first-1M of=/dev/$xda
|
||||||
|
rm -f /first-1M
|
||||||
|
|
||||||
# gpt 分区表开头记录了备份分区表的位置
|
# gpt 分区表开头记录了备份分区表的位置
|
||||||
# 如果 qcow2 虚拟容量 大于 实际硬盘容量
|
# 如果 qcow2 虚拟容量 大于 实际硬盘容量
|
||||||
@ -5148,7 +5164,7 @@ get_server_name_by_build_ver() {
|
|||||||
echo 2012
|
echo 2012
|
||||||
elif [ "$build_ver" -ge 7600 ]; then
|
elif [ "$build_ver" -ge 7600 ]; then
|
||||||
echo 2008 r2
|
echo 2008 r2
|
||||||
elif [ "$build_ver" -ge 6000 ]; then
|
elif [ "$build_ver" -ge 6001 ]; then
|
||||||
echo 2008
|
echo 2008
|
||||||
else
|
else
|
||||||
error_and_exit "Unknown Build Version: $build_ver"
|
error_and_exit "Unknown Build Version: $build_ver"
|
||||||
@ -5230,11 +5246,15 @@ install_windows() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
info "Process windows iso"
|
info "Process windows iso"
|
||||||
|
mkdir -p /iso /wim
|
||||||
|
|
||||||
|
# find_file_ignore_case 也在这个文件里面
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
. <(wget -O- $confhome/windows-driver-utils.sh)
|
||||||
|
|
||||||
apk add wimlib
|
apk add wimlib
|
||||||
|
|
||||||
download $iso /os/windows.iso
|
download $iso /os/windows.iso
|
||||||
mkdir -p /iso
|
|
||||||
mount -o ro /os/windows.iso /iso
|
mount -o ro /os/windows.iso /iso
|
||||||
|
|
||||||
# 防止用了不兼容架构的 iso
|
# 防止用了不兼容架构的 iso
|
||||||
@ -5272,12 +5292,14 @@ install_windows() {
|
|||||||
if [ "$image_count" = 1 ]; then
|
if [ "$image_count" = 1 ]; then
|
||||||
# 只有一个版本就用那个版本
|
# 只有一个版本就用那个版本
|
||||||
image_name=$all_image_names
|
image_name=$all_image_names
|
||||||
|
image_index=1
|
||||||
else
|
else
|
||||||
while true; do
|
while true; do
|
||||||
# 匹配成功
|
# 匹配成功
|
||||||
# 改成正确的大小写
|
# 改成正确的大小写
|
||||||
if matched_image_name=$(echo "$all_image_names" | grep -ix "$image_name"); then
|
if matched_image_name=$(echo "$all_image_names" | grep -ix "$image_name"); then
|
||||||
image_name=$matched_image_name
|
image_name=$matched_image_name
|
||||||
|
image_index=$(wiminfo "$iso_install_wim" "$image_name" | grep 'Index:' | awk '{print $NF}')
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -5298,7 +5320,7 @@ install_windows() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
get_selected_image_prop() {
|
get_selected_image_prop() {
|
||||||
get_image_prop "$iso_install_wim" "$image_name" "$1"
|
get_image_prop "$iso_install_wim" "$image_index" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
# 多会话的信息来自注册表,因为没有官方 iso
|
# 多会话的信息来自注册表,因为没有官方 iso
|
||||||
@ -5344,12 +5366,45 @@ install_windows() {
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# 挂载 install.wim,检查
|
||||||
|
# 1. 是否自带 sac 组件
|
||||||
|
# 2. 是否自带 nvme 驱动
|
||||||
|
# 3. 是否支持 sha256
|
||||||
|
|
||||||
|
wimmount "$iso_install_wim" "$image_index" /wim/
|
||||||
|
{
|
||||||
|
find_file_ignore_case /wim/Windows/System32/sacsess.exe && has_sac=true || has_sac=false
|
||||||
|
find_file_ignore_case /wim/Windows/INF/stornvme.inf && has_stornvme=true || has_stornvme=false
|
||||||
|
} >/dev/null 2>&1
|
||||||
|
|
||||||
|
support_sha256=false
|
||||||
|
if is_nt_ver_ge 6.2; then
|
||||||
|
support_sha256=true
|
||||||
|
else
|
||||||
|
# https://www.hummingheads.co.jp/press/info-certificates.html
|
||||||
|
# https://support.microsoft.com/kb/KB3033929
|
||||||
|
# https://support.microsoft.com/kb/KB4474419
|
||||||
|
# Windows Vista SP2 ldr_escrow 6.0.6003 + KB4474419
|
||||||
|
# Windows 7 SP1 6.1.7601 + KB3033929
|
||||||
|
ntoskrnl_exe=$(find_file_ignore_case /wim/Windows/System32/ntoskrnl.exe)
|
||||||
|
get_windows_version_from_dll "$ntoskrnl_exe"
|
||||||
|
if { [ "$nt_ver" = 6.0 ] && [ "$build_ver" -ge 6003 ] && [ "$rev_ver" -ge 20555 ]; } ||
|
||||||
|
{ [ "$nt_ver" = 6.1 ] && [ "$build_ver" -ge 7601 ] && [ "$rev_ver" -ge 18741 ]; }; then
|
||||||
|
support_sha256=true
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
wimunmount /wim/
|
||||||
|
|
||||||
info "Selected image info"
|
info "Selected image info"
|
||||||
echo "Image Name: $image_name"
|
echo "Image Name: $image_name"
|
||||||
echo "Product Version: $product_ver"
|
echo "Product Version: $product_ver"
|
||||||
echo "Windows Type: $windows_type"
|
echo "Windows Type: $windows_type"
|
||||||
echo "NT Version: $nt_ver"
|
echo "NT Version: $nt_ver"
|
||||||
echo "Build Version: $build_ver"
|
echo "Build Version: $build_ver"
|
||||||
|
echo "-------------------------"
|
||||||
|
echo "Has SAC: $has_sac"
|
||||||
|
echo "Has StorNVMe: $has_stornvme"
|
||||||
|
echo "Support SHA256: $support_sha256"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
# 复制 boot.wim 到 /os,用于临时编辑
|
# 复制 boot.wim 到 /os,用于临时编辑
|
||||||
@ -5401,7 +5456,7 @@ install_windows() {
|
|||||||
# (意义不大,因为已经删除了 boot.wim 用来创建虚拟内存,vista 除外)
|
# (意义不大,因为已经删除了 boot.wim 用来创建虚拟内存,vista 除外)
|
||||||
# 缺点: 如果 install.wim 只有一个镜像,则只能缩小 10M+
|
# 缺点: 如果 install.wim 只有一个镜像,则只能缩小 10M+
|
||||||
if false; then
|
if false; then
|
||||||
time wimexport --threads "$(get_build_threads 512)" "$iso_install_wim" "$image_name" "$install_wim"
|
time wimexport --threads "$(get_build_threads 512)" "$iso_install_wim" "$image_index" "$install_wim"
|
||||||
info "install.wim size"
|
info "install.wim size"
|
||||||
echo "Original: $(get_filesize_mb "$iso_install_wim")"
|
echo "Original: $(get_filesize_mb "$iso_install_wim")"
|
||||||
echo "Optimized: $(get_filesize_mb "$install_wim")"
|
echo "Optimized: $(get_filesize_mb "$install_wim")"
|
||||||
@ -5415,7 +5470,7 @@ install_windows() {
|
|||||||
# https://github.com/pbatard/rufus/issues/1990
|
# https://github.com/pbatard/rufus/issues/1990
|
||||||
# https://learn.microsoft.com/windows/iot/iot-enterprise/Hardware/System_Requirements
|
# https://learn.microsoft.com/windows/iot/iot-enterprise/Hardware/System_Requirements
|
||||||
if [ "$product_ver" = "11" ] && [ "$(nproc)" -le 1 ]; then
|
if [ "$product_ver" = "11" ] && [ "$(nproc)" -le 1 ]; then
|
||||||
wiminfo "$install_wim" "$image_name" --image-property WINDOWS/INSTALLATIONTYPE=Server
|
wiminfo "$install_wim" "$image_index" --image-property WINDOWS/INSTALLATIONTYPE=Server
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 变量名 使用场景
|
# 变量名 使用场景
|
||||||
@ -5450,10 +5505,6 @@ install_windows() {
|
|||||||
drv=/os/drivers
|
drv=/os/drivers
|
||||||
mkdir -p "$drv" # 驱动下载临时文件夹
|
mkdir -p "$drv" # 驱动下载临时文件夹
|
||||||
|
|
||||||
# 下载脚本
|
|
||||||
# shellcheck disable=SC1090
|
|
||||||
. <(wget -O- $confhome/windows-driver-utils.sh)
|
|
||||||
|
|
||||||
# 这里有坑
|
# 这里有坑
|
||||||
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
|
# $(get_cloud_vendor) 调用了 cache_dmi_and_virt
|
||||||
# 但是 $(get_cloud_vendor) 运行在 subshell 里面
|
# 但是 $(get_cloud_vendor) 运行在 subshell 里面
|
||||||
@ -5473,18 +5524,19 @@ install_windows() {
|
|||||||
add_driver_huawei_virtio
|
add_driver_huawei_virtio
|
||||||
|
|
||||||
# gcp 官方驱动不全,需要用公版补全
|
# gcp 官方驱动不全,需要用公版补全
|
||||||
elif [ "$vendor" = gcp ] && [ "$nt_ver" = 6.1 ] && [ "$arch_wim" = x86_64 ]; then
|
# 官方 windows server 模板没有 viorng 设备,但 linux 模板有
|
||||||
add_driver_gcp_virtio_win6_1_sha1_x64
|
elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86 ] && $support_sha256; then
|
||||||
add_driver_generic_virtio \( -iname viorng.inf -or -iname balloon.inf \)
|
|
||||||
|
|
||||||
elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86 ]; then
|
|
||||||
add_driver_gcp_virtio
|
add_driver_gcp_virtio
|
||||||
add_driver_generic_virtio \( -iname viorng.inf -or -iname pvpanic.inf \)
|
add_driver_generic_virtio \( -iname viorng.inf -or -iname pvpanic.inf \)
|
||||||
|
|
||||||
elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.2 && [ "$arch_wim" = x86_64 ]; then
|
elif [ "$vendor" = gcp ] && is_nt_ver_ge 6.1 && [ "$arch_wim" = x86_64 ] && $support_sha256; then
|
||||||
add_driver_gcp_virtio
|
add_driver_gcp_virtio
|
||||||
add_driver_generic_virtio -iname viorng.inf
|
add_driver_generic_virtio -iname viorng.inf
|
||||||
|
|
||||||
|
elif [ "$vendor" = gcp ] && [ "$nt_ver" = 6.1 ] && [ "$arch_wim" = x86_64 ] && ! $support_sha256; then
|
||||||
|
add_driver_gcp_virtio_win6_1_sha1_x64
|
||||||
|
add_driver_generic_virtio \( -iname viorng.inf -or -iname balloon.inf \)
|
||||||
|
|
||||||
else
|
else
|
||||||
# 兜底
|
# 兜底
|
||||||
add_driver_generic_virtio
|
add_driver_generic_virtio
|
||||||
@ -5554,8 +5606,9 @@ install_windows() {
|
|||||||
|
|
||||||
file=$(
|
file=$(
|
||||||
case "$product_ver" in
|
case "$product_ver" in
|
||||||
'7' | '2008 r2') echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名
|
'7' | '2008 r2') $support_sha256 &&
|
||||||
# '7' | '2008 r2') echo 18713/eng/prowin${arch_intel}legacy.exe ;; # 25.0 有部分文件是 sha256 签名
|
echo echo 18713/eng/prowin${arch_intel}legacy.exe || # 25.0 有部分文件是 sha256 签名
|
||||||
|
echo 29323/eng/prowin${arch_intel}legacy.exe ;; # 24.3 sha1 签名
|
||||||
'8') echo 21642/eng/prowin${arch_intel}.exe ;;
|
'8') echo 21642/eng/prowin${arch_intel}.exe ;;
|
||||||
'8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;;
|
'8.1') echo 764813/Wired_driver_27.8_${arch_intel}.zip ;;
|
||||||
'2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;;
|
'2012' | '2012 r2') echo 785805/Wired_driver_28.2_${arch_intel}.zip ;;
|
||||||
@ -5663,8 +5716,7 @@ EOF
|
|||||||
|
|
||||||
ena_ver=$(
|
ena_ver=$(
|
||||||
case "$nt_ver" in
|
case "$nt_ver" in
|
||||||
6.1) echo 2.1.4 ;; # sha1 签名
|
6.1) $support_sha256 && echo 2.2.3 || echo 2.1.4 ;;
|
||||||
# 6.1) echo 2.2.3 ;; # sha256 签名
|
|
||||||
6.2 | 6.3) echo 2.6.0 ;;
|
6.2 | 6.3) echo 2.6.0 ;;
|
||||||
*) echo Latest ;;
|
*) echo Latest ;;
|
||||||
esac
|
esac
|
||||||
@ -5708,8 +5760,7 @@ EOF
|
|||||||
|
|
||||||
aws_pv_ver=$(
|
aws_pv_ver=$(
|
||||||
case "$nt_ver" in
|
case "$nt_ver" in
|
||||||
6.1) echo 8.3.2 ;; # sha1 签名
|
6.1) $support_sha256 && echo 8.3.5 || echo echo 8.3.2 ;;
|
||||||
# 6.1) echo 8.3.5 ;; # sha256 签名
|
|
||||||
6.2 | 6.3) echo 8.4.3 ;;
|
6.2 | 6.3) echo 8.4.3 ;;
|
||||||
*) echo Latest ;;
|
*) echo Latest ;;
|
||||||
esac
|
esac
|
||||||
@ -5790,14 +5841,15 @@ EOF
|
|||||||
# 173-9 不是稳定版?
|
# 173-9 不是稳定版?
|
||||||
# 185 ~ 187 win7 vioscsi 是 sha256 签名
|
# 185 ~ 187 win7 vioscsi 是 sha256 签名
|
||||||
# 189 ~ 215 win7 vultr 气球驱动死机
|
# 189 ~ 215 win7 vultr 气球驱动死机
|
||||||
# 217 ~ 266 win7 甲骨文 vioscsi 用不了,即使是红帽的 virtio-win-1.9.44 也用不了
|
# 217 ~ 271 win7 甲骨文 vioscsi 用不了,即使是红帽的 virtio-win-1.9.45 也用不了
|
||||||
# 217 ~ 266 2k12 证书有问题
|
# 217 ~ 271 2k12 证书有问题
|
||||||
|
|
||||||
# 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动
|
# 2008 安装的气球驱动不能用,需要到硬件管理器重新安装设备才能用,无需更新驱动
|
||||||
|
|
||||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40
|
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40
|
||||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61
|
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61
|
||||||
case "$nt_ver" in
|
case "$nt_ver" in
|
||||||
|
# 最新版里面的 win2008 win7 是 sha1 签名的,但是甲骨文 vioscsi 用不了
|
||||||
6.0 | 6.1) dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista|w7|2k8|2k8R2
|
6.0 | 6.1) dir=archive-virtio/virtio-win-0.1.173-9 ;; # vista|w7|2k8|2k8R2
|
||||||
6.2 | 6.3) dir=archive-virtio/virtio-win-0.1.215-2 ;; # w8|w8.1|2k12|2k12R2
|
6.2 | 6.3) dir=archive-virtio/virtio-win-0.1.215-2 ;; # w8|w8.1|2k12|2k12R2
|
||||||
*) dir=stable-virtio ;;
|
*) dir=stable-virtio ;;
|
||||||
@ -5941,38 +5993,21 @@ EOF
|
|||||||
add_driver_aliyun_virtio() {
|
add_driver_aliyun_virtio() {
|
||||||
info "Add drivers: Aliyun virtio"
|
info "Add drivers: Aliyun virtio"
|
||||||
|
|
||||||
# win7 旧驱动是 sha1 签名
|
# win7 sha1 旧驱动
|
||||||
if [ "$nt_ver" = 6.1 ]; then
|
if [ "$nt_ver" = 6.1 ] && ! $support_sha256; then
|
||||||
# 旧驱动
|
filename=210408.1454.1459_bin.zip # sha1
|
||||||
aliyun_sys=$(
|
# filename=220915.0953.0953_bin.zip # sha256
|
||||||
case "$nt_ver" in
|
# filename=new_virtio.zip # sha256
|
||||||
6.1) echo 7 ;;
|
|
||||||
6.2 | 6.3) echo 8 ;;
|
|
||||||
*) echo 10 ;;
|
|
||||||
esac
|
|
||||||
)
|
|
||||||
|
|
||||||
filename=$(
|
if is_in_china; then
|
||||||
case "$nt_ver" in
|
region=cn-beijing
|
||||||
6.1) echo 210408.1454.1459_bin.zip ;; # sha1
|
else
|
||||||
*) echo 220915.0953.0953_bin.zip ;; # sha256
|
region=us-west-1
|
||||||
# *) echo new_virtio.zip ;;
|
fi
|
||||||
esac
|
|
||||||
)
|
|
||||||
|
|
||||||
region=$(
|
|
||||||
if is_in_china; then
|
|
||||||
echo cn-beijing
|
|
||||||
else
|
|
||||||
echo us-west-1
|
|
||||||
fi
|
|
||||||
)
|
|
||||||
|
|
||||||
download https://windows-driver-$region.oss-$region.aliyuncs.com/virtio/$filename $drv/aliyun.zip
|
download https://windows-driver-$region.oss-$region.aliyuncs.com/virtio/$filename $drv/aliyun.zip
|
||||||
unzip -o -d $drv/aliyun/ $drv/aliyun.zip
|
unzip -o -d $drv/aliyun/ $drv/aliyun.zip
|
||||||
|
cp_drivers $drv/aliyun -ipath "*/win7/${arch}/*"
|
||||||
# 注意文件夹是 win7 Win8 win10 大小写不一致
|
|
||||||
cp_drivers $drv/aliyun -ipath "*/win${aliyun_sys}/${arch}/*"
|
|
||||||
else
|
else
|
||||||
# 新驱动
|
# 新驱动
|
||||||
aliyun_sys=$(
|
aliyun_sys=$(
|
||||||
@ -5996,7 +6031,7 @@ EOF
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# gcp virtio win7 x64
|
# gcp virtio win7 x64 sha1
|
||||||
# 缺 balloon viorng
|
# 缺 balloon viorng
|
||||||
add_driver_gcp_virtio_win6_1_sha1_x64() {
|
add_driver_gcp_virtio_win6_1_sha1_x64() {
|
||||||
info "Add drivers: GCP virtio win6.1 sha1 x64"
|
info "Add drivers: GCP virtio win6.1 sha1 x64"
|
||||||
@ -6005,15 +6040,15 @@ EOF
|
|||||||
for file in \
|
for file in \
|
||||||
WdfCoInstaller01009.dll WdfCoInstaller01011.dll \
|
WdfCoInstaller01009.dll WdfCoInstaller01011.dll \
|
||||||
netkvm.inf netkvm.cat netkvm.sys netkvmco.dll \
|
netkvm.inf netkvm.cat netkvm.sys netkvmco.dll \
|
||||||
nvme.inf nvme64.cat nvme.sys \
|
|
||||||
pvpanic.inf pvpanic.sys pvpanic.cat \
|
pvpanic.inf pvpanic.sys pvpanic.cat \
|
||||||
vioscsi.inf vioscsi.sys vioscsi.cat; do
|
vioscsi.inf vioscsi.sys vioscsi.cat \
|
||||||
|
$([ -d /sys/module/nvme ] && ! $has_stornvme && echo nvme.inf nvme64.cat nvme.sys); do
|
||||||
download https://storage.googleapis.com/gce-windows-drivers-public/win6.1sha1/$file $drv/gce/win6.1sha1/$file
|
download https://storage.googleapis.com/gce-windows-drivers-public/win6.1sha1/$file $drv/gce/win6.1sha1/$file
|
||||||
done
|
done
|
||||||
cp_drivers $drv/gce/win6.1sha1
|
cp_drivers $drv/gce/win6.1sha1
|
||||||
}
|
}
|
||||||
|
|
||||||
# gcp virtio win8+
|
# gcp virtio win7+ sha256
|
||||||
# x86 缺 viorng pvpanic
|
# x86 缺 viorng pvpanic
|
||||||
# x64 缺 viorng
|
# x64 缺 viorng
|
||||||
# https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/daisy_workflows/image_build/windows
|
# https://github.com/GoogleCloudPlatform/compute-image-tools/tree/master/daisy_workflows/image_build/windows
|
||||||
@ -6063,7 +6098,9 @@ EOF
|
|||||||
link=$(grep -o "/pool/.*-google-compute-engine-driver-$part.*\.goo" $drv/gce/gce.json)
|
link=$(grep -o "/pool/.*-google-compute-engine-driver-$part.*\.goo" $drv/gce/gce.json)
|
||||||
wget $gce_repo$link -O- | tar xz -C $drv/gce/$part
|
wget $gce_repo$link -O- | tar xz -C $drv/gce/$part
|
||||||
|
|
||||||
# inf 不限版本,6.0 能装 6.1 的驱动但用不了
|
# inf 不限版本
|
||||||
|
# 但 win7 gvnic ndis 版本是 6.2,vista/2008 能装但用不了
|
||||||
|
# https://github.com/GoogleCloudPlatform/compute-virtual-ethernet-windows/blob/cad1edf7a05465f4972a81f2c015952fd228b5e3/src/gvnic.vcxproj#L298
|
||||||
if false; then
|
if false; then
|
||||||
for suffix in '' '-32'; do
|
for suffix in '' '-32'; do
|
||||||
if [ -d "$drv/gce/$part/win6.1$suffix" ]; then
|
if [ -d "$drv/gce/$part/win6.1$suffix" ]; then
|
||||||
@ -6126,6 +6163,8 @@ EOF
|
|||||||
locale=$(get_selected_image_prop 'Default Language')
|
locale=$(get_selected_image_prop 'Default Language')
|
||||||
use_default_rdp_port=$(is_need_change_rdp_port && echo false || echo true)
|
use_default_rdp_port=$(is_need_change_rdp_port && echo false || echo true)
|
||||||
password_base64=$(get_password_windows_administrator_base64)
|
password_base64=$(get_password_windows_administrator_base64)
|
||||||
|
# 7601.24214.180801-1700.win7sp1_ldr_escrow_CLIENT_ULTIMATE_x64FRE_en-us.iso Image Name 为空
|
||||||
|
# 将 xml Image Name 的值设为空可以正常安装
|
||||||
sed -i \
|
sed -i \
|
||||||
-e "s|%arch%|$arch|" \
|
-e "s|%arch%|$arch|" \
|
||||||
-e "s|%image_name%|$image_name|" \
|
-e "s|%image_name%|$image_name|" \
|
||||||
@ -6152,7 +6191,7 @@ EOF
|
|||||||
# 评估版 iso ei.cfg 有 EVAL 字样,填空白 key 报错 Windows Cannot find Microsoft software license terms
|
# 评估版 iso ei.cfg 有 EVAL 字样,填空白 key 报错 Windows Cannot find Microsoft software license terms
|
||||||
|
|
||||||
# key
|
# key
|
||||||
if [[ "$image_name" = 'Windows Vista*' ]]; then
|
if [ "$product_ver" = vista ]; then
|
||||||
# vista 需密钥,密钥可与 edition 不一致
|
# vista 需密钥,密钥可与 edition 不一致
|
||||||
# TODO: 改成从网页获取?
|
# TODO: 改成从网页获取?
|
||||||
# https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys
|
# https://learn.microsoft.com/en-us/windows-server/get-started/kms-client-activation-keys
|
||||||
@ -6169,13 +6208,6 @@ EOF
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p /wim
|
|
||||||
|
|
||||||
# 挂载 install.wim,检查是否有 sac 组件
|
|
||||||
wimmount "$install_wim" "$image_name" /wim/
|
|
||||||
[ -f /wim/Windows/System32/sacsess.exe ] && has_sac=true || has_sac=false
|
|
||||||
wimunmount /wim/
|
|
||||||
|
|
||||||
# 挂载 boot.wim
|
# 挂载 boot.wim
|
||||||
info "mount boot.wim"
|
info "mount boot.wim"
|
||||||
wimmountrw /os/boot.wim "$boot_index" /wim/
|
wimmountrw /os/boot.wim "$boot_index" /wim/
|
||||||
@ -6306,7 +6338,7 @@ EOF
|
|||||||
# 所以复制 resize.bat 到 install.wim
|
# 所以复制 resize.bat 到 install.wim
|
||||||
if true; then
|
if true; then
|
||||||
info "mount install.wim"
|
info "mount install.wim"
|
||||||
wimmountrw $install_wim "$image_name" /wim/
|
wimmountrw $install_wim "$image_index" /wim/
|
||||||
if false; then
|
if false; then
|
||||||
# 使用 autounattend.xml
|
# 使用 autounattend.xml
|
||||||
# win7 在此阶段找不到网卡
|
# win7 在此阶段找不到网卡
|
||||||
@ -6696,6 +6728,8 @@ elif [ "$1" = "alpine" ]; then
|
|||||||
distro=alpine
|
distro=alpine
|
||||||
# 后面的步骤很多都会用到这个,例如分区布局
|
# 后面的步骤很多都会用到这个,例如分区布局
|
||||||
cloud_image=0
|
cloud_image=0
|
||||||
|
elif [ -n "$1" ]; then
|
||||||
|
error_and_exit "unknown option $1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 无参数运行部分
|
# 无参数运行部分
|
||||||
|
Loading…
x
Reference in New Issue
Block a user