Skip to content

Instantly share code, notes, and snippets.

@bunchc
Last active May 26, 2018 14:12
Show Gist options
  • Save bunchc/35288cbb11c58b254e8ed7b28dfcdb72 to your computer and use it in GitHub Desktop.
Save bunchc/35288cbb11c58b254e8ed7b28dfcdb72 to your computer and use it in GitHub Desktop.
Ubuntu preseed with raid support
#
# Ubuntu Server 16.04 Preseed
#
# Usage:
#
# This Ubuntu Preseed file is meant to be used when installing Ubuntu
# from the ISO. The following menus will require user input, everything
# after will be an unattended install:
#
# * Select a language
# * Select your location
# * Configure the keyboard
# * Configure the network
#
# References:
#
# https://help.ubuntu.com/16.04/installation-guide/example-preseed.txt
# http://www.claudiokuenzler.com/blog/513/debian-ubuntu-preseed-create-two-volume-groups-same-disk
#############
#
# 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
#############
#
# Localization
#
#############
d-i debian-installer/locale string en
d-i debian-installer/country string US
d-i debian-installer/locale string en_US.UTF-8
d-i debian-installer/language string en
#############
#
# Keyboard
#
#############
# Disable automatic (interactive) keymap detection.
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
#############
#
# Mirror
#
#############
d-i mirror/suite string xenial
d-i mirror/country string manual
d-i mirror/http/proxy string
d-i mirror/http/hostname string rackspace.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
#############
#
# Clock and Time Zone
#
#############
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
d-i clock-setup/ntp-server string ntp.ubuntu.com
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string US/Central
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
### Partitioning
# If the system has free space you can choose to only partition that space.
#d-i partman-auto/init_automatically_partition select biggest_free
# Alternatively, you can specify a disk to partition. The device name must
# be given in traditional non-devfs format.
# Note: A disk must be specified, unless the system has only one disk.
# For example, to use the first SCSI/SATA hard disk:
d-i partman-auto/disk string /dev/sdb /dev/sdc
# In addition, you'll need to specify the method to use.
# The presently available methods are: "regular"
# 2009-10-20 14:30 EDT
# LM: do not use "lvm" here as it breaks newer d-i
d-i partman-auto/method string raid
# If one of the disks that are going to be automatically partitioned
# contains an old LVM configuration, the user will normally receive a
# warning. This can be preseeded away...
# This makes partman automatically partition without confirmation.
# Write the changes to the storage devices and configure RAID?
d-i partman-md/confirm boolean true
# Write a new empty partition table?
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/confirm_write_new_label boolean true
# Remove existing software RAID partitions?
d-i partman-md/device_remove_md boolean true
# Write the changes to disks and configure LVM?
d-i partman-lvm/confirm boolean true
d-i partman/choose_partition select finish
d-i partman/confirm_nooverwrite boolean true
d-i partman-md/confirm_nooverwrite boolean true
# Write the changes to disks?
d-i partman/confirm boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_lvm_span boolean true
d-i partman-auto-lvm/new_vg_name string bootdisk
d-i partman-auto-lvm/guided_size string max
# Notes:
# - partitions are created in the order they are defined
# - higher priority takes precendence
# - highest priority number chosen is 5,000
# - very impotant!! do not leave spaces after \ or it won't work
# RAID:
# /dev/md0 -> /boot -> 100M - 256MB (high priority)
# /dev/md1 -> LVM VG bootdisk -> 500M - 1T (high priority)
# LVM:
# /dev/mapper/bootdisk-root -> / -> 5G - 200G (high priority)
# /dev/mapper/bootdisk-swap_1 -> swap -> 4.5G
# Note: having 300% yielded wrong 276G instead of
# 3 times size of RAM (high priority)
# bootdisk volgroup has extra free space
#
# Last you need to specify how the previously defined partitions will be
# used in the RAID setup. Remember to use the correct partition numbers
# for logical partitions.
# Parameters are:
# <raidtype> <devcount> <sparecount> <fstype> <mountpoint> \
# <devices> <sparedevices>
# RAID levels 0, 1, 5, 6 and 10 are supported; devices are separated using "#"
d-i partman-auto-raid/recipe string \
1 2 0 xfs /boot /dev/sdb1#/dev/sdc1 . 0 2 0 lvm / /dev/sdb5#/dev/sdc5 .
# RAID partitions are tagged as "lvmignore"
# and LVM logical volumes as "defaultignore" and "lvmok"
d-i partman-auto/expert_recipe string \
multiraid :: \
100 512 256 raid $lvmignore{ } $primary{ } method{ raid } . \
900 5000 1000000000 raid $lvmignore{ } method{ raid } . \
8192 5000 1000000000 xfs $defaultignore{ } $lvmok{ } \
method{ format } format{ } use_filesystem{ } filesystem{ xfs } \
options/relatime{ relatime } mountpoint{ / } . \
256 3000 4500 linux-swap $defaultignore{ } $lvmok{ } method{ swap } format{ } .
#############
#
# Packages
#
#############
# Package selection
tasksel tasksel/first multiselect openssh-server
# Individual additional packages to install
d-i pkgsel/include string vim git python-pip ethtool bmon wget curl
# Whether to upgrade packages after debootstrap.
# Allowed values: none, safe-upgrade, full-upgrade
d-i pkgsel/upgrade select none
# Policy for applying updates. May be "none" (no automatic updates),
# "unattended-upgrades" (install security updates automatically), or
# "landscape" (manage system with Landscape).
d-i pkgsel/update-policy select none
# Some versions of the installer can report back on what software you have
# installed, and what software you use. The default is not to report back,
# but sending reports helps the project determine what software is most
# popular and include it on CDs.
popularity-contest popularity-contest/participate boolean false
#############
#
# Users and Password
#
#############
# Skip creation of a root account (normal user account will be able to
# use sudo). The default is false; preseed this to true if you want to set
# a root password.
d-i passwd/root-login boolean true
# Alternatively, to skip creation of a normal user account.
d-i passwd/make-user boolean false
# The installer will warn about weak passwords. If you are sure you know
# what you're doing and want to override it, uncomment this.
d-i user-setup/allow-password-weak boolean true
# Root password, either in clear text
d-i passwd/root-password password number-Three-03
d-i passwd/root-password-again password number-Three-03
#############
#
# Bootloader
#
#############
# This is fairly safe to set, it makes grub install automatically to the MBR
# if no other operating system is detected on the machine.
d-i grub-installer/only_debian boolean true
d-i grub-installer/bootdev string (hd0,0) (hd1,0)
#############
#
# Post Install
#
#############
# Command Line 1: Allow root to SSH.
d-i preseed/late_command string \
sed -i '/PermitRootLogin / s/ .*/ yes/' /target/etc/ssh/sshd_config
#############
#
# Finish
#
#############
# Reboot after the install is finished.
finish-install finish-install/reboot_in_progress note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment