Projet

Général

Profil

Preseed » Historique » Version 4

Mehdi Abaakouk, 16/06/2015 19:08

1 1 Laurent GUERBY
{{>toc}}
2 1 Laurent GUERBY
3 1 Laurent GUERBY
h1. Preseed
4 1 Laurent GUERBY
5 1 Laurent GUERBY
h2. Documentation
6 1 Laurent GUERBY
7 1 Laurent GUERBY
This page document a preseed setup in an environment where you already have a DHCP server. The idea is to add a PXE server that will do only the PXE part of the work.
8 1 Laurent GUERBY
9 1 Laurent GUERBY
Assuming :
10 1 Laurent GUERBY
* on the PXE server : apt-get install dnsmasq 
11 1 Laurent GUERBY
* you have a DHCP (no PXE) server at 10.2.255.254
12 1 Laurent GUERBY
* your PXE server interface is eth0
13 1 Laurent GUERBY
* your PXE server IP on eth0 is 10.2.137.101
14 1 Laurent GUERBY
* you have an http proxy which will be useful to cache locally all downloaded packages, here : http://cache.ut-capitole.fr:3128
15 1 Laurent GUERBY
16 1 Laurent GUERBY
h2. Files
17 1 Laurent GUERBY
18 2 Laurent GUERBY
h3. dnsmasq
19 2 Laurent GUERBY
20 1 Laurent GUERBY
<pre>
21 1 Laurent GUERBY
root@c1:~# cat /etc/dnsmasq.d/pxeu.conf
22 1 Laurent GUERBY
# disable dns
23 1 Laurent GUERBY
port=0
24 1 Laurent GUERBY
25 1 Laurent GUERBY
interface=eth0
26 1 Laurent GUERBY
27 1 Laurent GUERBY
# replace with real dhcp server
28 1 Laurent GUERBY
#dhcp-range=192.168.1.0,proxy
29 1 Laurent GUERBY
dhcp-range=10.2.255.254,proxy
30 1 Laurent GUERBY
31 1 Laurent GUERBY
# Tell PXE clients not to use multicast discovery
32 1 Laurent GUERBY
dhcp-option=vendor:PXEClient,6,2b
33 1 Laurent GUERBY
dhcp-no-override
34 1 Laurent GUERBY
35 1 Laurent GUERBY
# Enable this for better debugging
36 1 Laurent GUERBY
#log-dhcp
37 1 Laurent GUERBY
38 1 Laurent GUERBY
enable-tftp
39 1 Laurent GUERBY
tftp-root=/var/lib/tftpboot
40 1 Laurent GUERBY
pxe-service=x86PC, "Install Linux", pxelinux
41 1 Laurent GUERBY
</pre>
42 1 Laurent GUERBY
43 2 Laurent GUERBY
h3. tftpboot
44 2 Laurent GUERBY
45 2 Laurent GUERBY
Run the following script:
46 2 Laurent GUERBY
47 1 Laurent GUERBY
<pre>
48 1 Laurent GUERBY
root@c1:~# cat pxe-setup.sh 
49 1 Laurent GUERBY
#!/bin/bash
50 1 Laurent GUERBY
set -x
51 1 Laurent GUERBY
 
52 1 Laurent GUERBY
YOURMIRROR=archive.ubuntu.com
53 1 Laurent GUERBY
ARCH=amd64
54 1 Laurent GUERBY
VENDOR=ubuntu
55 1 Laurent GUERBY
DIST=trusty
56 1 Laurent GUERBY
DEST=/var/lib/tftpboot
57 1 Laurent GUERBY
 
58 1 Laurent GUERBY
mkdir -p $DEST
59 1 Laurent GUERBY
cd $DEST
60 1 Laurent GUERBY
 
61 1 Laurent GUERBY
rm -rf netboot.tar.gz Release* SHA* ${VENDOR}-installer version.info pxelinux.0 pxelinux.cfg ldlinux.c32
62 1 Laurent GUERBY
wget -q http://"$YOURMIRROR"/${VENDOR}/dists/${DIST}/main/installer-"$ARCH"/current/images/netboot/netboot.tar.gz
63 1 Laurent GUERBY
wget -q http://"$YOURMIRROR"/${VENDOR}/dists/${DIST}/main/installer-"$ARCH"/current/images/SHA256SUMS
64 1 Laurent GUERBY
wget -q http://"$YOURMIRROR"/${VENDOR}/dists/${DIST}/Release
65 1 Laurent GUERBY
wget -q http://"$YOURMIRROR"/${VENDOR}/dists/${DIST}/Release.gpg
66 1 Laurent GUERBY
tar -xzf netboot.tar.gz
67 1 Laurent GUERBY
</pre>
68 1 Laurent GUERBY
69 2 Laurent GUERBY
h3. preseed.cfg
70 2 Laurent GUERBY
71 1 Laurent GUERBY
<pre>
72 1 Laurent GUERBY
root@c1:/var/lib/tftpboot# cat preseed.cfg
73 1 Laurent GUERBY
### Localization
74 1 Laurent GUERBY
# Preseeding only locale sets language, country and locale.
75 1 Laurent GUERBY
d-i debian-installer/locale string en_US.UTF-8
76 1 Laurent GUERBY
77 1 Laurent GUERBY
# Keyboard selection.
78 1 Laurent GUERBY
# Disable automatic (interactive) keymap detection.
79 1 Laurent GUERBY
d-i console-setup/ask_detect boolean false
80 1 Laurent GUERBY
d-i keyboard-configuration/layoutcode string fr
81 1 Laurent GUERBY
82 1 Laurent GUERBY
### Network configuration
83 1 Laurent GUERBY
# netcfg will choose an interface that has link if possible. This makes it
84 1 Laurent GUERBY
# skip displaying a list if there is more than one interface.
85 1 Laurent GUERBY
d-i netcfg/choose_interface select auto
86 1 Laurent GUERBY
87 1 Laurent GUERBY
# Just in case our DHCP server is busy.
88 1 Laurent GUERBY
d-i netcfg/dhcp_timeout string 60
89 1 Laurent GUERBY
90 1 Laurent GUERBY
# Any hostname and domain names assigned from dhcp take precedence over
91 1 Laurent GUERBY
# values set here. However, setting the values still prevents the questions
92 1 Laurent GUERBY
# from being shown, even if values come from dhcp.
93 1 Laurent GUERBY
d-i netcfg/get_hostname string unassigned-hostname
94 1 Laurent GUERBY
d-i netcfg/get_domain string unassigned-domain
95 1 Laurent GUERBY
96 1 Laurent GUERBY
# Disable that annoying WEP key dialog.
97 1 Laurent GUERBY
d-i netcfg/wireless_wep string
98 1 Laurent GUERBY
99 1 Laurent GUERBY
# Always install the server kernel
100 1 Laurent GUERBY
d-i	base-installer/kernel/override-image string linux-server
101 1 Laurent GUERBY
102 1 Laurent GUERBY
### Mirror settings
103 1 Laurent GUERBY
# Alternatively: by default, the installer uses CC.archive.ubuntu.com where
104 1 Laurent GUERBY
# CC is the ISO-3166-2 code for the selected country. You can preseed this
105 1 Laurent GUERBY
# so that it does so without asking.
106 1 Laurent GUERBY
d-i mirror/http/mirror select archive.ubuntu.com
107 1 Laurent GUERBY
d-i mirror/http/proxy string http://cache.ut-capitole.fr:3128
108 1 Laurent GUERBY
109 1 Laurent GUERBY
### Clock and time zone setup
110 1 Laurent GUERBY
# Controls whether or not the hardware clock is set to UTC.
111 1 Laurent GUERBY
d-i clock-setup/utc boolean true
112 1 Laurent GUERBY
113 1 Laurent GUERBY
# You may set this to any valid setting for $TZ; see the contents of
114 1 Laurent GUERBY
# /usr/share/zoneinfo/ for valid values.
115 1 Laurent GUERBY
d-i time/zone string Etc/UTC
116 1 Laurent GUERBY
117 1 Laurent GUERBY
# Controls whether to use NTP to set the clock during the install
118 1 Laurent GUERBY
d-i clock-setup/ntp boolean true
119 1 Laurent GUERBY
120 1 Laurent GUERBY
### Partitioning
121 1 Laurent GUERBY
d-i partman-auto/disk string /dev/sda
122 1 Laurent GUERBY
123 1 Laurent GUERBY
# The presently available methods are:
124 1 Laurent GUERBY
# - regular: use the usual partition types for your architecture
125 1 Laurent GUERBY
# - lvm:     use LVM to partition the disk
126 1 Laurent GUERBY
# - crypto:  use LVM within an encrypted partition
127 1 Laurent GUERBY
d-i partman-auto/method string regular
128 1 Laurent GUERBY
129 1 Laurent GUERBY
# If one of the disks that are going to be automatically partitioned
130 1 Laurent GUERBY
# contains an old LVM configuration, the user will normally receive a
131 1 Laurent GUERBY
# warning. This can be preseeded away...
132 1 Laurent GUERBY
d-i partman-lvm/device_remove_lvm boolean true
133 1 Laurent GUERBY
# The same applies to pre-existing software RAID array:
134 1 Laurent GUERBY
d-i partman-md/device_remove_md boolean true
135 1 Laurent GUERBY
# And the same goes for the confirmation to write the lvm partitions.
136 1 Laurent GUERBY
d-i partman-lvm/confirm boolean true
137 1 Laurent GUERBY
138 1 Laurent GUERBY
# For LVM partitioning, you can select how much of the volume group to use
139 1 Laurent GUERBY
# for logical volumes.
140 1 Laurent GUERBY
#d-i partman-auto-lvm/guided_size string max
141 1 Laurent GUERBY
142 1 Laurent GUERBY
# You can choose one of the three predefined partitioning recipes:
143 1 Laurent GUERBY
# - atomic: all files in one partition
144 1 Laurent GUERBY
# - home:   separate /home partition
145 1 Laurent GUERBY
# - multi:  separate /home, /usr, /var, and /tmp partitions
146 1 Laurent GUERBY
# d-i partman-auto/choose_recipe select atomic
147 1 Laurent GUERBY
d-i partman-auto/expert_recipe string root :: 2048 30720 20000000 ext4 \
148 1 Laurent GUERBY
			$primary{ } $bootable{ } \
149 1 Laurent GUERBY
			method{ format } format{ } \
150 1 Laurent GUERBY
			use_filesystem{ } filesystem{ ext4 } \
151 1 Laurent GUERBY
			mountpoint{ / } .
152 1 Laurent GUERBY
153 1 Laurent GUERBY
partman-basicfilesystems partman-basicfilesystems/no_swap boolean false
154 1 Laurent GUERBY
d-i partman-basicfilesystems partman-basicfilesystems/no_swap boolean false 
155 1 Laurent GUERBY
156 1 Laurent GUERBY
# If you just want to change the default filesystem from ext3 to something
157 1 Laurent GUERBY
# else, you can do that without providing a full recipe.
158 1 Laurent GUERBY
d-i partman/default_filesystem string ext4
159 1 Laurent GUERBY
160 1 Laurent GUERBY
# This makes partman automatically partition without confirmation, provided
161 1 Laurent GUERBY
# that you told it what to do using one of the methods above.
162 1 Laurent GUERBY
d-i partman-partitioning/confirm_write_new_label boolean true
163 1 Laurent GUERBY
d-i partman/choose_partition select finish
164 1 Laurent GUERBY
d-i partman/confirm boolean true
165 1 Laurent GUERBY
d-i partman/confirm_nooverwrite boolean true
166 1 Laurent GUERBY
167 1 Laurent GUERBY
### Base system installation
168 1 Laurent GUERBY
### Account setup
169 1 Laurent GUERBY
170 1 Laurent GUERBY
d-i passwd/root-password password root
171 1 Laurent GUERBY
d-i passwd/root-password-again password root
172 1 Laurent GUERBY
173 1 Laurent GUERBY
# To create a normal user account.
174 1 Laurent GUERBY
d-i passwd/user-fullname string guest
175 1 Laurent GUERBY
d-i passwd/username string guest
176 1 Laurent GUERBY
d-i passwd/user-password password guest
177 1 Laurent GUERBY
d-i passwd/user-password-again password guest
178 1 Laurent GUERBY
179 1 Laurent GUERBY
180 1 Laurent GUERBY
181 1 Laurent GUERBY
# The installer will warn about weak passwords. If you are sure you know
182 1 Laurent GUERBY
# what you're doing and want to override it, uncomment this.
183 1 Laurent GUERBY
d-i user-setup/allow-password-weak boolean true
184 1 Laurent GUERBY
185 1 Laurent GUERBY
# Set to true if you want to encrypt the first user's home directory.
186 1 Laurent GUERBY
d-i user-setup/encrypt-home boolean false
187 1 Laurent GUERBY
188 1 Laurent GUERBY
### Apt setup
189 1 Laurent GUERBY
# You can choose to install restricted and universe software, or to install
190 1 Laurent GUERBY
# software from the backports repository.
191 1 Laurent GUERBY
#d-i apt-setup/restricted boolean true
192 1 Laurent GUERBY
#d-i apt-setup/universe boolean true
193 1 Laurent GUERBY
#d-i apt-setup/backports boolean true
194 1 Laurent GUERBY
# Uncomment this if you don't want to use a network mirror.
195 1 Laurent GUERBY
#d-i apt-setup/use_mirror boolean false
196 1 Laurent GUERBY
# Select which update services to use; define the mirrors to be used.
197 1 Laurent GUERBY
# Values shown below are the normal defaults.
198 1 Laurent GUERBY
#d-i apt-setup/services-select multiselect security
199 1 Laurent GUERBY
#d-i apt-setup/security_host string security.ubuntu.com
200 1 Laurent GUERBY
#d-i apt-setup/security_path string /ubuntu
201 1 Laurent GUERBY
202 1 Laurent GUERBY
# Additional repositories, local[0-9] available
203 1 Laurent GUERBY
#d-i apt-setup/local0/repository string \
204 1 Laurent GUERBY
#       http://local.server/ubuntu squeeze main
205 1 Laurent GUERBY
#d-i apt-setup/local0/comment string local server
206 1 Laurent GUERBY
# Enable deb-src lines
207 1 Laurent GUERBY
#d-i apt-setup/local0/source boolean true
208 1 Laurent GUERBY
# URL to the public key of the local repository; you must provide a key or
209 1 Laurent GUERBY
# apt will complain about the unauthenticated repository and so the
210 1 Laurent GUERBY
# sources.list line will be left commented out
211 1 Laurent GUERBY
#d-i apt-setup/local0/key string http://local.server/key
212 1 Laurent GUERBY
213 1 Laurent GUERBY
### Package selection
214 1 Laurent GUERBY
tasksel	tasksel/force-tasks	string standard,server,desktop
215 1 Laurent GUERBY
tasksel tasksel/first multiselect standard,server,desktop
216 1 Laurent GUERBY
217 1 Laurent GUERBY
# Individual additional packages to install
218 1 Laurent GUERBY
d-i pkgsel/include string openssh-server tftp-hpa software-properties-common python-apt python-pycurl python-setuptools
219 1 Laurent GUERBY
# Whether to upgrade packages after debootstrap.
220 1 Laurent GUERBY
# Allowed values: none, safe-upgrade, full-upgrade
221 1 Laurent GUERBY
d-i pkgsel/upgrade select full-upgrade
222 1 Laurent GUERBY
223 1 Laurent GUERBY
# Language pack selection
224 1 Laurent GUERBY
d-i pkgsel/language-packs multiselect en
225 1 Laurent GUERBY
226 1 Laurent GUERBY
# No language support packages
227 1 Laurent GUERBY
d-i	pkgsel/install-language-support	boolean false
228 1 Laurent GUERBY
229 1 Laurent GUERBY
# Policy for applying updates. May be "none" (no automatic updates),
230 1 Laurent GUERBY
# "unattended-upgrades" (install security updates automatically), or
231 1 Laurent GUERBY
# "landscape" (manage system with Landscape).
232 1 Laurent GUERBY
d-i pkgsel/update-policy select unattended-upgrades
233 1 Laurent GUERBY
234 1 Laurent GUERBY
# Verbose output and no boot splash screen
235 1 Laurent GUERBY
d-i	debian-installer/quiet	boolean false
236 1 Laurent GUERBY
d-i	debian-installer/splash	boolean false
237 1 Laurent GUERBY
238 1 Laurent GUERBY
### Boot loader installation
239 1 Laurent GUERBY
# This is fairly safe to set, it makes grub install automatically to the MBR
240 1 Laurent GUERBY
# if no other operating system is detected on the machine.
241 1 Laurent GUERBY
d-i grub-installer/only_debian boolean true
242 1 Laurent GUERBY
243 1 Laurent GUERBY
# This one makes grub-installer install to the MBR if it also finds some other
244 1 Laurent GUERBY
# OS, which is less safe as it might not be able to boot that other OS.
245 1 Laurent GUERBY
d-i grub-installer/with_other_os boolean true
246 1 Laurent GUERBY
247 1 Laurent GUERBY
# Wait for two seconds in grub
248 1 Laurent GUERBY
d-i	grub-installer/timeout string 2
249 1 Laurent GUERBY
250 1 Laurent GUERBY
# Use the following option to add additional boot parameters for the
251 1 Laurent GUERBY
# installed system (if supported by the bootloader installer).
252 1 Laurent GUERBY
# Note: options passed to the installer will be added automatically.
253 1 Laurent GUERBY
# d-i debian-installer/add-kernel-opts string vga=normal nomodeset audit=0 intel_idle.max_cstate=0 processor.max_cstate=1 cgroup_enable=memory swapaccount=1
254 1 Laurent GUERBY
255 1 Laurent GUERBY
### Finishing up the installation
256 1 Laurent GUERBY
# Avoid that last message about the install being complete.
257 1 Laurent GUERBY
d-i finish-install/reboot_in_progress note
258 1 Laurent GUERBY
259 1 Laurent GUERBY
#### Advanced options
260 1 Laurent GUERBY
### Running custom commands during the installation
261 1 Laurent GUERBY
# d-i preseeding is inherently not secure. Nothing in the installer checks
262 1 Laurent GUERBY
# for attempts at buffer overflows or other exploits of the values of a
263 1 Laurent GUERBY
# preconfiguration file like this one. Only use preconfiguration files from
264 1 Laurent GUERBY
# trusted locations! To drive that home, and because it's generally useful,
265 1 Laurent GUERBY
# here's a way to run any shell command you'd like inside the installer,
266 1 Laurent GUERBY
# automatically.
267 1 Laurent GUERBY
268 1 Laurent GUERBY
# This first command is run as early as possible, just after
269 1 Laurent GUERBY
# preseeding is read.
270 1 Laurent GUERBY
#d-i preseed/early_command string anna-install some-udeb
271 1 Laurent GUERBY
# This command is run immediately before the partitioner starts. It may be
272 1 Laurent GUERBY
# useful to apply dynamic partitioner preseeding that depends on the state
273 1 Laurent GUERBY
# of the disks (which may not be visible when preseed/early_command runs).
274 1 Laurent GUERBY
#d-i partman/early_command \
275 1 Laurent GUERBY
#       string debconf-set partman-auto/disk "$(list-devices disk | head -n1)"
276 1 Laurent GUERBY
# This command is run just before the install finishes, but when there is
277 1 Laurent GUERBY
# still a usable /target directory. You can chroot to /target and use it
278 1 Laurent GUERBY
# directly, or use the apt-install and in-target commands to easily install
279 1 Laurent GUERBY
# packages and run commands in the target system.
280 1 Laurent GUERBY
#d-i preseed/late_command string \
281 1 Laurent GUERBY
#    in-target tftp 172.16.0.1 -c get postpreseed.sh; \
282 1 Laurent GUERBY
#    in-target chmod +x postpreseed.sh; \
283 1 Laurent GUERBY
#    in-target /bin/bash -x postpreseed.sh; \
284 1 Laurent GUERBY
#    in-target rm -f postpreseed.sh;
285 1 Laurent GUERBY
</pre>
286 2 Laurent GUERBY
287 3 Laurent GUERBY
h3. default
288 3 Laurent GUERBY
289 3 Laurent GUERBY
<pre>
290 3 Laurent GUERBY
root@c1:/var/lib/tftpboot/pxelinux.cfg# cat default 
291 3 Laurent GUERBY
DEFAULT ubuntu-installer/amd64/boot-screens/vesamenu.c32
292 3 Laurent GUERBY
293 3 Laurent GUERBY
label Boot local disk
294 3 Laurent GUERBY
	LOCALBOOT 0x80
295 3 Laurent GUERBY
296 3 Laurent GUERBY
label install
297 3 Laurent GUERBY
	kernel ubuntu-installer/amd64/linux
298 3 Laurent GUERBY
	append auto=true priority=critical initrd=ubuntu-installer/amd64/initrd.gz locale=en_GB.UTF-8 kbd-chooser/method=gb netcfg/choose_interface=auto url=tftp://10.2.137.101/preseed.cfg
299 3 Laurent GUERBY
</pre>