pull/8/head
Bohan Yang 7 years ago
parent 031cf69e0c
commit 2b89f66765
  1. 132
      README.md

@ -1,82 +1,64 @@
# Setup Clean Debian OS for Your (Cloud) VPS # VPS Re-install Debian 9 Script
## Step 1. Preparation ## Introduction
- A clean normally running true virtualization (e.g. KVM) VPS with GRUB 2 and VNC access. This script have been tested on SolusVM KVM VPS & Alibaba Cloud ECS with Debian 9 & Ubuntu 16.04. This script is used to re-install VPS to Debian 9 with the official installer, but semi-automatically.
- Then check `/etc/default/grub` with your preferred editor (e.g. `nano` or `vi`).
- Set `GRUB_DEFAULT` to `debi` select the installer to boot automatically after timeout. ## How It Works
- Make sure there's reasonable number for `GRUB_TIMEOUT` **timeout**. You can just set `GRUB_TIMEOUT=10` which will be fine.
- Make sure there's **no** `GRUB_HIDDEN_TIMEOUT_QUIET` and `GRUB_HIDDEN_TIMEOUT`. **Just delete them.** 1. Generate a preseed file to automate installation
2. Download Debian Installer to the boot directory
Install dependencies: 3. Alter GRUB2 configuration to boot the installer
``` ## Usage
sudo apt update && sudo apt -y install ca-certificates whois
``` sudo sh -c "$(wget -qO- https://github.com/brentybh/debian-netboot/raw/master/netboot.sh)" -- <OPTIONS>
## Step 2. Run the Script ## Available Options
Replace following `<OPTIONS>` with your options. - `--preset` [`china`, `cloud`]
- `--ip`
``` - `--netmask`
sudo sh -c "$(wget -qO- https://github.com/brentybh/debian-netboot/raw/master/netboot.sh)" -- <OPTIONS> - `--gateway`
``` - `--ns "1.1.1.1 1.0.0.1"`
- `--hostname debian`
**Remember** to enter your current user's password for `sudo` (if need) and then enter the new user's password (if not specified by `--password`). - `--ssh-password`
- `--ssh-keys`
### All Options - `--protocol http` [`http`, `https`, `ftp`]
- `--mirror deb.debian.org`
- `--template foobar` Selected template (see below) - `--directory /debian`
- `--hostname debian` Hostname. Precedence: provided value > reverse DNS record > the default value `debian` - `--suite stretch`
- `--protocol http` Transport protocol to use with the repository mirror (not for the security mirror). Possible values: `http`, `https`, `ftp`, etc. - `--skip-user`
- `--mirror deb.debian.org` Hostname of the repository mirror (not for the security mirror) - `--username debian`
- `--directory /debian` Directory of the repository mirror - `--password`
- `--suite stretch` Selected suite to install (`stable`, `testing`, `stretch`, etc.) - `--timezone UTC` https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List
- `--username debian` Username of the administrator account with sudo privilege - `--ntp pool.ntp.org`
- `--password secret` Password of the account **(if not specified, it will be asked interactively)** - `--skip-part`
- `--timezone UTC` [Time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) - `--disk`
- `--ntp-server pool.ntp.org` NTP server - `--part`
- `--upgrade full-upgrade` Whether to upgrade packages after debootstrap (`none`, `safe-upgrade`, `full-upgrade`) - `--fs ext4`
- `--security-mirror http://security.debian.org/debian-security` Specify a URL for the security mirror or set to `true` to use the same mirror as the repository mirror instead of the default one - `--security http://security.debian.org/debian-security`
- `--filesystem ext4` Filesystem for partition - `--install`
- `--disk-encryption` Enable full disk encryption. Since it can't be fully automated currently, you'll need physical console (VNC) access to go through the steps - `--upgrade full-upgrade` [`none`, `safe-upgrade`, `full-upgrade`]
- `--ip 12.34.56.78` Configure network manually with an IP address **(the following 3 network related options only work when an IP address is provided here)** - `--poweroff`
- `--netmask 255.255.255.0` Netmask for manual network configuration - `--arch`
- `--gateway 12.34.56.1` Gateway for manual network configuration - `--boot-partition`
- `--dns "1.1.1.1 1.0.0.1"` DNS for manual network configuration - `--dry-run`
- `--include "ca-certificates curl fail2ban openssl whois"` Include additional packages to install
- `--manual` Manually configure user account and disk partition, etc. Network connection, the repository and security mirrors, time zone and NTP server are already auto-configured ## Presets
- `--ssh-password installer_secret` Enable SSH access to the installer with a password. You can login to `installer` user and continue installation manually or just check system logs.
- `--ssh-keys https://example.com/.ssh/authorized_keys` Enable SSH access to the installer with a URL of the file contains authorized public keys. (see above) You can't access with password if authorized public keys are provided here. ### `china`
- `--dry-run` Generate `preseed.cfg` and save to current directory but don't actually do anything
- `--architecture amd64` Specify an architecture (useful under CentOS) - `--ns "156.154.70.5 156.154.71.5"`
- `--boot-partition` Use `/` as the boot directory for the GRUB boot entry instead of `/boot`, useful under LVM machines with an independent boot partition
### Templates
You can select a template for quickly applying options. All custom settings will override template values.
#### `china`
- `--protocol https` - `--protocol https`
- `--mirror chinanet.mirrors.ustc.edu.cn` - `--mirror chinanet.mirrors.ustc.edu.cn`
- `--security-mirror true` - `--security true`
- `--timezone Asia/Shanghai` - `--timezone Asia/Shanghai`
- `--ntp-server cn.ntp.org.cn` - `--ntp cn.ntp.org.cn`
- `--dns "156.154.70.5 156.154.71.5"`
#### `cloud` ### `cloud`
- `--protocol https` - `--protocol https`
- `--mirror cdn-aws.deb.debian.org` - `--mirror cdn-aws.deb.debian.org`
- `--security-mirror true` - `--security true`
- `--ntp-server time.google.com` - `--ntp time.google.com`
## Step 3. Entering Debian Installer
- Keep your SSH connection and **open VNC console** on your Provider's control panel.
- `sudo reboot` with your SSH and the VM should **reboot**.
- Switch to your VNC window **quickly**. You should enter the **GRUB selection menu** now.
- If you've configured correct `GRUB_DEFAULT`, it should be booted into installer automatically after timeout.
- Or, use your keyboard to **select** `Debian Installer` and **enter** it. Also, **be quick**, just do not miss the `GRUB_TIMEOUT` timeout you've set.
- Finally, you should see the screen of Debian Installer now. It will setup all things automatically and reboot when complete.

Loading…
Cancel
Save