gitmyhub

reinstall

Shell ★ 12k updated 1d ago

一键DD/重装脚本 (One-click reinstall OS on VPS)

A shell script that reinstalls the operating system on a VPS server remotely, switching between Linux distributions or to Windows with a single command and no control panel needed.

Shellsetup: moderatecomplexity 3/5

reinstall is a shell script for VPS servers that lets you replace the operating system on a virtual machine with a single command. It covers both Linux and Windows targets, meaning you can switch from Linux to Linux, Linux to Windows, Windows to Linux, or Windows to Windows without needing physical access to the machine or a control panel reinstall feature.

For Linux targets, the script supports 19 common distributions including Debian, Ubuntu, Alpine, Fedora, CentOS Stream, Rocky Linux, AlmaLinux, NixOS, and others across a range of versions. For Windows, the script uses official Microsoft ISOs rather than custom or modified images, and it automatically locates the download link and installs required cloud drivers such as VirtIO.

The script has five main modes. The first reinstalls to a Linux distribution. The second writes a raw disk image (DD format) directly to the machine's disk. The third boots the server into Alpine Linux running entirely from memory, useful for performing manual operations on a clean environment. The fourth boots to netboot.xyz, a tool that provides a menu of operating systems to install over the network. The fifth reinstalls to Windows.

Network configuration is handled automatically, including support for static IPs, unusual subnet configurations like /32 or /128 addresses, pure IPv6 setups, and machines where IPv4 and IPv6 use separate network interfaces. The script uses disk partition IDs rather than device names to identify the correct target disk, reducing the risk of writing to the wrong location. It is also optimized for low-memory VPS instances, requiring less RAM than standard network boot approaches.

All resources are fetched from official distribution mirrors at installation time, so the script itself does not bundle any OS files or custom packages. Both BIOS and EFI boot modes are supported, along with ARM-based servers.

Where it fits