2024-05-22 22:32:43 +08:00
|
|
|
|
#_preseed_V1
|
|
|
|
|
# shellcheck disable=SC1091,SC2148
|
2023-07-22 21:45:47 +08:00
|
|
|
|
# https://www.debian.org/releases/stable/amd64/apbs04.zh-cn.html
|
2023-08-27 23:46:48 +08:00
|
|
|
|
# https://www.debian.org/releases/stable/example-preseed.txt
|
|
|
|
|
# https://preseed.debian.net/debian-preseed/bookworm/amd64-main-full.txt
|
2024-05-22 21:39:00 +08:00
|
|
|
|
# 需要留意 kali initrd 自带的 /preseed.cfg
|
2023-08-08 23:21:28 +08:00
|
|
|
|
|
2024-04-03 21:53:52 +08:00
|
|
|
|
# 下面这行语句无效,因为本行后面有反斜杠,前面有空格(安装器认为不算注释)\
|
|
|
|
|
d-i debian-installer/locale string en_US
|
|
|
|
|
|
2023-05-17 22:54:26 +08:00
|
|
|
|
# B.4.1. 本地化
|
|
|
|
|
d-i debian-installer/locale string en_US
|
|
|
|
|
d-i keyboard-configuration/xkb-keymap select us
|
|
|
|
|
|
|
|
|
|
# B.4.2. 网络设置
|
|
|
|
|
d-i netcfg/get_hostname string unassigned-hostname
|
|
|
|
|
d-i netcfg/get_domain string unassigned-domain
|
|
|
|
|
d-i netcfg/hostname string localhost
|
|
|
|
|
|
|
|
|
|
# B.4.3. 网络控制台
|
|
|
|
|
|
|
|
|
|
# B.4.4. 镜像设置
|
|
|
|
|
d-i mirror/country string manual
|
2024-05-03 21:37:07 +08:00
|
|
|
|
# d-i mirror/http/hostname string deb.debian.org
|
2023-05-17 22:54:26 +08:00
|
|
|
|
|
|
|
|
|
# B.4.5. 帐号设置
|
|
|
|
|
d-i passwd/make-user boolean false
|
|
|
|
|
d-i passwd/root-password password 123@@@
|
|
|
|
|
d-i passwd/root-password-again password 123@@@
|
2024-05-03 21:37:07 +08:00
|
|
|
|
# kali 需要下面这行,否则会提示输入用户名
|
|
|
|
|
d-i passwd/root-login boolean true
|
2023-05-17 22:54:26 +08:00
|
|
|
|
|
|
|
|
|
# B.4.6. 时钟与时区设置
|
|
|
|
|
d-i time/zone string Asia/Shanghai
|
|
|
|
|
|
|
|
|
|
# B.4.7. 分区
|
|
|
|
|
d-i partman-auto/method string regular
|
2023-09-15 19:22:23 +08:00
|
|
|
|
d-i partman-lvm/device_remove_lvm boolean true
|
|
|
|
|
d-i partman-md/device_remove_md boolean true
|
2023-05-17 22:54:26 +08:00
|
|
|
|
d-i partman-partitioning/confirm_write_new_label boolean true
|
|
|
|
|
d-i partman/choose_partition select finish
|
|
|
|
|
d-i partman/confirm boolean true
|
|
|
|
|
d-i partman/confirm_nooverwrite boolean true
|
2024-03-25 22:40:50 +08:00
|
|
|
|
|
|
|
|
|
# vm 原有系统是 bios + gpt,切换成 efi,用 iso 重装,需要确认此项
|
|
|
|
|
# 用脚本重装的话,强制安装在第二个硬盘上也可能会遇到?
|
|
|
|
|
d-i partman-efi/non_efi_system boolean true
|
|
|
|
|
|
|
|
|
|
### Description: Do you want to return to the partitioning menu?
|
|
|
|
|
# You have not selected any partitions for use as swap space. Enabling swap
|
|
|
|
|
# space is recommended so that the system can make better use of the
|
|
|
|
|
# available physical memory, and so that it behaves better when physical
|
|
|
|
|
# memory is scarce. You may experience installation problems if you do not
|
|
|
|
|
# have enough physical memory.
|
|
|
|
|
# .
|
|
|
|
|
# If you do not go back to the partitioning menu and assign a swap partition,
|
|
|
|
|
# the installation will continue without swap space.
|
|
|
|
|
# 坑的一比
|
|
|
|
|
# 不是确认是否 no_swap
|
|
|
|
|
# 而是 recipe no_swap 时,确认是否返回上一级重新分区
|
|
|
|
|
# 选择 true 就一直死循环
|
|
|
|
|
d-i partman-basicfilesystems/no_swap boolean false
|
|
|
|
|
|
|
|
|
|
# 最小值 膨胀权重 最大值
|
|
|
|
|
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes/atomic?ref_type=heads
|
|
|
|
|
# https://salsa.debian.org/installer-team/partman-auto/-/blob/master/recipes-amd64-efi/atomic?ref_type=heads
|
2024-05-22 21:27:06 +08:00
|
|
|
|
# shellcheck disable=SC1083,SC2086,SC2154
|
2024-03-25 22:40:50 +08:00
|
|
|
|
d-i partman-auto/expert_recipe_efi string efi :: \
|
|
|
|
|
106 1 106 free \
|
2024-05-22 21:27:06 +08:00
|
|
|
|
$iflabel{ gpt } method{ efi } format{ } . \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
1 1 -1 $default_filesystem \
|
|
|
|
|
method{ format } format{ } use_filesystem{ } $default_filesystem{ } mountpoint{ / } .
|
|
|
|
|
|
2024-05-22 21:27:06 +08:00
|
|
|
|
# shellcheck disable=SC1083,SC2086,SC2154
|
2024-03-25 22:40:50 +08:00
|
|
|
|
d-i partman-auto/expert_recipe_bios string bios :: \
|
|
|
|
|
1 1 1 free \
|
2024-05-22 21:27:06 +08:00
|
|
|
|
$iflabel{ gpt } method{ biosgrub } . \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
1 1 -1 $default_filesystem \
|
|
|
|
|
method{ format } format{ } use_filesystem{ } $default_filesystem{ } mountpoint{ / } .
|
2023-05-17 22:54:26 +08:00
|
|
|
|
|
|
|
|
|
# B.4.8. 基本系统安装
|
|
|
|
|
|
|
|
|
|
# B.4.9. 设置 apt
|
2024-03-25 22:40:50 +08:00
|
|
|
|
d-i apt-setup/non-free boolean true
|
2023-08-27 23:46:48 +08:00
|
|
|
|
d-i apt-setup/non-free-firmware boolean true
|
2024-03-25 22:40:50 +08:00
|
|
|
|
d-i apt-setup/contrib boolean true
|
2023-05-17 22:54:26 +08:00
|
|
|
|
d-i apt-setup/enable-source-repositories boolean false
|
2024-05-03 21:37:07 +08:00
|
|
|
|
# kali 不要设置
|
|
|
|
|
# d-i apt-setup/security_host string security.debian.org
|
2023-05-17 22:54:26 +08:00
|
|
|
|
|
|
|
|
|
# B.4.10. 选择软件包
|
|
|
|
|
tasksel tasksel/first multiselect ssh-server
|
|
|
|
|
d-i pkgsel/upgrade select none
|
|
|
|
|
|
|
|
|
|
# B.4.11. 安装 bootloader
|
2024-03-25 22:40:50 +08:00
|
|
|
|
# 添加 bootx64.efi
|
2023-05-17 22:54:26 +08:00
|
|
|
|
d-i grub2/force_efi_extra_removable boolean true
|
|
|
|
|
|
|
|
|
|
# B.4.12. 完成安装
|
|
|
|
|
d-i finish-install/reboot_in_progress note
|
|
|
|
|
|
|
|
|
|
# B.4.13. 预置其他的软件包
|
|
|
|
|
|
2024-05-03 21:37:07 +08:00
|
|
|
|
# 其他设置
|
|
|
|
|
# d-i anna/standard_modules boolean false
|
|
|
|
|
# d-i anna/choose_modules string network-console
|
|
|
|
|
# d-i network-console/password password 123@@@
|
|
|
|
|
# d-i network-console/password-again password 123@@@
|
|
|
|
|
|
2023-05-17 22:54:26 +08:00
|
|
|
|
# B.5.1. 安装过程中运行用户命令
|
2024-05-22 21:39:00 +08:00
|
|
|
|
# 注意所有命令都会合并成一行命令
|
|
|
|
|
|
2024-05-22 22:32:43 +08:00
|
|
|
|
# 最后的 true; \ 没什么用,只是让 vscode 代码高亮不报错误
|
|
|
|
|
|
2024-05-22 21:39:00 +08:00
|
|
|
|
# 有 /cdrom/simple-cdd 才安装 simple-cdd-profiles
|
|
|
|
|
# 不然安装时 control 脚本会报错:
|
|
|
|
|
# Loading simple-cdd-profiles failed for unknown reasons
|
|
|
|
|
d-i preseed/early_command string true; \
|
|
|
|
|
if [ -d /cdrom/simple-cdd ]; then anna-install simple-cdd-profiles; fi
|
2023-05-17 22:54:26 +08:00
|
|
|
|
|
2024-04-29 22:26:12 +08:00
|
|
|
|
# debian 11 initrd 没有 xargs awk
|
|
|
|
|
# debian 12 initrd 没有 xargs
|
2024-05-22 21:27:06 +08:00
|
|
|
|
# efi 分区大小未改变时,不会被格式化,因此需要手动删除旧系统的 efi 文件
|
2024-05-22 22:32:43 +08:00
|
|
|
|
# os-prober 卡太久,因此跳过
|
|
|
|
|
d-i partman/early_command string true; \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
confhome="$(grep -o 'extra\.confhome=[^ ]*' /proc/cmdline | cut -d= -f2)"; \
|
2024-05-03 21:37:07 +08:00
|
|
|
|
|
2024-03-25 22:40:50 +08:00
|
|
|
|
postinst=/var/lib/dpkg/info/bootstrap-base.postinst; \
|
|
|
|
|
cp $postinst $postinst.orig; \
|
2024-05-22 22:32:43 +08:00
|
|
|
|
true >$postinst; \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
|
2024-05-22 22:32:43 +08:00
|
|
|
|
swapfile=/target/swapfile; \
|
|
|
|
|
mem=$(grep ^MemTotal: /proc/meminfo | { read -r _ y _; echo "$y"; }); \
|
2024-04-29 22:26:12 +08:00
|
|
|
|
mem=$((mem / 1024)); \
|
|
|
|
|
swap_size=$((512 - mem)); \
|
2024-05-22 22:32:43 +08:00
|
|
|
|
[ $swap_size -gt 0 ] && echo "fallocate -l ${swap_size}M $swapfile; mkswap $swapfile; swapon $swapfile" >>$postinst; \
|
2024-05-03 21:37:07 +08:00
|
|
|
|
|
2024-04-29 22:26:12 +08:00
|
|
|
|
echo "swapoff -a; rm -f $swapfile" >/usr/lib/finish-install.d/95swapoff; \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
chmod a+x /usr/lib/finish-install.d/95swapoff; \
|
|
|
|
|
|
2024-05-22 21:27:06 +08:00
|
|
|
|
echo "rm -rf /target/boot/efi/*; $postinst.orig" >>$postinst; \
|
|
|
|
|
|
|
|
|
|
xda=$(wget --tries=5 "$confhome/get-xda.sh" -O- | sh -s); \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
debconf-set partman-auto/disk "/dev/$xda"; \
|
2024-04-16 23:29:19 +08:00
|
|
|
|
debconf-set grub-installer/bootdev "/dev/$xda"; \
|
2024-04-03 21:53:52 +08:00
|
|
|
|
rm -rf /usr/sbin/fdisk /usr/sbin/sfdisk; \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
|
2024-05-22 22:32:43 +08:00
|
|
|
|
ttys=$(wget --tries=5 "$confhome/ttys.sh" -O- | sh -s console=); \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
debconf-set debian-installer/add-kernel-opts "$ttys"; \
|
2024-02-02 00:31:21 +08:00
|
|
|
|
|
2024-05-22 21:37:30 +08:00
|
|
|
|
sh /can_use_cloud_kernel.sh "$xda" || debconf-set base-installer/kernel/image "$(debconf-get base-installer/kernel/image | sed 's/-cloud//')"; \
|
2024-02-02 00:31:21 +08:00
|
|
|
|
|
2024-03-25 22:40:50 +08:00
|
|
|
|
[ -d /sys/firmware/efi ] && debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_efi)"; \
|
2024-04-03 21:53:52 +08:00
|
|
|
|
[ -d /sys/firmware/efi ] || debconf-set partman-auto/expert_recipe "$(debconf-get partman-auto/expert_recipe_bios)"; \
|
|
|
|
|
|
|
|
|
|
true >/bin/os-prober
|
2023-08-27 23:52:06 +08:00
|
|
|
|
|
2023-07-22 21:44:58 +08:00
|
|
|
|
# debian 10 没有 /target/etc/ssh/sshd_config.d/ 文件夹
|
2024-05-03 21:37:07 +08:00
|
|
|
|
# kali ssh 默认关闭
|
2024-05-22 22:32:43 +08:00
|
|
|
|
d-i preseed/late_command string true; \
|
2024-05-03 21:37:07 +08:00
|
|
|
|
in-target systemctl enable ssh; \
|
2024-03-25 22:40:50 +08:00
|
|
|
|
echo "PermitRootLogin yes" >/target/etc/ssh/sshd_config.d/01-permitrootlogin.conf || \
|
|
|
|
|
echo "PermitRootLogin yes" >>/target/etc/ssh/sshd_config
|