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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
| #############
# 网络配置
#############
d-i netcfg/choose_interface select auto
#############
# Pre Install
############
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \
umount /media || true
#############
# Net Image
#############
# 针对12.10以上的版本一定要配置这个
d-i live-installer/net-image string
#############
#语言设置
#############
d-i debian-installer/locale string en
d-i debian-installer/country string CN
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/language string en
#############
# 键盘设置
#############
d-i console-setup/ask_detect boolean false
d-i console-setup/layoutcode string us
d-i console-setup/variantcode string
d-i keyboard-configuration/layoutcode string us
#############
# 安装源配置
#############
#安装源配置
d-i mirror/country string manual
d-i mirror/http/proxy string 1.1.1.122 #此处必须填写,否则安装system要等很久
d-i mirror/http/hostname string 1.1.1.122
d-i mirror/http/directory string /ubuntu/
#############
# APT
############
#如不配置此项,在安装包的时候会卡住很久,但不影响最终安装结果
d-i apt-setup/security_host string 172.16.245.240
d-i apt-setup/security_path string /ubuntu
#############
#
# Clock and Time Zone
#
#############
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string 1.1.1.1
d-i time/zone string Asia/Shanghai
d-i clock-setup/CST boolean true
#############
# Partitioning
#############
#清楚磁盘中所有的lvm分区
d-i partman-lvm/device_remove_lvm boolean true
# 清楚所有raid分区
d-i partman-md/device_remove_md boolean true
#使用磁盘进行普通分区
d-i partman-auto/method string regular
d-i partman-auto/disk string /dev/vda #kvm虚拟机中磁盘是vda,如果是真实机器则是sda
#预定义分区方式,每个分区在一行定义,以.结尾
#每组分区三个数字表示:最小分区多少MB,优先级(越小越优先),分区最大多少MB
d-i partman-auto/expert_recipe string \
boot-root :: \
150 150 150 ext4 \
$primary{ } $bootable{ } \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ /boot } \
. \
8000 8000 8000 linux-swap \
method{ swap } format{ } \
. \
204800 204800 204800 ext4 \
method{ format } format{ } \
use_filesystem{ } filesystem{ ext4 } \
mountpoint{ / } \
.
d-i partman-partitioning/confirm_write_new_label boolean true #不提示写入fenqu信息到磁盘
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true #不提示覆盖磁盘中已有数据
#############
# Packages
#############
# 这里目前我只能选择包组,没法制定具体某个安装包,不知道具体为什么。
tasksel tasksel/first multiselect openssh-server
# 禁止安装时自动更新
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
popularity-contest popularity-contest/participate boolean false
#############
# Users and Password
#############
#允许使用root登录
d-i passwd/root-login boolean true
# 不建立其他用户
d-i passwd/make-user boolean false
#允许使用弱密码
d-i user-setup/allow-password-weak boolean true
#配置root密码,通过mkpasswd程序生成
d-i passwd/root-password-crypted password $1$RsMBi5P0$bWmhi.I4MnZPmWFXpBEy0/
#############
# Bootloader
#############
d-i grub-installer/only_debian boolean true
d-i finish-install/reboot_in_progress note #安装完成后重启
#############
# 安装完成后执行脚本和命令
#############
#所有命令通过;分隔,如果使用一般命令可以直接执行,但此时真正的系统正被挂在载/target/下面,因此最终执行的目标是/target/下,如果想使用系统级的命令,如执行脚本等。需要通过chroor 到/target下,以target为根 才能正常执行,否则报错。
#第一个命令是修改ssh配置文件,使其允许root登录
#第二个命令是下载soures.list,该文件实现定义内部的apt源。
#第三个命令是去掉cobbler中system的自动引导,否则下次重启系统还会重新安装。
#第四个命令是下载并执行一个脚本,实现公钥注入功能。
#第五个命令是更新apt源,并安装指定的软件包。
#第六个命令则修改puppet配置文件和chrony时间服务的配置文件。
d-i preseed/late_command string \
sed -i '/PermitRootLogin / s/ .*/ yes/' /target/etc/ssh/sshd_config; \
wget http://$http_server/cobbler/repo_mirror/trusty-sources.list -O /target/etc/a pt/sources.list; \
wget http://$http_server/cblr/svc/op/nopxe/system/$system_name -O /dev/null; \
cd /target; \
wget http://$http_server/cobbler/svc/public_key.sh; chmod +x ./public_key.sh; chr oot ./ ./public_key.sh; \
chroot ./ apt-get update; \
chroot ./ apt-get install -y --force-yes vim chrony puppet; \
cd - ; \
sed -i '8 s/^.*/server=puppet-server.chinergy.com.cn/' /target/etc/puppet/puppet. conf; sed -i '4 s/^.*/server 1.1.1.1 iburst/' /target/etc/chrony/chrony.conf
|