1
2
root@debian:~# pwd
/root
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# 下载Debian12.8.0
root@debian:~# wget https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.8.0-amd64-netinst.iso
--2025-01-11 13:54:25-- https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.8.0-amd64-netinst.iso
Resolving cdimage.debian.org (cdimage.debian.org)... 194.71.11.173, 194.71.11.163, 2001:6b0:19::163, ...
Connecting to cdimage.debian.org (cdimage.debian.org)|194.71.11.173|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://chuangtzu.ftp.acc.umu.se/debian-cd/current/amd64/iso-cd/debian-12.8.0-amd64-netinst.iso [following]
--2025-01-11 13:54:27-- https://chuangtzu.ftp.acc.umu.se/debian-cd/current/amd64/iso-cd/debian-12.8.0-amd64-netinst.iso
Resolving chuangtzu.ftp.acc.umu.se (chuangtzu.ftp.acc.umu.se)... 194.71.11.167, 2001:6b0:19::167
Connecting to chuangtzu.ftp.acc.umu.se (chuangtzu.ftp.acc.umu.se)|194.71.11.167|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 661651456 (631M) [application/x-iso9660-image]
Saving to: ‘debian-12.8.0-amd64-netinst.iso’

debian-12.8.0-amd64-netinst.iso 100%[============================================================================================================>] 631.00M 3.97MB/s in 41s

2025-01-11 13:55:10 (15.4 MB/s) - ‘debian-12.8.0-amd64-netinst.iso’ saved [661651456/661651456]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# mount镜像
root@debian:~# mkdir mnt
root@debian:~# mount ./debian-12.8.0-amd64-netinst.iso ./mnt
mount: /root/mnt: WARNING: source write-protected, mounted read-only.
root@debian:~# ls ./mnt
boot css debian dists doc EFI firmware install install.amd isolinux md5sum.txt
pics pool README.html README.mirrors.html README.mirrors.txt README.source README.txt
# 复制镜像文件
root@debian:~# cp -rT ./mnt ./isofile
root@debian:~# ls ./isofile/
boot css debian dists doc EFI firmware install install.amd isolinux md5sum.txt
pics pool README.html README.mirrors.html README.mirrors.txt README.source README.txt
# umount镜像
root@debian:~# umount ./mnt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 修改启动超时时间
root@debian:~# nano ./isofile/isolinux/isolinux.cfg
root@debian:~# cat ./isofile/isolinux/isolinux.cfg
# D-I config version 2.0
# search path for the c32 support libraries (libcom32, libutil etc.)
path
prompt 0
timeout 1
include menu.cfg
default vesamenu.c32
# 设置默认为CLI安装
root@debian:~# nano ./isofile/isolinux/txt.cfg
root@debian:~# cat ./isofile/isolinux/txt.cfg
default install
label install
menu label ^Install
menu default
kernel /install.amd/vmlinuz
append vga=788 initrd=/install.amd/initrd.gz --- quiet preseed/file=/cdrom/preseed.cfg
# 禁用默认GUI安装
root@debian:~# nano ./isofile/isolinux/gtk.cfg
root@debian:~# cat ./isofile/isolinux/gtk.cfg
label installgui
menu label ^Graphical install
kernel /install.amd/vmlinuz
append vga=788 initrd=/install.amd/gtk/initrd.gz --- quiet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 写preseed.cfg文件
root@debian:~# nano ./isofile/preseed.cfg
root@debian:~# cat ./isofile/preseed.cfg
d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
d-i netcfg/choose_interface select auto
d-i netcfg/hostname string debian

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

d-i apt-setup/cdrom/set-first boolean false

d-i passwd/make-user boolean false
d-i passwd/root-password password 123456
d-i passwd/root-password-again password 123456

d-i time/zone string Asia/Shanghai

d-i pkgsel/run_tasksel boolean false
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select none

d-i finish-install/reboot_in_progress note
1
2
3
4
5
6
root@debian:~# chmod +w -R ./isofile/install.amd/
root@debian:~# gunzip ./isofile/install.amd/initrd.gz
root@debian:~# echo ./isofile/preseed.cfg | cpio -H newc -o -A -F ./isofile/install.amd/initrd
2 blocks
root@debian:~# gzip ./isofile/install.amd/initrd
root@debian:~# chmod -w -R ./isofile/install.amd/
1
2
root@debian:~# cd isofile/
root@debian:~/isofile# genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../debian.iso ./