Ubuntu – Preseeding Ubuntu partman recipe using LVM and RAID

lvmpartitionpreseedraidUbuntu

I'm trying to preseed Ubuntu 12.04 server installation and created a recipe that would create RAID 1 on 2 drives and then partition that using LVM. Unfortunately partman complains when creating LVM volumes saying there no partitions in recipe that could be used with LVM (in console it complains about unusable recipe).

The layout I'm after is RAID 1 on sdb and sdc (installing from USB stick so it takes sda) and then use LVM to create boot, root and swap.

The odd thing is that if I change the mount point of boot_lv to home the recipe works fine (apart from mounting in wrong place), but when mounting at /boot it fails

I know I could use separate /boot primary partition, but can anybody tell me why it fails. Recipe and relevant options below.

## Partitioning using RAID
d-i     partman-auto/disk string /dev/sdb /dev/sdc
d-i     partman-auto/method string raid
d-i     partman-lvm/device_remove_lvm boolean true
d-i     partman-md/device_remove_md boolean true
#d-i     partman-lvm/confirm boolean true
d-i     partman-auto-lvm/new_vg_name string main_vg
d-i partman-auto/expert_recipe string           \
    multiraid ::                    \
        100 512 -1 raid         \
            $lvmignore{ }           \
            $primary{ }         \
            method{ raid }          \
        .                   \
        256 512 256 ext3            \
            $defaultignore{ }       \
            $lvmok{ }           \
            method{ format }        \
            format{ }           \
            use_filesystem{ }       \
            filesystem{ ext3 }      \
            mountpoint{ /boot }     \
            lv_name{ boot_lv }      \
        .                   \
        2000 5000 -1 ext4           \
            $defaultignore{ }       \
            $lvmok{ }           \
            method{ format }        \
            format{ }           \
            use_filesystem{ }       \
            filesystem{ ext4 }      \
            mountpoint{ / }         \
            lv_name{ root_lv }      \
        .                   \
        64 512 300% linux-swap          \
            $defaultignore{ }       \
            $lvmok{ }           \
            method{ swap }          \
            format{ }           \
            lv_name{ swap_lv }      \
        .

d-i partman-auto-raid/recipe string \
    1 2 0 lvm -                     \
          /dev/sdb1#/dev/sdc1       \
    .                               
d-i     mdadm/boot_degraded boolean true
#d-i     partman-md/confirm boolean true
#d-i     partman-partitioning/confirm_write_new_label boolean true
#d-i     partman/choose_partition select Finish partitioning and write changes to disk
#d-i     partman/confirm boolean true
#d-i     partman-md/confirm_nooverwrite  boolean true
#d-i     partman/confirm_nooverwrite boolean true 

Best Answer

After a bit of googling I found below snippet of code from partman-auto-lvm, it seems that if lvm recipe detects /boot partition on LVM it will bail out although it's perfectly possible to have /boot on LVM. According to my research, before GRUB 2 you couldn't boot from LVM so you needed separate primary boot partition.

# Make sure a boot partition isn't marked as lvmok
if echo "$scheme" | grep lvmok | grep -q "[[:space:]]/boot[[:space:]]"; then
     bail_out unusable_recipe
fi

A workaround would be to specify no mount point and do it manually from setup screens, which defeats the purpose of unattended install to some degree.