Skip to content

Instantly share code, notes, and snippets.

@WillDawnlll
Last active April 21, 2026 08:12
Show Gist options
  • Select an option

  • Save WillDawnlll/8eceae571d5311c8aebe5c0d5a6e37a2 to your computer and use it in GitHub Desktop.

Select an option

Save WillDawnlll/8eceae571d5311c8aebe5c0d5a6e37a2 to your computer and use it in GitHub Desktop.
debian13 preseed.cfg
#_preseed_V1
# https://bit.ly/ghd13cfg
# Debian Official Documentation: https://www.debian.org/releases/stable/example-preseed.txt
# Debian Wiki Preseed: https://wiki.debian.org/DebianInstaller/Preseed
#
# [引导参数] 需配合以下内核引导参数实现完全无人值守安装:
# auto=true — 启用自动安装模式,延迟交互问题到 preseed 加载后回答
# priority=critical — 仅显示 critical 级别问题,跳过低优先级交互提示
# [示例] linux /install/vmlinuz auto=true priority=critical preseed/url=http://example.com/preseed.cfg
### 1. 核心最小化安装设置 (The Essential Minimal)
# [功能] 软件集合选择:取消所有预设任务
tasksel tasksel/first multiselect
# [功能] 排除推荐包:确保只安装必须的依赖
d-i base-installer/install-recommends boolean false
# [功能] 自动分区配方:将所有空间分配给根分区
d-i partman-auto/choose_recipe select atomic
# [功能] 自动分区方法:常规分区
d-i partman-auto/method string regular
# [功能] 无干预磁盘确认:自动写入分区表
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
# [功能] 自动结束安装:完成后自动重启
d-i finish-install/reboot_in_progress note
### 2. 基础环境设置 (Localization & Env)
# [功能] 区域设置:系统语言
d-i debian-installer/locale string en_US.UTF-8
# [功能] 键盘布局
d-i keyboard-configuration/xkb-keymap select us
# [功能] 时区设置
d-i time/zone string Asia/Shanghai
# [功能] 硬件时钟:使用 UTC
d-i clock-setup/utc boolean true
# [功能] NTP同步:安装时同步时间
d-i clock-setup/ntp boolean true
### 3. 网络配置 (Network)
# [功能] 主机名设定
d-i netcfg/get_hostname string debian-mini
# [功能] 域名设定
d-i netcfg/get_domain string local
# [功能] 自动确认网络配置
d-i netcfg/choose_interface select auto
### 4. 镜像源配置 (Mirror & APT)
# [功能] 镜像源协议与地址(以清华源为例,适合 ARM64 加速)
d-i mirror/country string manual
d-i mirror/http/hostname string mirrors.tuna.tsinghua.edu.cn
d-i mirror/http/directory string /debian
d-i mirror/http/proxy string
# [功能] 软件流行度调查:关闭
popularity-contest popularity-contest/participate boolean false
### 5. 用户与安全设置 (Account Setup)
# [功能] 启用 Root 账户
d-i passwd/root-login boolean true
# [功能] 设置 Root 密码(请在安装后立即更改)
# [原始] 明文密码方式(不安全,已弃用)
#d-i passwd/root-password password your_password
#d-i passwd/root-password-again password your_password
# [替代] 使用 crypt(3) SHA-512 哈希存储密码,避免明文泄露
# [生成] openssl passwd -6 -salt "$(openssl rand -hex 8)" 'xxx'
d-i passwd/root-password-crypted password $6$6694eb748c917764$zlhyiFqvte1l57kLY/zg0iEulGSo1GwpGqhkFxofr7PyJAOMciKMWgqZrLHq4i4fS/ZIDHw2k4JohJjhojeYB.
# [功能] 跳过创建普通用户:实现极致精简
d-i passwd/make-user boolean false
### 6. 引导程序 (Bootloader)
# [功能] 自动安装 GRUB 到主引导记录
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i grub-installer/bootdev string default
### 7. 附加组件与安装后脚本 (Advanced & Late Command)
# [功能] 额外安装特定包:添加 SSH 服务和虚拟化工具支持
d-i pkgsel/include string openssh-server curl open-vm-tools
# [功能] 后处理逻辑:允许 Root SSH 登录并清理缓存
d-i preseed/late_command string \
in-target sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/' /etc/ssh/sshd_config; \
in-target systemctl enable ssh; \
in-target apt-get clean
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment