logo
0
0
Login

Debian Network Reinstall Script

What is this?

A script that reinstalls any VPS or physical machine to minimal Debian via network boot. Works by injecting the Debian installer into GRUB and automatically configuring the installation process.

Perfect for:

  • Converting Oracle Cloud's Ubuntu images to Debian
  • Removing cloud provider surveillance agents
  • Creating minimal, clean Debian environments
  • Automating installations with preseed/cloud-init
  • Rescuing broken systems

Quick Start

# Download the script curl -fLO https://raw.githubusercontent.com/bohanyang/debi/master/debi.sh chmod +x debi.sh # Basic installation (creates user 'debian' with sudo access) sudo ./debi.sh # Or install as root user instead sudo ./debi.sh --user root # Reboot when ready sudo reboot

Default settings: Debian 13 (trixie), DHCP networking, user debian with sudo access, you'll be prompted for password.

Platform Support

PlatformStatusNotes
KVM/PhysicalFull supportAll features work
Most VPSFull supportDigitalOcean, Vultr, Linode, etc.
⚠️ Google CloudRequires manual networkMust use --ip, --gateway (DHCP broken)
⚠️ AWS EC2BIOS onlyUEFI boot not yet supported
ContainersNot supportedRequires GRUB bootloader

Requirements:

  • KVM or physical machine (not containers)
  • GRUB 2 bootloader
  • Root access

Regional Presets

PresetMirrorDNSNTPBest for
Defaultdeb.debian.orgGoogle DNStime.google.comGlobal
--cloudflaredeb.debian.orgCloudflaretime.cloudflare.comGlobal (privacy)
--awscdn-aws.deb.debian.orgGoogle DNStime.aws.comAWS instances
--aliyunmirrors.aliyun.comAliDNStime.amazonaws.cnChina
--tencentmirrors.tencentyun.comDNSPodtime1.tencentyun.comTencent Cloud
--ustcmirrors.ustc.edu.cnDNSPodtime.amazonaws.cnChina
--tunamirrors.tuna.tsinghua.edu.cnDNSPodtime.amazonaws.cnChina

Complete Options Reference

System & User Configuration

OptionDefaultDescription
--version 1313Debian version: 10, 11, 12, 13, 14
--suite trixietrixieDebian suite: stable, testing, sid, etc.
--user debiandebianUsername (use root for root-only)
--password PASSWORDpromptUser password (prompted if not specified)
--authorized-keys-url URLpassword authSSH keys from URL (e.g., https://github.com/user.keys)
--no-account-setupcreate userSkip user creation (manual setup via console)
--sudo-with-passwordno passwordRequire password for sudo commands
--timezone UTCUTCSystem timezone (e.g., Asia/Shanghai)
--hostname NAMEcurrentSystem hostname

Network Configuration

OptionDefaultDescription
--interface autoautoNetwork interface (e.g., eth0, eth1)
--ip ADDRESSDHCPStatic IP: 10.0.0.100, 1.2.3.4/24, 2001:db8::1/64
--static-ipv4DHCPUse current IPv4 settings automatically
--netmask MASKautoNetwork mask: 255.255.255.0, ffff:ffff:ffff:ffff::
--gateway ADDRESSautoGateway IP (use none for no gateway)
--dns '8.8.8.8 8.8.4.4'1.1.1.1 1.0.0.1DNS servers for IPv4
--dns6 '2001:4860:4860::8888'2606:4700:4700::1111DNS servers for IPv6
--ethxconsistent namingUse eth0/eth1 instead of enp0s3 style
--ntp time.google.comtime.google.comNTP server

Network Console (Remote Installation)

OptionDefaultDescription
--network-consoledisabledEnable SSH access during installation

Network Console Usage:

  1. Enable with --network-console and reboot
  2. Wait 2-3 minutes for Debian installer to load components
  3. SSH to your server: ssh installer@YOUR_IP
  4. Use multiple terminals:
    • Alt+F1: Main installer interface
    • Alt+F2: Shell access
    • Alt+F3: Additional shell
    • Alt+F4: System logs (monitor automated installation progress)
    • Navigate with Alt+Left/Alt+Right

[!IMPORTANT]
If --authorized-keys-url is used, SSH password authentication is disabled (SSH keys required), but you still need to set a user password for VNC console and sudo access.

Storage & Partitioning

OptionDefaultDescription
--disk /dev/sdaauto-detectTarget disk (required if multiple disks)
--no-disk-partitioningauto partitionManual partitioning via console
--filesystem ext4ext4Root filesystem type
--force-gptenabledCreate GPT partition table
--no-force-gptuse GPTUse MBR partition table instead
--biosauto-detectForce BIOS boot (creates BIOS boot partition)
--efiauto-detectForce EFI boot (creates EFI system partition)
--esp 106106EFI system partition size (106=100MB, 538=512MB, 1075=1GB)

Mirror & Repository Configuration

OptionDefaultDescription
--mirror-protocol httpshttpsMirror protocol: http, https, ftp
--httpsenabledAlias for --mirror-protocol https
--mirror-host deb.debian.orgdeb.debian.orgMirror hostname
--mirror-directory /debian/debianMirror directory path
--mirror-proxy URLnoneHTTP proxy for downloads and APT
--reuse-proxynoneUse existing http_proxy environment variable
--security-repository URLautoSecurity updates repo (use mirror for main mirror)

APT Repository Components

OptionDefaultDescription
--apt-non-free-firmwareenabledInclude non-free firmware (Debian 12+)
--apt-non-freedisabledEnable non-free repository
--apt-contribdisabledEnable contrib repository
--apt-srcenabledEnable source repositories
--apt-backportsenabledEnable backports repository
--no-apt-non-free-firmwareuse defaultDisable non-free firmware
--no-apt-non-freeuse defaultDisable non-free
--no-apt-contribuse defaultDisable contrib
--no-apt-srcuse defaultDisable source repositories
--no-apt-backportsuse defaultDisable backports

Package Installation

OptionDefaultDescription
--install 'pkg1 pkg2'minimalAdditional packages (space-separated, quoted)
--install-recommendsenabledInstall recommended packages
--no-install-recommendsinstall recommendsSkip recommended packages
--upgrade safe-upgradesafe-upgradePackage upgrade mode
--safe-upgradedefaultSafe package upgrades during install
--full-upgradesafe upgradeFull system upgrade (dist-upgrade)
--no-upgradesafe upgradeSkip package upgrades entirely

Kernel Options

OptionDefaultDescription
--kernel PACKAGElinux-image-ARCHKernel package name
--cloud-kernelstandardUse cloud-optimized kernel
--bpo-kernelstableUse newer kernel from backports
--firmwareauto-detectInclude non-free firmware for hardware

Advanced Options

OptionDefaultDescription
--ssh-port 222222Custom SSH port
--bbrdisabledEnable TCP BBR congestion control
--architecture amd64auto-detectTarget architecture: amd64, arm64, i386, etc.
--force-lowmem 1autoForce low memory mode: 0, 1, 2 (for <512MB RAM)
--no-force-efi-extra-removableenabledDisable EFI extra removable media path
--grub-timeout 55GRUB menu timeout in seconds

Debian Installer Options

OptionDefaultDescription
--release-d-iautoUse release version of debian-installer
--daily-d-iautoUse daily build of debian-installer

Cloud-Init Integration

OptionDefaultDescription
--cidata /path/to/dirnoneCustom cloud-init data directory

Cloud-Init Usage:

# Create cloud-init configuration mkdir my-cloud-config echo "instance-id: my-server" > my-cloud-config/meta-data cat > my-cloud-config/user-data << 'EOF' #cloud-config hostname: my-server packages: - htop - git EOF # Use with installation sudo ./debi.sh --cidata my-cloud-config

Development & Testing

OptionDefaultDescription
--dry-runexecuteGenerate configuration without installing
--holdrebootDon't reboot after installation
--power-offrebootPower off instead of reboot

Examples

Oracle Cloud (Ubuntu → Debian)

sudo ./debi.sh --cloudflare --user debian

Google Cloud Platform

# GCP requires manual network (replace with your VPC settings) sudo ./debi.sh --ip 10.128.0.100/24 --gateway 10.128.0.1

Minimal Installation

sudo ./debi.sh --no-install-recommends --install 'curl git vim' --no-upgrade

China Deployment

sudo ./debi.sh --ustc --timezone Asia/Shanghai --dns '119.29.29.29'

Network Console Installation

# Enable remote access during install (SSH keys for network, password still needed for VNC/sudo) sudo ./debi.sh --network-console --authorized-keys-url https://github.com/yourusername.keys # After reboot, SSH: ssh installer@YOUR_IP

Static Network with Cloud-Init

sudo ./debi.sh --ip 192.168.1.100/24 --gateway 192.168.1.1 --cidata ./cloud-config/

Advanced Custom Configuration

sudo ./debi.sh \ --version 13 \ --user admin \ --timezone Europe/London \ --disk /dev/nvme0n1 \ --filesystem btrfs \ --cloud-kernel \ --bbr \ --ssh-port 2222 \ --install 'htop iotop ncdu'

Troubleshooting

Revert All Changes

# Remove all modifications and restore original GRUB sudo rm -rf /etc/default/grub.d/zz-debi.cfg /boot/debian-* sudo update-grub || sudo grub2-mkconfig -o /boot/grub2/grub.cfg

Common Issues

Multiple disks detected:

# List available disks lsblk # Specify target disk sudo ./debi.sh --disk /dev/sda

Low memory VPS (<512MB):

sudo ./debi.sh --force-lowmem 1

Network configuration fails:

# Use current network settings sudo ./debi.sh --static-ipv4 # Or configure manually sudo ./debi.sh --ip YOUR_IP/CIDR --gateway YOUR_GATEWAY

Need firmware for network card:

sudo ./debi.sh --firmware

Installation debugging:

# Generate preseed file only sudo ./debi.sh --dry-run # Enable network console for remote access (SSH keys for remote, password for VNC/sudo) sudo ./debi.sh --network-console --authorized-keys-url YOUR_KEYS_URL

How It Works

  1. Downloads Debian installer to /boot/debian-$VERSION/
  2. Generates preseed file with your configuration
  3. Modifies GRUB configuration (adds installer menu entry)
  4. Injects configuration into installer initramfs
  5. Updates GRUB to include new boot option

Changes made to your system:

  • Files added to /boot/debian-*/
  • GRUB configuration in /etc/default/grub.d/zz-debi.cfg
  • Updated GRUB menu

These changes are safe and reversible before reboot using the revert command above.


Created by @bohanyangIssuesGitHub

About

Reinstall your VPS to minimal Debian

reinstalldebian