Skip to content

Instantly share code, notes, and snippets.

@tomwalsh
Last active April 21, 2024 22:21
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomwalsh/aadd1dee2863dab12dc738db0df997bc to your computer and use it in GitHub Desktop.
Save tomwalsh/aadd1dee2863dab12dc738db0df997bc to your computer and use it in GitHub Desktop.
Debian Installer/preseed Partman Setup for RAID and LVM
# Force the system to unmount any previously found file systems
d-i preseed/early_command string umount /media || true
# We are using RAID as our method - This is important
d-i partman-auto/method string raid
# Define which disks we want to use in our RAID configuration
d-i partman-auto/disk string /dev/sda /dev/sdb
# Remove any previous LVM metadata
d-i partman-lvm/device_remove_lvm boolean true
# Remove any previous MD metadata
d-i partman-md/device_remove_md boolean true
# Confirm, because we are doing an automated install...
d-i partman-lvm/confirm boolean true
# Tell the installer we want to use the definition defined below "custompartitioning"
d-i partman-auto/choose_recipe select custompartitioning
# Specify the name of the Volume Group. Not required, but helps be consistent
d-i partman-auto-lvm/new_vg_name string VGroup
# This will cause LVM to use the maximum size for whatever is left over when creating an LV (I think)
d-i partman-auto-lvm/guided_size string max
# Defining our custom partition
# First partition is for UEFI boot
# Second partition is setup to be RAID raidid=1
# Third partition is setup to be the rest of the disk also RAID raidid=2
# Fourth definition is setup to be an LVM LV for /home at 10GB
# Fifth definition is setup to be an LVM LV for swap at 8GB
# Sixth definition is setup to be an LVM LV for / (root) for the remainder of the drive
d-i partman-auto/expert_recipe string \
custompartitioning :: \
1 1 1 free \
$gptonly{ } \
$primary{ } \
$lvmignore{ } \
$bios_boot{ } \
method{ biosgrub } \
. \
1024 2 1024 raid \
$primary{ } \
$lvmignore{ } \
method{ raid } \
raidid{ 1 } \
. \
20480 3 -1 raid \
$lvmignore{ } \
method{ raid } \
raidid{ 2 } \
. \
10240 400 10240 ext4 \
$defaultignore{ } \
$lvmok{ } \
lv_name{ home } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ /home } \
. \
8192 500 8192 linux-swap \
$defaultignore{ } \
$lvmok{ } \
lv_name{ swap } \
method{ swap } \
format{ } \
. \
20480 600 -1 ext4 \
$defaultignore{ } \
$lvmok{ } \
lv_name{ root } \
method{ format } \
format{ } \
use_filesystem{ } \
filesystem{ ext4 } \
mountpoint{ / } \
.
# Here we tell the RAID how we want the drives used
# First one: (RAID1, 2 devices, 0 spares, formated as ext3, mounted to /boot)
# Second one: (RAID1, 2 devices, 0 spares, setup as LVM, no mount)
d-i partman-auto-raid/recipe string \
1 2 0 ext3 /boot \
raidid=1 \
. \
1 2 0 lvm - \
raidid=2 \
.
# Don't allow the RAID to be created in degraded mode
d-i mdadm/boot_degraded boolean false
# Again, confirming things because we are automating this
d-i partman-md/confirm boolean true
# More confirming... seriously.
d-i partman-partitioning/confirm_write_new_label boolean true
# Yep, more confirming... I mean, come on.
d-i partman/choose_partition select Finish partitioning and write changes to disk
# .... ugh
d-i partman/confirm boolean true
# REALLY?!?
d-i partman-md/confirm_nooverwrite boolean true
# You have got to be kidding!
d-i partman/confirm_nooverwrite boolean true
@maximko
Copy link

maximko commented Aug 29, 2022

Can't get this to work on Debian 11 even with copypasted preseed:
mdadm: cannot open raidid=1: No such file or directory

@etkaar
Copy link

etkaar commented Jan 19, 2023

Are you sure you want ext3 instead of ext4?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment