3

I want to automatically partition all of my workstations in the same way:

  • First partition is a bootable 1GB ext4 /boot partition
  • Second partition is a 2GB swap partition
  • Third partition is an ext4 / partition that takes up whatever is left
  • All partitions should be formatted

I think adding this to my preseed.cfg will accomplish what I want:

d-i partman-auto/workstation_recipe string \
    root :: \
        1024 1023 1024 ext4 \
            $primary{ } $bootable{ } \
            method{ format } format{ } \
            use_filesystem{ } filesystem{ ext4 } \
            mountpoint{ /boot } \
        . \
        2048 2047 2048 linux-swap \
            $primary{ } \
            method{ swap } format{ } \
        . \
        17408 100000000000 -1 ext4 \
            $primary{ } \
            method{ format } format{ } \
            use_filesystem{ } filesystem{ ext4 } \
            mountpoint{ / } \
        .

This is based on this blog. Will this do what I want, and is there anything else I need to add to my preseed.cfg to make it accept these instructions without user intervention? I have never used partman recipes before.

4

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.

1

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.

0

Try these 3 lines (making changes as fits):

d-i partman-auto/disk string /dev/sda
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
  • 1
    Hi @Tshepang, thank you for your answer. This was the start of what I needed to do. These lines will select /dev/sda for partitioning and get you ready to partition that disk. Setting up the partman recipe was a much more involved process, but I managed to do it; see my answer below. – user5104897 Feb 7 '17 at 21:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.