Unattended installation requires what is called an answer file, often spelled answerfile.
It is an XML file that contains the answers to questions the installer would ask during a manual installation.
Here's an example:
<?xml version="1.0"?>
<installation srtype="ext">
<primary-disk>sda</primary-disk>
<guest-disk>sdb</guest-disk>
<guest-disk>sdc</guest-disk>
<keymap>us</keymap>
<root-password>mypassword</root-password>
<source type="url">http://pxehost.example.com/xcp-ng/</source>
<post-install-script type="url">
http://pxehost.example.com/myscripts/post-install-script
</post-install-script>
<admin-interface name="eth0" proto="dhcp" />
<timezone>Europe/Paris</timezone>
</installation>
TIP
• Check the full answerfile reference.
Via PXE
Follow the previous section on Network boot (PXE) and add options to that will fetch and use an answer file.
PXE unattended install - BIOS boot
Add answerfile=http://your_server/path/to/answerfile.xml install
to the parameters passed to vmlinuz
(the linux kernel of the installer).
Example:
menuentry "XCP-ng Install (serial)" {
multiboot2 /EFI/xcp-ng/xen.gz dom0_mem=2048M,max:2048M watchdog dom0_max_vcpus=4 com1=115200,8n1 console=com1,vga
module2 /EFI/xcp-ng/vmlinuz console=hvc0 console=tty0 answerfile_device=eth0 answerfile=http://your_server/path/to/answerfile.xml install
module2 /EFI/xcp-ng/install.img
}
Unattended installation with a custom ISO image
You may build a custom installation image that will automatically install XCP-ng. The answerfile can either be downloaded by the installer or embedded in the image itself.
Unattended installation ISO with remote config
If you can't or don't want to setup PXE but can still serve a file (the answerfile) from a server that will be available to the hosts during installation, you can create an automated installation image that will fetch its configuration from the network.
- For BIOS boot, edit
/boot/isolinux/isolinux.cfg
.- Locate the
install
boot entry, which should look like this:
LABEL install KERNEL mboot.c32 APPEND /boot/xen.gz dom0_max_vcpus=1-16 dom0_mem=max:8192M com1=115200,8n1 console=com1,vga --- /boot/vmlinuz console=hvc0 console=tty0 --- /install.img
- Append
answerfile=http://your_server/path/to/answerfile.xml install
to the parameters passed to vmlinuz, before the last---
:
LABEL install KERNEL mboot.c32 APPEND /boot/xen.gz dom0_max_vcpus=1-16 dom0_mem=max:8192M com1=115200,8n1 console=com1,vga --- /boot/vmlinuz console=hvc0 console=tty0 answerfile=http://your_server/path/to/answerfile.xml install --- /install.img
- Locate the
- For UEFI boot edit
/EFI/xenserver/grub.cfg
(and/EFI/xenserver/grub-usb.cfg
for USB installation).- Locate the
install
menuentry, which should look like this:
menuentry "install" { multiboot2 /boot/xen.gz dom0_max_vcpus=1-16 dom0_mem=max:8192M com1=115200,8n1 console=com1,vga module2 /boot/vmlinuz console=hvc0 console=tty0 module2 /install.img }
- Append
answerfile=http://your_server/path/to/answerfile.xml install
to the parameters passed to vmlinuz, in the line that starts withmodule2 /boot/vmlinuz
:
menuentry "install" { multiboot2 /boot/xen.gz dom0_max_vcpus=1-16 dom0_mem=max:8192M com1=115200,8n1 console=com1,vga module2 /boot/vmlinuz console=hvc0 console=tty0 answerfile=http://your_server/path/to/answerfile.xml install module2 /install.img }
- Locate the
-
- Append
answerfile=file:///answerfile.xml install
to the parameters passed to vmlinuz, in the line that starts withmodule2 /boot/vmlinuz
:
menuentry "install" { multiboot2 /boot/xen.gz dom0_max_vcpus=1-16 dom0_mem=max:8192M com1=115200,8n1 console=com1,vga module2 /boot/vmlinuz console=hvc0 console=tty0 answerfile=file:///answerfile.xml install module2 /install.img }
- Append
5. Add your answerfile
cp answerfile.xml "$WORK_DIR/install/answerfile.xml"
7. Build a new ISO with your changes
Your ISO is ready for installation.
Software RAID in answerfile
For an automated install using an answer file, software raid can be enabled as follows:
<?xml version="1.0"?>
<installation mode="fresh" srtype="lvm">
<raid device="md127">
<disk>sda</disk>
<disk>sdb</disk>
</raid>
<primary-disk>md127</primary-disk>
<keymap>us</keymap>
<source type="url">https://xcp-ng.org/install/</source>
<admin-interface name="eth0" proto="dhcp" />
<timezone>Europe/London</timezone>
<root-password>secret</root-password>
</installation>
As an improvement and to delay the md
resync (increasing install speed by about 500% on certain drives), we can use the following in the answer file:
<script stage="installation-start" type="url">http://your-server/noresync.sh</script>
The noresync.sh
script would do something like this:
#!/bin/sh
echo 0 > /proc/sys/dev/raid/speed_limit_max
echo 0 > /proc/sys/dev/raid/speed_limit_min
Upon server reboot, normal md
resync will take place.