8

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.

0

3 Answers 3

12

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.

7
  • 2
    Well done for posting what you found. The paucity of info and lack of exhaustive directory for all the preseed directives is a travesty of modern computing. I dread to think of $myTimeWasted*$numEngineers.
    – volvox
    Commented May 22, 2020 at 18:59
  • 1
    Can you explain why did you choose 17408 for the minimum size? It seems a number that you calculated carefully ... this is what I'm trying to understand .. if you are about to make minimum of 17GB, why not go with 17000 ? How did you get that 17408 ?
    – MaXi32
    Commented Apr 9, 2021 at 2:07
  • @MaXi32 OP is consistently using power of two sizing. First partition is 1GiB second is 2GiB and third at least 17GiB
    – JJ Roman
    Commented Dec 23, 2021 at 22:16
  • What is the number of n that you are getting 17,408? The first is correct where 2^n = (2^10) =1024, The second one is also correct 2^11 = 2048, The third is not in the chart of power 2 sizings, the minimum size would be 2^14 which is equal to 16,384. So 17,408 is not in that range. If you pick 2^15 it is equal to 32,768 . So, I guess he picked a random number without thinking. Still does not answer my question.
    – MaXi32
    Commented Dec 23, 2021 at 22:53
  • Actually, I just got the answer myself, The number he picked is actually just a random number where most people will do this without reason. When he put -1 in the last partition (the third argument), it is already assumed that the last partition would take the rest of the available space so this line: 17408 100000000000 -1 ext4 where the number 17408 and 100000000000 are not important to have bigger value.
    – MaXi32
    Commented Dec 23, 2021 at 23:05
3

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.

1

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
  • 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. Commented Feb 7, 2017 at 21:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .