In our quest to automate even more, we have further automated our installations. We use Debian and don’t want to answer any (except for IP and hostname) question in the debian installer by hand. We’ve already pre-seeded the installer with a lot of answers, but the partitioning was always hard.
Before, we formatted the first disk like this, and added any other disks to the volume group by hand:
1GB ext3: /boot
The rest is a physical volume for LVM
Debian Squeeze comes with GRUB2, which has the ability to boot linux from an LVM volume. This means that we can use all disks inside the same volume group. So we completely redid our debian installer preseed files. As we ran into some trouble with the partman portion of the installer, we blog that part of our preseed in the hope that it’ll be useful to others.
## Disk partitioning.
d-i partman-auto/method string lvm
d-i partman-auto/choose_recipe select kumina
# 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…
# FIXME Unfortunatly, it still errors, but we should install
# on used volumes anyway without zero’ing
d-i partman-lvm/device_remove_lvm boolean true
# The same applies to pre-existing software RAID array:
d-i partman-md/device_remove_md boolean true
# It’s ok to have /boot in the LVM
d-i partman-auto-lvm/no_boot boolean true
# Select all possible disks to use in the volume group
d-i partman-auto/disk string /dev/vda /dev/vdb /dev/vdc /dev/vdd /dev/vde /dev/vdf /dev/vdg /dev/vdh /dev/vdi /dev/vdj
# Name of the new LVM VG
d-i partman-auto-lvm/new_vg_name string vg
# Default partition schema.
d-i partman-auto/expert_recipe string \
kumina :: \
1024 1024 1024 linux-swap method{ swap } \
format{ } $lvmok{ } lv_name{ swap } \
. \
2048 2048 2048 ext4 method{ lvm } \
$lvmok{ } mountpoint{ / } lv_name{ root } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
. \
1024 1024 1024 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /tmp } lv_name{ tmp } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
options/nodev{ nodev } options/nosuid{ nosuid } \
. \
2048 2048 2048 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /home } lv_name{ home } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
options/nodev{ nodev } options/nosuid{ nosuid } \
. \
4096 4096 4096 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /var } lv_name{ var } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
. \
2048 2048 2048 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /srv } lv_name{ srv } \
format{ } use_filesystem{ } filesystem{ ext4 } \
options/relatime{ relatime } \
. \
1 2048 1000000000 ext4 method{ lvm } \
$lvmok{ } mountpoint{ /tmp/hack } lv_name{ hack } \
.
# This makes partman automatically partition without confirmation, provided
# that you told it what to do using one of the methods above.
d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select Finish
d-i partman/confirm_nooverwrite boolean true
d-i partman/confirm boolean true
As you can see we create a logical volume called hack. The debian installer allocates all remaining free space to the last volume defined. So we now end up with a huge, unformatted /dev/vg/hack. After the installation a script is run using the late_command in the preseed that performs an lvremove vg/hack
giving us a lot of free space in our volume group for future allocation.
To make sure the machine can boot we install grub on the first harddisk:
grub-installer grub-installer/bootdev string /dev/vda