Linux – How to make custom partitioning of hdd via preseed

automated-installautomationlinuxpreseedUbuntu

According to official debian manual (https://www.debian.org/releases/stable/amd64/apbs04.html.en), i saw:

#d-i partman-auto/expert_recipe string                         \
#      boot-root ::                                            \
#              40 50 100 ext3                                  \
#                      $primary{ } $bootable{ }                \
#                      method{ format } format{ }              \
#                      use_filesystem{ } filesystem{ ext3 }    \
#                      mountpoint{ /boot }                     \
#              .                                               \
#              500 10000 1000000000 ext3                       \
#                      method{ format } format{ }              \
#                      use_filesystem{ } filesystem{ ext3 }    \
#                      mountpoint{ / }                         \
#              .                                               \
#              64 512 300% linux-swap                          \
#                      method{ swap } format{ }                \
#              .

But this variant for using all disk. But if i want to use 30 Gb for root / and 2 Gb for swap. Other space i don't want to use (unlocated space). How to do it ? Sorry, i tried to find, but i have not found ? Maybe you can help me ?

Best Answer

Do you want /boot as a separate filesystem? The example in your question will create it with a minimum of 40 MiB, maximum of 100 MiB. If you want it to be 500 MiB always, then set the three numbers for /boot like 500 500 500.

For root, if you want it to always be 30 GiB (= 30720 MiB), specify the three numbers as 30720 30720 30720. If you don't want to use a separate /boot filesystem, move the $primary{ } $bootable{ } line to this partition and then delete the /boot partition specification.

For always 2 GiB of swap, set the swap values to 2048 2048 2048.

When you're specifying fixed sizes (minimum = maximum) then the priority value will be unimportant. But the documentation says the priority value should normally be between the min and max size values, so all three values should then be the same, and equal to the required size in MiB.

So here's a recipe for just two partitions, 30 GiB for root and 2 GiB for swap, using the ext4 filesystem for root, uncommented and ready for use:

 d-i partman-auto/expert_recipe string                    \
      boot-root ::                                        \
          30720 30720 30720 ext4                          \
                  $primary{ } $bootable{ }                \
                  method{ format } format{ }              \
                  use_filesystem{ } filesystem{ ext4 }    \
                  mountpoint{ / }                         \
          .                                               \
          2048 2048 2048 linux-swap                       \
                  method{ swap } format{ }                \
          .
Related Topic