VPS Tutorials
Reinstall a VPS: provider rebuilds, scripts, images and recovery
Choose a VPS reinstall method, verify offsite backups and console access, preserve network settings and SSH keys, then restore supported services with tested access and disk procedures.

Reinstalling is useful when you need a different supported distribution, a clean environment or recovery from an unusable system. It is destructive: assume every partition on the selected system disk will be erased, and check the provider's treatment of additional disks before proceeding.
This guide compares a provider rebuild, the third-party reinstall script and raw disk images. Prepare recovery access and verified offsite backups first. If you want to move an existing service while preserving data, a staged migration may be the better operation.
| Route | When it fits | Main risk | Original time estimate |
|---|---|---|---|
| Provider's reinstall/rebuild | A suitable supported image is available | Wrong image/instance or lost disk data | 3–10 minutes |
| Third-party reinstall script | You need an image not offered in the panel | Privileged code, boot and network compatibility | 10–20 minutes |
| Raw image/DD | A supported custom or Windows image is required | Disk layout, architecture and driver mismatch | 20–60 minutes |
These times are examples, not completion or recovery guarantees. Prefer a documented provider workflow when it meets the requirement; evaluate scripts and custom images only after confirming how to recover.
Open the provider's VNC/KVM/Console/noVNC now and verify it shows the existing machine. Confirm how to enter rescue mode and whether support must enable it. SSH cannot rescue an installation whose network or boot configuration is broken. Without a tested recovery path, do not attempt a raw-image overwrite.
Save website files, databases, configuration, certificates, keys, service units and scheduled jobs. The original sketch is:
# 打包关键目录
tar czf /tmp/backup-$(date +%F).tar.gz \
/etc/nginx /etc/letsencrypt /var/www /root/.ssh
# 数据库单独导
mysqldump -u root -p --all-databases > /tmp/all-db.sql
# 或 PostgreSQL
sudo -u postgres pg_dumpall > /tmp/all-db.sql
Adapt paths to the actual system; missing paths can leave a failed or partial archive. Choose the correct database dump command instead of overwriting one output with the other. Use protected filenames, record exit statuses and keep files/database consistent during the backup. Transfer encrypted copies to another machine or storage outside the disks being replaced.
Verify extraction and a restore drill. For a service cutover, use VPS migration instead of assuming reinstall preserves data.
ip addr show
ip route show
cat /etc/resolv.conf
Save IPv4/IPv6 addresses and prefixes, gateways, routes, interface/MAC identities and DNS outside the VPS. Confirm whether the provider uses DHCP, static settings, routed addresses or special gateway routes; these requirements depend on its network design, not a continent. See IPv6 configuration.
On your trusted local computer:
cat ~/.ssh/id_ed25519.pub
Generate a key if needed using ssh-keygen -t ed25519 -C "your@email". Protect the private key. Prefer injecting the public key through a supported provider/script option rather than assuming the new image requires password login.
Reinstallation destroys evidence and does not repair stolen credentials or compromised neighboring systems. First isolate the incident, preserve required evidence and rotate exposed secrets using the incident checklist. Restore trusted data, not an unreviewed compromised application image.
Names and menu paths change, so read the current confirmation for the specific instance:
- RackNerd and SolusVM-based panels may call it Reinstall or Rebuild.
- Vultr provides its documented server reinstall workflow.
- BandwagonHost uses KiwiVM's Install new OS option where available.
- DigitalOcean distinguishes Rebuild an existing Droplet from destroying and creating another. Its rebuild documentation confirms an existing Droplet's IP is retained; destruction releases its address.
Confirm the instance, supported OS/architecture, disk effects, keys or initial credentials, and where credentials are delivered. Monitor panel/console progress. Connection refused can mean SSH has not started yet, but also a wrong address, port or listener; do not diagnose failure solely from waiting 3–5 minutes.
- Reinstallation normally changes host keys. For
REMOTE HOST IDENTIFICATION HAS CHANGED, verify the new fingerprint through the trusted console/provider before removing the old record. The originalssh-keygen -R 你的IPcontains a replaceable IP placeholder; use your actual hostname/IP and port entry. An unexplained change deserves investigation. - cloud-init may manage
/etc/netplan. Inspect its generated configuration and/etc/cloud/cloud.cfg//etc/cloud/cloud.cfg.d/before changing network ownership. Do not disable it blindly.
| System | Relevant support window | Use |
|---|---|---|
| Ubuntu 26.04 LTS | Standard maintenance through May 2031 | New workloads whose dependencies support the release |
| Ubuntu 24.04 LTS | Standard maintenance through May 2029 | Existing compatible tooling and consistent hosts |
| Debian 13, Trixie | Community LTS scheduled through June 2030 | Supported minimal server installations |
| Debian 12 | LTS scheduled through June 2028 | Existing dependencies with a migration plan |
- Verify third-party repositories support Ubuntu 26.04's release before adding them.
- Ubuntu 24.04 can match the Node.js and Python examples, but check application requirements too.
- A minimal Debian image may save memory on 512-MB/1-GB machines; the original one-to-two-hundred-MB difference is image-dependent, not guaranteed.
- CentOS Linux 7 is upstream EOL. Evaluate supported Rocky/AlmaLinux releases when a RHEL-family application requires them.
- Ubuntu interim releases generally receive nine months of support; 25.04/25.10 are not good long-lived new-server choices here. Archive repository access and successful
apt updatedo not establish security coverage.
Extended paid coverage has its own terms and package scope; do not confuse it with standard/community support.
bin456789/reinstall is a third-party project. A historical star count such as 13k+ is not a security review or proof of current compatibility. Read the current README, review a specific revision and confirm OS, architecture, virtualization, memory and network requirements before privileged execution.
# Debian/Ubuntu 先装依赖
apt update && apt install -y curl
# 下载脚本
curl -O https://raw.githubusercontent.com/bin456789/reinstall/main/reinstall.sh
# 装 Debian 13
bash reinstall.sh debian 13
# 或装 Ubuntu 24.04,并指定密码
bash reinstall.sh ubuntu 24.04 --password 'YourStrongPassword'
The Debian and Ubuntu commands are alternatives; choose only one. The shown password is a placeholder, and passing a real password as a command argument may expose it in history/process inspection. Prefer the project's supported key or interactive credential options. Use a verified download and its documented administrative privileges, such as an authorized root shell; ordinary-user execution is not appropriate.
The verified README warns that Linux installation erases the entire current system disk, including other partitions. It documents cancellation before reboot with bash reinstall.sh reset, and supported public-key options. Confirm those instructions against the revision you use. Do not interrupt preparation or reboot until the script reports that preparation completed.
reboot
Watch the console after reboot. SSH/ping can be unavailable while installing; duration varies. Record temporary and final credentials securely and distinguish them. A terminal multiplexer is not inherently forbidden; what matters is completing the documented stages without losing required input or output.
- If GitHub cannot be reached from the server, transfer a verified local download using
scpor a trusted upstream distribution path. Do not substitute an arbitrary mirror and run its privileged code. - Mainland-China download restrictions are a regional example, not a condition applying to all VPS users.
- Keep tested console/rescue access and offsite backups throughout.
If it fails, check console boot status → ip addr → the actual SSH service and listener → firewall/cloud rules. systemctl status sshd uses the sshd unit name; Debian/Ubuntu may use ssh. See console network recovery.
ip link show
The interface may be eth0, ens3 or enp0s3. Use the observed name and provider settings rather than copying an old interface name.
For an Ubuntu image actually managed by Netplan, adapt /etc/netplan/01-netcfg.yaml:
network:
version: 2
ethernets:
ens3:
addresses:
- 192.0.2.10/24
routes:
- to: default
via: 192.0.2.1
nameservers:
addresses: [1.1.1.1, 8.8.8.8]
The 192.0.2.0/24 addresses are documentation examples, not real assigned addresses. Replace prefix, gateway and DNS with the provider's settings; special routed gateways may need additional configuration. Avoid competing Netplan/cloud-init files.
chmod 600 /etc/netplan/01-netcfg.yaml
netplan try # 120 秒内不确认就自动回滚,比 netplan apply 安全
Use netplan try with console recovery available rather than applying netplan apply without a fallback. Use spaces in YAML. Debian may use /etc/network/interfaces, systemd-networkd or NetworkManager; identify the active manager instead of assuming a single default.
Raw-image installation writes disk contents through a supported workflow, bypassing much of an installer. It can be appropriate for:
- A compatible, licensed Windows installation not offered by the provider.
- A trusted custom image with required drivers/kernel.
- A documented recovery route when ordinary installation is unsuitable.
Before choosing it:
- Test console and external rescue access.
- Match architecture and CPU requirements; see ARM compatibility.
- Verify the expanded image's disk layout/size, not just compressed download size, fits the destination; check BIOS/UEFI, bootloader and VirtIO/storage/network drivers.
- Review the supported
reinstall.sh dd --img <url>workflow and exact image source/checksum. A wrapper aroundddis still destructive; it does not remove compatibility risk.
An overwrite can remove guest recovery partitions. A provider's external rescue environment is separate, but availability must be confirmed. Use rescue recovery or provide a precise support ticket if console/rescue cannot restore boot. Do not repeat destructive writes against an unidentified disk.
Do not assume every image has an open firewall or password login. Verify the actual defaults and establish reliable administrative access before exposing applications.
passwd
mkdir -p ~/.ssh && chmod 700 ~/.ssh
echo "ssh-ed25519 AAAA... your@email" >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys
Insert your complete real public key, not the truncated example, under the intended user's home with correct ownership. Test a new SSH connection while keeping the working session and console available.
sudo sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication no/' /etc/ssh/sshd_config
sudo sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config
sudo sshd -t && sudo systemctl restart ssh
The sed sketch edits only matching lines in one file. Include files, cloud-init or Match blocks can change effective settings. Inspect the effective configuration for your intended user, including keyboard-interactive authentication where applicable. Run sshd -t first; prefer a validated reload of the correct ssh/sshd unit and verify a fresh key login before closing existing access. PermitRootLogin prohibit-password still permits authorized root keys; use a separate sudo account when appropriate.
sudo apt update && sudo apt upgrade -y
sudo apt install -y curl git vim ufw fail2ban
sudo timedatectl set-timezone Asia/Shanghai
These package commands are for Debian/Ubuntu, not every distribution. Review upgrades and reboot requirements. Asia/Shanghai is the original example timezone: use your chosen operational timezone, often UTC, rather than inheriting a region from the source article. Installing Fail2ban is not the same as configuring and verifying an active jail.
sudo ufw allow OpenSSH
sudo ufw allow 80,443/tcp
sudo ufw --force enable
Add allow OpenSSH for the actual SSH port before enable. OpenSSH may represent port 22, so adjust it if your listener differs. Allow HTTP/HTTPS only if needed; verify IPv6 and provider rules too. Keep a console fallback for UFW lockout recovery.
sudo fallocate -l 2G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile && sudo swapon /swapfile
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab
For low-memory systems, first inspect existing swap and available disk/filesystem support. The 2-GB file is an example; do not overwrite an existing swapfile or append duplicate fstab entries. Some filesystems and provider environments need a different procedure. ZRAM and disk swap have CPU, storage and capacity trade-offs; neither fixes sustained insufficient RAM. Follow server hardening after access works.
- A broken service configuration often needs logs and diagnosis, not a rebuilt host.
- Filtering of a particular IP by mainland-China networks is outside the guest OS. Reinstallation does not change that address or filtering policy.
- CPU contention, provider throttling or network congestion require measurement and provider investigation.
- Disk exhaustion may be fixed with reviewed Docker cleanup; do not erase persistent data as a shortcut.
- To try another distribution, use a separate test VPS or verified recovery plan. Snapshots, backups and images serve different purposes; a snapshot alone is not an independent offsite copy.
A clean install may be appropriate for an unrecoverable filesystem, a deliberate distribution change or an environment you have chosen to rebuild. Preserve evidence and trusted backups first if compromise is involved.
Will the IP change? Provider reinstall commonly retains an existing instance's IP, but check its terms. DigitalOcean Rebuild retains it; destroying and creating a Droplet releases the address and does not promise the same replacement IP.
Does reinstall remove an IP block? It does not change network-layer filtering by itself. Diagnose the actual affected region and route; the IP filtering guide addresses the source's mainland-China case, not universal access guarantees.
Does it reset traffic billing? Guest reinstallation does not normally reset provider-side counters or the billing cycle. Confirm the provider's rules when destroying/recreating resources.
Why is the usable disk smaller? Inspect df -h together with partitions, filesystem and mounts; not every difference is an unexpanded root partition.
lsblk # 先看清楚盘和分区
sudo growpart /dev/vda 1 # 扩展分区
sudo resize2fs /dev/vda1 # ext4 扩展文件系统
# XFS 用 sudo xfs_growfs /
Identify the root device/filesystem before using growpart. The sample /dev/vda partition 1 and ext4 command are not universal; some hosts use /dev/sda, NVMe, LVM or XFS. Back up first, confirm adjacent free space and use the correct partition/filesystem procedure. Never substitute a guessed device name.
Why is Windows slow? Verify the selected Windows version's requirements, virtualization, drivers, license, disk and workload. The original 1/2/4-GB examples are rough usability estimates, not supported minimum requirements; updates and a desktop need adequate headroom.
- Harden the server after validating access.
- Size the workload before rebuilding.
- Understand recovery artifacts before the next change.
- Use rescue mode when installation fails.
- Diagnose external access when a service works only locally.