Projet

Général

Profil

Preseed » Historique » Version 1

Laurent GUERBY, 16/06/2015 19:02

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