Using d-i partman recipe strings?

I figured this out after spending days scouring the internet for any shred of information about partman - it is not very well-documented at all. Here's the config I used:

# This automatically creates a standard unencrypted partitioning scheme.
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
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-lvm/confirm_nooverwrite boolean true
d-i partman-auto/choose_recipe select unencrypted-install
d-i partman-auto/expert_recipe string \
        unencrypted-install :: \
                1024 1024 1024 ext4 \
                        $primary{ } $bootable{ } \
                        method{ format } format{ } \
                        use_filesystem{ } filesystem{ ext4 } \
                        mountpoint{ /boot } \
                . \
                2048 2048 2048 linux-swap \
                        $primary{ } \
                        method{ swap } format{ } \
                . \
                17408 100000000000 -1 ext4 \
                        $primary{ } \
                        method{ format } format{ } \
                        use_filesystem{ } filesystem{ ext4 } \
                        mountpoint{ / } \
                .
d-i partman-md/confirm boolean true
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true

Just drop that in your preseed and you should be good to go. Line by line:

  • Use disk /dev/sda
  • Do a regular install (not encrypted or LVM)
  • Remove any existing LVM without prompting
  • Remove any existing RAID setup without prompting
  • Confirm that this is what you want
  • Confirm again
  • Select the "unencrypted-install" recipe, which is specified below
  • This is a single logical line that specifies the entire recipe, one partition at a time. It creates the partition table exactly as I specified in the question.
  • Confirm again
  • Allow partman to write new labels
  • Finish the process
  • Confirm again
  • Confirm again

And there you go, works perfect.


I know that this is an old post but I am not sure if hard coding /dev/sda is a good idea. Instead, I'd use something similar to

d-i partman/early_command string \
    USBDEV=$(list-devices usb-partition | sed "s/\(.*\)./\1/");\
    if [ ! -z "$USBDEV" ]; then \
        BOOTDEV=$(list-devices disk | grep -v "$USBDEV" | head -1);\
    else \
        BOOTDEV=$(list-devices disk | head -1);\
    fi; \
    debconf-set partman-auto/disk $BOOTDEV;\
    debconf-set grub-installer/bootdev $BOOTDEV;\
    lvremove --select all -ff -y; vgremove --select all -ff -y; pvremove ${BOOTDEV}* -ff -y

To make sure that the first internal drive is used as the installation medium and any possible external usb drive is excluded as the enumeration order might change dynamically.