Project

General

Profile

Preseed » History » Version 6

Laurent GUERBY, 06/16/2015 07:13 PM

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