mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
core: 不重要的优化
This commit is contained in:
parent
3c6550c86a
commit
d3518a7502
207
README.en.md
Normal file
207
README.en.md
Normal file
@ -0,0 +1,207 @@
|
||||
# reinstall
|
||||
|
||||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc679a17751448628fe6d8ac35e26eed)](https://app.codacy.com/gh/bin456789/reinstall/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||
[![CodeFactor](https://www.codefactor.io/repository/github/bin456789/reinstall/badge)](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code)](#reinstall)
|
||||
|
||||
One-click Reinstallation Script
|
||||
|
||||
[中文](README.md) | [English](README.en.md)
|
||||
|
||||
## Highlights
|
||||
|
||||
- Default usage of official installation programs. In cases where the memory requirements of the installation program are not met, the official cloud image will be used.
|
||||
- Excludes third-party links and self-made packages; all resources are fetched in real-time from the source site.
|
||||
- Adapted for 512M + 5G small VPS, and supports installing Alpine on 256M VPS.
|
||||
- Supports installing Windows using the official ISO (does not support ARM).
|
||||
- Supports reinstalling Windows as Linux and vice versa.
|
||||
- Supports BIOS, EFI, ARM (Windows installation not supported on ARM).
|
||||
- Supports original system partition with LVM, Btrfs.
|
||||
- Supports installing Alpine, Arch, openSUSE, Gentoo, and installing from these systems.
|
||||
- Progress of DD and cloud image installation can be viewed through SSH, a browser, serial console, or background VNC.
|
||||
- Contains extensive comments.
|
||||
|
||||
## Usage on Linux
|
||||
|
||||
### Download
|
||||
|
||||
```bash
|
||||
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
|
||||
```
|
||||
|
||||
### Download (from within China)
|
||||
|
||||
```bash
|
||||
curl -O https://raw.fgit.cf/bin456789/reinstall/main/reinstall.sh
|
||||
```
|
||||
|
||||
### Usage 1: Install Linux
|
||||
|
||||
Note: For machines with static IP, installing centos, alma, rocky, fedora, debian, ubuntu, requires adding the --ci parameter to force the use of the cloud mirror.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh centos 7|8|9 (8|9 for stream versions)
|
||||
alma 8|9
|
||||
rocky 8|9
|
||||
fedora 38|39
|
||||
debian 10|11|12
|
||||
ubuntu 20.04|22.04
|
||||
alpine 3.16|3.17|3.18|3.19
|
||||
opensuse 15.4|15.5|tumbleweed (supports cloud mirror only)
|
||||
arch (supports only amd64 cloud mirror)
|
||||
gentoo (supports only amd64 cloud mirror)
|
||||
|
||||
If no version number is entered, it installs the latest version.
|
||||
|
||||
Optional parameters: --ci Force the use of the cloud mirror.
|
||||
```
|
||||
|
||||
### Usage 2: DD
|
||||
|
||||
Supports gzip, xz formats.
|
||||
|
||||
Supports automatic configuration of static IP, system disk expansion.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh dd --img=https://example.com/xxx.xz
|
||||
```
|
||||
|
||||
### Usage 3: Restart to Alpine Rescue System (Live OS)
|
||||
|
||||
Can be connected via SSH to perform manual DD, modify partitions, manually install Arch Linux, and other operations.
|
||||
|
||||
```bash
|
||||
bash reinstall.sh alpine --hold=1
|
||||
```
|
||||
|
||||
### Usage 4: Restart to netboot.xyz
|
||||
|
||||
```bash
|
||||
bash reinstall.sh netboot.xyz
|
||||
```
|
||||
|
||||
### Usage 5: Install Windows ISO
|
||||
|
||||
```bash
|
||||
bash reinstall.sh windows \
|
||||
--iso='https://example.com/en-us_windows_10_enterprise_ltsc_2021_x64_dvd_d289cf96.iso' \
|
||||
--image-name='Windows 10 Enterprise LTSC 2021'
|
||||
```
|
||||
|
||||
#### Parameter Description
|
||||
|
||||
`--iso` Original image link without integrating VirtIO, Xen, AWS, GCP drivers.
|
||||
|
||||
`--image-name` Specifies the image to install, case insensitive, enclosed in quotes, for example:
|
||||
|
||||
```text
|
||||
'Windows 7 Ultimate'
|
||||
'Windows 10 Enterprise LTSC 2021'
|
||||
'Windows 11 Pro'
|
||||
'Windows Server 2022 SERVERDATACENTER'
|
||||
```
|
||||
|
||||
Use `Dism++` File menu > Open image file, select the iso to get the image name.
|
||||
|
||||
![image-name](https://github.com/bin456789/reinstall/assets/7548515/5aae0a9b-61e2-4f66-bb98-d470a6beaac2)
|
||||
|
||||
#### Other Notes
|
||||
|
||||
1. Successfully tested systems: 7, 10, 11, 2022. Tested platforms: vultr (bios), oracle (efi), aws t2 (xen), aws t3 (nitro).
|
||||
2. Supports 32/64-bit systems; UEFI machines only support 64-bit.
|
||||
3. Can bypass Windows 11 hardware restrictions.
|
||||
4. Tested not to support ARM.
|
||||
5. `zh-cn_windows_10_enterprise_ltsc_2021_x64_dvd_033b7312.iso`: After installing this image, the `wsappx` process may occupy CPU for an extended period.
|
||||
|
||||
This is an issue with the image, and the solution is to install the `VCLibs` library.
|
||||
|
||||
<https://www.google.com/search?q=ltsc+wsappx>
|
||||
|
||||
6. The following websites contain iso links:
|
||||
|
||||
<https://archive.org>
|
||||
|
||||
<https://massgrave.dev/genuine-installation-media.html>
|
||||
|
||||
## Usage on Windows
|
||||
|
||||
Run `cmd` with administrator privileges.
|
||||
|
||||
If running `powershell`, switch to `cmd` first.
|
||||
|
||||
### Download
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat
|
||||
```
|
||||
|
||||
### Download (from within China)
|
||||
|
||||
```batch
|
||||
certutil -urlcache -f -split https://raw.fgit.cf/bin456789/reinstall/main/reinstall.bat
|
||||
```
|
||||
|
||||
### If unable to download
|
||||
|
||||
- Disable Windows Defender real-time protection.
|
||||
|
||||
- Update SSL root certificate.
|
||||
|
||||
```batch
|
||||
certutil -generateSSTFromWU root.sst
|
||||
certutil -addstore Root root.sst
|
||||
```
|
||||
|
||||
- Save the following two files via 'Save link as' or use 'Remote Desktop' to copy:
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.bat>
|
||||
|
||||
<https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh>
|
||||
|
||||
### Usage
|
||||
|
||||
All functionalities available in Linux can be used on Windows, using parameters similar to those in Linux.
|
||||
|
||||
For example, to install centos 7:
|
||||
|
||||
```batch
|
||||
reinstall.bat centos-7
|
||||
```
|
||||
|
||||
## Memory Requirements
|
||||
|
||||
| System | Traditional Install | Cloud Image |
|
||||
| -------------------------------- | ------------------- | ------------|
|
||||
| Debian | 384M | 512M |
|
||||
| Ubuntu | 1G | 512M |
|
||||
| CentOS / Alma / Rocky / Fedora | 1G | 512M |
|
||||
| Alpine | 256M | - |
|
||||
| openSUSE | - | 512M |
|
||||
| Arch | - | 512M |
|
||||
| Gentoo | - | 512M |
|
||||
| Windows | 1G | - |
|
||||
|
||||
## Network Requirements
|
||||
|
||||
For 'Installation Mode' installing Linux, DHCPv4 is required.
|
||||
|
||||
Other cases support static IP, IPv6 (including installing Alpine, cloud mirror, Windows iso, dd).
|
||||
|
||||
No need to fill in the static IP address when running the script.
|
||||
|
||||
## Virtualization Requirements
|
||||
|
||||
Does not support OpenVZ, LXC virtual machines.
|
||||
|
||||
Please use <https://github.com/LloydAsp/OsMutation>.
|
||||
|
||||
## Default Passwords
|
||||
|
||||
| System | Username | Password |
|
||||
| -------------------- | -------------- | -------- |
|
||||
| Linux | root | 123@@@ |
|
||||
| Windows (ISO install) | administrator | 123@@@ |
|
||||
|
||||
## TODO
|
||||
|
||||
- Installation modes: Static IP, IPv6, multiple NICs.
|
@ -2,8 +2,11 @@
|
||||
|
||||
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/dc679a17751448628fe6d8ac35e26eed)](https://app.codacy.com/gh/bin456789/reinstall/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)
|
||||
[![CodeFactor](https://www.codefactor.io/repository/github/bin456789/reinstall/badge)](https://www.codefactor.io/repository/github/bin456789/reinstall)
|
||||
[![Lines of Code](https://tokei.rs/b1/github/bin456789/reinstall?category=code)](#reinstall)
|
||||
|
||||
又一个重装脚本
|
||||
一键重装脚本
|
||||
|
||||
[中文](README.md) | [English](README.en.md)
|
||||
|
||||
## 亮点
|
||||
|
||||
@ -40,7 +43,7 @@ curl -O https://raw.fgit.cf/bin456789/reinstall/main/reinstall.sh
|
||||
bash reinstall.sh centos 7|8|9 (8|9 为 stream 版本)
|
||||
alma 8|9
|
||||
rocky 8|9
|
||||
fedora 37|38
|
||||
fedora 38|39
|
||||
debian 10|11|12
|
||||
ubuntu 20.04|22.04
|
||||
alpine 3.16|3.17|3.18|3.19
|
||||
|
21
reinstall.sh
21
reinstall.sh
@ -21,7 +21,7 @@ usage_and_exit() {
|
||||
Usage: reinstall.sh centos 7|8|9
|
||||
alma 8|9
|
||||
rocky 8|9
|
||||
fedora 37|38
|
||||
fedora 38|39
|
||||
debian 10|11|12
|
||||
ubuntu 20.04|22.04
|
||||
alpine 3.16|3.17|3.18|3.19
|
||||
@ -31,6 +31,8 @@ Usage: reinstall.sh centos 7|8|9
|
||||
dd --img=http://xxx
|
||||
windows --iso=http://xxx --image-name='windows xxx'
|
||||
netboot.xyz
|
||||
|
||||
Homepage: https://github.com/bin456789/reinstall
|
||||
EOF
|
||||
exit 1
|
||||
}
|
||||
@ -311,15 +313,12 @@ setos() {
|
||||
}
|
||||
|
||||
setos_alpine() {
|
||||
flavour=lts
|
||||
if is_virt; then
|
||||
# alpine aarch64 3.18 才有 virt 直连链接
|
||||
if [ "$basearch" = aarch64 ]; then
|
||||
install_pkg bc
|
||||
(($(echo "$releasever >= 3.18" | bc))) && flavour=virt
|
||||
else
|
||||
flavour=virt
|
||||
fi
|
||||
is_virt && flavour=virt || flavour=lts
|
||||
|
||||
# alpine aarch64 3.16/3.17 lts 才有直连链接
|
||||
if [ "$basearch" = aarch64 ] &&
|
||||
{ [ "$releasever" = 3.16 ] || [ "$releasever" = 3.17 ]; }; then
|
||||
flavour=lts
|
||||
fi
|
||||
|
||||
# 不要用https 因为甲骨文云arm initramfs阶段不会从硬件同步时钟,导致访问https出错
|
||||
@ -616,7 +615,7 @@ verify_os_name() {
|
||||
'centos 7|8|9' \
|
||||
'alma 8|9' \
|
||||
'rocky 8|9' \
|
||||
'fedora 37|38' \
|
||||
'fedora 38|39' \
|
||||
'debian 10|11|12' \
|
||||
'ubuntu 20.04|22.04' \
|
||||
'alpine 3.16|3.17|3.18|3.19' \
|
||||
|
40
trans.sh
40
trans.sh
@ -1887,9 +1887,9 @@ install_windows() {
|
||||
|
||||
case "$sys" in
|
||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/40
|
||||
w7) dir=archive-virtio/virtio-win-0.1.173-9 ;;
|
||||
w7 | 2k8*) dir=archive-virtio/virtio-win-0.1.173-9 ;;
|
||||
# https://github.com/virtio-win/virtio-win-pkg-scripts/issues/61
|
||||
2k12*) dir=archive-virtio/virtio-win-0.1.215-1 ;;
|
||||
w8* | 2k12*) dir=archive-virtio/virtio-win-0.1.215-1 ;;
|
||||
*) dir=stable-virtio ;;
|
||||
esac
|
||||
|
||||
@ -1929,9 +1929,9 @@ install_windows() {
|
||||
fi
|
||||
|
||||
# 修改应答文件
|
||||
download $confhome/windows.xml /tmp/Autounattend.xml
|
||||
download $confhome/windows.xml /tmp/autounattend.xml
|
||||
locale=$(wiminfo $install_wim | grep 'Default Language' | head -1 | awk '{print $NF}')
|
||||
sed -i "s|%arch%|$arch|; s|%image_name%|$image_name|; s|%locale%|$locale|" /tmp/Autounattend.xml
|
||||
sed -i "s|%arch%|$arch|; s|%image_name%|$image_name|; s|%locale%|$locale|" /tmp/autounattend.xml
|
||||
|
||||
# 修改 disk_id
|
||||
if false; then
|
||||
@ -1943,13 +1943,13 @@ install_windows() {
|
||||
else
|
||||
disk_id=0
|
||||
fi
|
||||
sed -i "s|%disk_id%|$disk_id|" /tmp/Autounattend.xml
|
||||
sed -i "s|%disk_id%|$disk_id|" /tmp/autounattend.xml
|
||||
fi
|
||||
|
||||
# 修改应答文件,分区配置
|
||||
if is_efi; then
|
||||
sed -i "s|%installto_partitionid%|3|" /tmp/Autounattend.xml
|
||||
insert_into_file /tmp/Autounattend.xml after '<ModifyPartitions>' <<EOF
|
||||
sed -i "s|%installto_partitionid%|3|" /tmp/autounattend.xml
|
||||
insert_into_file /tmp/autounattend.xml after '<ModifyPartitions>' <<EOF
|
||||
<ModifyPartition wcm:action="add">
|
||||
<Order>1</Order>
|
||||
<PartitionID>1</PartitionID>
|
||||
@ -1966,8 +1966,8 @@ install_windows() {
|
||||
</ModifyPartition>
|
||||
EOF
|
||||
else
|
||||
sed -i "s|%installto_partitionid%|1|" /tmp/Autounattend.xml
|
||||
insert_into_file /tmp/Autounattend.xml after '<ModifyPartitions>' <<EOF
|
||||
sed -i "s|%installto_partitionid%|1|" /tmp/autounattend.xml
|
||||
insert_into_file /tmp/autounattend.xml after '<ModifyPartitions>' <<EOF
|
||||
<ModifyPartition wcm:action="add">
|
||||
<Order>1</Order>
|
||||
<PartitionID>1</PartitionID>
|
||||
@ -1976,12 +1976,14 @@ EOF
|
||||
EOF
|
||||
fi
|
||||
|
||||
# # ei.cfg
|
||||
# cat <<EOF >/os/installer/sources/ei.cfg
|
||||
# [Channel]
|
||||
# OEM
|
||||
# EOF
|
||||
# unix2dos /os/installer/sources/ei.cfg
|
||||
# ei.cfg
|
||||
if false; then
|
||||
cat <<EOF >/os/installer/sources/EI.CFG
|
||||
[Channel]
|
||||
_Default
|
||||
EOF
|
||||
unix2dos /os/installer/sources/EI.CFG
|
||||
fi
|
||||
|
||||
# 挂载 boot.wim
|
||||
mkdir -p /wim
|
||||
@ -2021,10 +2023,10 @@ EOF
|
||||
fi
|
||||
|
||||
# 复制应答文件
|
||||
# 移除注释,否则 windows-setup.bat 重新生成的 Autounattend.xml 有问题
|
||||
# 移除注释,否则 windows-setup.bat 重新生成的 autounattend.xml 有问题
|
||||
apk add xmlstarlet
|
||||
xmlstarlet ed -d '//comment()' /tmp/Autounattend.xml >/wim/Autounattend.xml
|
||||
unix2dos /wim/Autounattend.xml
|
||||
xmlstarlet ed -d '//comment()' /tmp/autounattend.xml >/wim/autounattend.xml
|
||||
unix2dos /wim/autounattend.xml
|
||||
|
||||
# 复制安装脚本
|
||||
# https://slightlyovercomplicated.com/2016/11/07/windows-pe-startup-sequence-explained/
|
||||
@ -2046,7 +2048,7 @@ EOF
|
||||
if [[ "$install_wim" = '*.wim' ]]; then
|
||||
wimmountrw $install_wim "$image_name" /wim/
|
||||
if false; then
|
||||
# 使用 Autounattend.xml
|
||||
# 使用 autounattend.xml
|
||||
# win7 在此阶段找不到网卡
|
||||
download $confhome/windows-resize.bat /wim/windows-resize.bat
|
||||
create_win_set_netconf_script /wim/windows-set-netconf.bat
|
||||
|
@ -20,8 +20,8 @@ for /F "tokens=2 delims==" %%A in ('wmic logicaldisk where "VolumeName='installe
|
||||
set "DiskIndex=%%A"
|
||||
)
|
||||
|
||||
:: 设置 Autounattend.xml 的主硬盘 id
|
||||
set "file=X:\Autounattend.xml"
|
||||
:: 设置 autounattend.xml 的主硬盘 id
|
||||
set "file=X:\autounattend.xml"
|
||||
set "tempFile=X:\tmp.xml"
|
||||
|
||||
set "search=%%disk_id%%"
|
||||
|
Loading…
x
Reference in New Issue
Block a user