Preseeding a Debian Squeeze install putting all volumes in LVM

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

Tags: , , , , , ,


4 Responses to “Preseeding a Debian Squeeze install putting all volumes in LVM”

  1. Instead of listing multiple disks, you can also use:
    d-i partman-auto/disk string /dev/*da

    or in your case:
    d-i partman-auto/disk string /dev/vd*

    Saz

  2. Bertjan says:

    Very useful information.

    Thanx !

  3. kevin says:

    Hi,

    I am trying to build two volume groups using Cobbler but failed.
    I can only see one volume group created.
    I also tried
    d-i partman-auto-lvm/new_vg_name string lxc exportvg
    and
    d-i partman-auto-lvm/new_vg_name multiselect lxc, exportvg
    but failed as well.
    What might be the issues?

    Regards,

    Kevin SZ

    d-i partman-auto/choose_recipe select custompartitioning
    d-i partman-auto-lvm/new_vg_name string lxc
    #d-i partman-auto-lvm/new_vg_name multiselect lxc exportvg
    d-i partman-auto/expert_recipe string \
    custompartitioning :: \
    512 1 512 ext2 \
    $primary{ } \
    $bootable{ } \
    method{ format } format{ } \
    use_filesystem{ } filesystem{ ext2 } \
    label{ boot } \
    mountpoint{ /boot } \
    . \
    155648 1 155648 ext4 \
    $primary{ } \
    method{ lvm } \
    device{ /dev/sda2 } \
    vg_name{ lxc } \
    . \
    2048 1 2048 linux-swap \
    $lvmok{ } in_vg{ lxc } \
    lv_name{ swap00 } \
    method{ swap } format{ } \
    . \
    153600 1 153600 ext4 \
    $lvmok{ } in_vg{ lxc } \
    lv_name{ root00 } \
    method{ format } format{ } \
    use_filesystem{ } filesystem{ ext4 } \
    label{ root } \
    mountpoint{ / } \
    . \
    102400 1 102400 ext4 \
    $primary{ } \
    method{ lvm } \
    device{ /dev/sda3 } \
    vg_name{ exportvg } \
    . \
    102400 1 102400 ext4 \
    $lvmok{ } in_vg{ exportvg } \
    lv_name{ app00 } \
    method{ format } format{ } \
    use_filesystem{ } filesystem{ ext4 } \
    label{ app } \
    mountpoint{ /app } \
    . \

  4. Tim Stoop says:

    Hi Kevin,

    We never were able to get two different VGs working correctly from the preseed. The way we handled it was by creating a large partition outside of the VG instead and making that the second VG in a post-install script. You can preseed that script (late-command), so at least it’s part of your installation procedure. Partman is pretty limited, but I guess that’s mostly because it wants to make sure to do the right thing in almost all cases.

    Do let me know if you’d like an example, I’ll have to dig a bit but I think we still have it somewhere.

Leave a Reply