diff --git a/README.md b/README.md index beb4dd6..c866a80 100644 --- a/README.md +++ b/README.md @@ -3,13 +3,11 @@ ## Step 1. Preparation - A clean normally running true virtualization (e.g. KVM) VPS with GRUB2 and VNC access. This script have been tested on SolusVM KVM VPS & Alibaba Cloud ECS with Debian 8/9 & Ubuntu 16.04/18.04. - - Then check `/etc/default/grub` with your preferred editor (e.g. `nano` or `vi`). - + - Set `GRUB_DEFAULT` to `2` (which means select 3rd entry by default) will let **most of** virtual instances boot to installer automatically after timeout. + - Make sure there's reasonable number for `GRUB_TIMEOUT` **timeout**. You can just set `GRUB_TIMEOUT=30` which will be fine. - Make sure there's **no** `GRUB_HIDDEN_TIMEOUT_QUIET` and `GRUB_HIDDEN_TIMEOUT`. **Just delete them.** - - Make sure there's reasonable number for `GRUB_TIMEOUT` **timeout**. You can just set `GRUB_TIMEOUT=600` which will be fine (it's 10 minutes). - Install dependencies: ``` @@ -29,7 +27,7 @@ sudo sh -c "$(wget -O - https://github.com/brentybh/debian-netboot/raw/master/ne ### All Options - `-c US` Debian Installer Country - - `-fqdn unassigned-hostname.unassigned-domain` FQDN including hostname and domain + - `-fqdn debian` FQDN including hostname and domain - `-proto http` Transport protocol for archive mirror only but not security repository (`http`, `https`, `ftp`) - `-host deb.debian.org` Host for archive mirror only but not security repository - `-dir /debian` Directory path relative to root of the mirror @@ -41,18 +39,20 @@ sudo sh -c "$(wget -O - https://github.com/brentybh/debian-netboot/raw/master/ne - `-upgrade full-upgrade` Whether to upgrade packages after debootstrap (`none`, `safe-upgrade`, `full-upgrade`) - `-s http://security.debian.org/debian-security` Custom URL for security repository mirror - `-ip 192.168.1.42` Configure network manually with an IP address (following options only work when IP address specified) + - `-fs ext4` Filesystem for partition - `-cidr 255.255.255.0` Netmask for manual network configuration - `-gw 192.168.1.1` Gateway for manual network configuration - `-ns "8.8.8.8 8.8.4.4"` DNS for manual network configuration - `-add "ca-certificates curl fail2ban openssl whois"` Include individual additional packages to install - `-ssh secret` Enable network console and specify **password for SSH access during install process**. You can login with `installer` user and check system logs. + - `-dry-run` Generate `preseed.cfg` and save to current dir but don't actually do anything ### Chinese Special If `-c CN` is used, Chinese Special options will be setup for good connectivity and experience against GFW. - - Default archive mirror is `https://mirrors.ustc.edu.cn/debian`. - - Default security mirror is `https://mirrors.ustc.edu.cn/debian-security`. + - Default archive mirror is `https://chinanet.mirrors.ustc.edu.cn/debian`. + - Default security mirror is `https://chinanet.mirrors.ustc.edu.cn/debian-security`. - Default time zone is `Asia/Shanghai`. - Default NTP server is `cn.ntp.org.cn`. - Default DNS is `156.154.70.5 156.154.71.5`. @@ -63,5 +63,6 @@ If `-c CN` is used, Chinese Special options will be setup for good connectivity - 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. - - Use your keyboard to **select** `New Install` and **enter** it. Also, **be quick**, just do not miss the `GRUB_TIMEOUT` timeout you've set. + - If you've configured correct `GRUB_DEFAULT`, it should be booted into installer automatically after timeout. + - Or, use your keyboard to **select** `New Install` 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. diff --git a/netboot.sh b/netboot.sh index 492cf84..07036dd 100644 --- a/netboot.sh +++ b/netboot.sh @@ -92,6 +92,13 @@ while [ $# -gt 0 ]; do SSH_PASSWD=$2 shift ;; + -fs) + FILESYS=$2 + shift + ;; + -dry-run) + DRYRUN=true + ;; *) echo "Illegal option $1" exit 1 @@ -102,7 +109,7 @@ done case "$COUNTRY" in CN) PROTO=${PROTO:-https} - HOST=${HOST:-mirrors.ustc.edu.cn} + HOST=${HOST:-chinanet.mirrors.ustc.edu.cn} TIME_ZONE=${TIME_ZONE:-Asia/Shanghai} NTP=${NTP:-cn.ntp.org.cn} SECURITY=${SECURITY:-true} @@ -120,6 +127,7 @@ TIME_ZONE=${TIME_ZONE:-UTC} NTP=${NTP:-pool.ntp.org} UPGRADE=${UPGRADE:-full-upgrade} DNS=${DNS:-8.8.8.8 8.8.4.4} +FILESYS=${FILESYS:-ext4} if [ -z "$SECURITY" ]; then SECURITY=http://security.debian.org/debian-security @@ -135,6 +143,9 @@ else PASSWD=$(mkpasswd -m sha-512 "$PASSWD") fi + +if [ "$DRYRUN" != true ]; then + BOOT=/boot/debian-$SUITE URL=$PROTO://$HOST$DIR/dists/$SUITE/main/installer-$ARCH/current/images/netboot/debian-installer/$ARCH @@ -143,6 +154,8 @@ rm -fr "$BOOT" mkdir -p "$BOOT" cd "$BOOT" +fi + cat >> preseed.cfg << EOF # COUNTRY: 1 # IP_ADDR: 2 @@ -159,6 +172,7 @@ cat >> preseed.cfg << EOF # PASSWD: 4 # TIME_ZONE: 5 # NTP: 5 +# FILESYS: 6 # SECURITY: 8 # INCLUDE: 9 # UPGRADE: 9 @@ -192,8 +206,8 @@ if [ -n "$IP_ADDR" ]; then fi cat >> preseed.cfg << EOF -d-i netcfg/get_hostname string unassigned-hostname -d-i netcfg/get_domain string unassigned-domain +d-i netcfg/get_hostname string debian +d-i netcfg/get_domain string EOF if [ -n "$FQDN" ]; then @@ -238,7 +252,7 @@ d-i time/zone string {{-TIME_ZONE-}} d-i clock-setup/ntp boolean true d-i clock-setup/ntp-server string {{-NTP-}} -# 6. Partitioning +# 6. Partitioning: FILESYS d-i partman-basicfilesystems/no_swap boolean false d-i partman-auto/method string regular @@ -246,7 +260,7 @@ d-i partman-lvm/device_remove_lvm boolean true d-i partman-md/device_remove_md boolean true d-i partman-lvm/confirm boolean true d-i partman-lvm/confirm_nooverwrite boolean true -d-i partman-auto/expert_recipe string naive :: 0 1 -1 ext4 $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ ext4 } mountpoint{ / } . +d-i partman-auto/expert_recipe string naive :: 0 1 -1 {{-FILESYS-}} $primary{ } $bootable{ } method{ format } format{ } use_filesystem{ } filesystem{ {{-FILESYS-}} } mountpoint{ / } . d-i partman-auto/choose_recipe select naive d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish @@ -298,6 +312,9 @@ sed -i 's/{{-TIME_ZONE-}}/'$(echo "$TIME_ZONE" | sed 's/\//\\\//g')'/g' preseed. sed -i 's/{{-NTP-}}/'"$NTP"'/g' preseed.cfg sed -i 's/{{-SECURITY-}}/'$(echo "$SECURITY" | sed 's/\//\\\//g')'/g' preseed.cfg sed -i 's/{{-UPGRADE-}}/'"$UPGRADE"'/g' preseed.cfg +sed -i 's/{{-FILESYS-}}/'"$FILESYS"'/g' preseed.cfg + +if [ "$DRYRUN" != true ]; then wget "$URL/linux" "$URL/initrd.gz" gunzip initrd.gz @@ -313,3 +330,5 @@ linux $BOOT/linux initrd $BOOT/initrd.gz } EOF + +fi