[Partition]
Type=root
Label=root
SizeMinBytes=2G
GrowFileSystem=yes
[Partition]
Type=root
Label=root
SizeMinBytes=2G
GrowFileSystem=yes
[Partition]
Type=root
Label=root
SizeMinBytes=2G
GrowFileSystem=yes
[Partition]
Type=var
Label=var
SizeMinBytes=4G
Weight=1000
Format=ext4
[Partition]
Type=var
Label=var
SizeMinBytes=4G
Weight=1000
Format=ext4
[Partition]
Type=var
Label=var
SizeMinBytes=4G
Weight=1000
Format=ext4
LABEL=root / ext4 defaults,x-systemd.growfs 0 1
LABEL=var /var ext4 defaults 0 2
LABEL=root / ext4 defaults,x-systemd.growfs 0 1
LABEL=var /var ext4 defaults 0 2
LABEL=root / ext4 defaults,x-systemd.growfs 0 1
LABEL=var /var ext4 defaults 0 2
mkdir -p repart-demo/repart.d
cd repart-demo
mkdir -p repart-demo/repart.d
cd repart-demo
mkdir -p repart-demo/repart.d
cd repart-demo
cat > repart.d/10-root.conf <<'EOF'
[Partition]
Type=root
Label=root
SizeMinBytes=2G
GrowFileSystem=yes
EOF cat > repart.d/20-var.conf <<'EOF'
[Partition]
Type=var
Label=var
SizeMinBytes=4G
Weight=1000
Format=ext4
EOF
cat > repart.d/10-root.conf <<'EOF'
[Partition]
Type=root
Label=root
SizeMinBytes=2G
GrowFileSystem=yes
EOF cat > repart.d/20-var.conf <<'EOF'
[Partition]
Type=var
Label=var
SizeMinBytes=4G
Weight=1000
Format=ext4
EOF
cat > repart.d/10-root.conf <<'EOF'
[Partition]
Type=root
Label=root
SizeMinBytes=2G
GrowFileSystem=yes
EOF cat > repart.d/20-var.conf <<'EOF'
[Partition]
Type=var
Label=var
SizeMinBytes=4G
Weight=1000
Format=ext4
EOF
systemd-repart \ --dry-run=yes \ --empty=create \ --size=12G \ --definitions=repart.d \ demo.img
systemd-repart \ --dry-run=yes \ --empty=create \ --size=12G \ --definitions=repart.d \ demo.img
systemd-repart \ --dry-run=yes \ --empty=create \ --size=12G \ --definitions=repart.d \ demo.img
[Partition]
Type=var
Label=var
SizeMinBytes=8G
SizeMaxBytes=8G
Format=ext4
[Partition]
Type=var
Label=var
SizeMinBytes=8G
SizeMaxBytes=8G
Format=ext4
[Partition]
Type=var
Label=var
SizeMinBytes=8G
SizeMaxBytes=8G
Format=ext4
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINTS,PARTLABEL,PARTTYPE
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINTS,PARTLABEL,PARTTYPE
lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINTS,PARTLABEL,PARTTYPE
findmnt -no SOURCE,FSTYPE,OPTIONS /
findmnt -no SOURCE,FSTYPE,OPTIONS /
findmnt -no SOURCE,FSTYPE,OPTIONS /
journalctl -b -u systemd-repart.service
journalctl -b -u systemd-repart.service
journalctl -b -u systemd-repart.service - ship a large image that wastes space everywhere, or
- ship a small image and rely on ad hoc first-boot scripts to resize partitions - growing the root partition on first boot,
- adding a dedicated /var partition when extra disk space exists,
- growing the filesystem itself with x-systemd.growfs, and
- dry-running the whole layout safely against an image file before rollout. - systemd-repart works with GPT partition tables.
- It is typically run in the initrd at boot through systemd-repart.service.
- It can operate on the running system's backing device when invoked without arguments.
- It can also operate on an image file with --image=.
- By default, it changes the partition table, not the filesystem inside the partition, unless you explicitly use formatting features or pair it with filesystem growth. - a golden image for KVM, Proxmox, or cloud VMs
- an appliance-style image that should expand to the target disk
- a Linux image where /var, /home, or swap should appear only when space is available
- A/B-style images where the secondary partition is created on first boot - one root partition - the root partition to grow beyond its shipped size
- a separate /var partition to be created if extra disk space is available - Type=root matches the architecture-appropriate GPT root partition type.
- SizeMinBytes=2G ensures the root partition is at least 2 GiB.
- GrowFileSystem=yes marks the partition so tools that honor the flag grow the filesystem on first mount.
- Type=var declares a /var partition using the Discoverable Partitions Specification type.
- Format=ext4 tells systemd-repart to create a filesystem for that new partition. - it is visible during review,
- it makes the filesystem-growth step explicit, and
- it uses the documented [email protected] path that systemd exposes for mounted filesystems. - a new GPT image file is created,
- the partition plan is computed from your .conf files,
- and no real disk is modified because --dry-run=yes is in effect. - GrowFileSystem=yes where appropriate,
- x-systemd.growfs for mounts, or
- a documented filesystem-specific growth step if your setup requires it. - build the image with a deliberately small root partition,
- include repart.d files in /usr/lib/repart.d/,
- ensure root mounts with x-systemd.growfs if needed,
- test with systemd-repart --dry-run against an image file,
- boot a disposable VM on a larger virtual disk,
- verify partition layout with lsblk -o NAME,SIZE,TYPE,MOUNTPOINTS,PARTLABEL,
- verify filesystem growth with findmnt / and df -h /,
- only then promote the image. - the partition exists,
- the expected filesystem exists,
- the mount options include the growth path you expected, and
- systemd-repart did what the layout files said. - systemd-repart manages partition intent
- systemd-growfs or equivalent handles filesystem expansion - systemd-repart(8): https://manpages.debian.org/testing/systemd/systemd-repart.8.en.html
- repart.d(5): https://manpages.debian.org/testing/systemd/repart.d.5.en.html
- systemd.io, Safely Building Images: https://systemd.io/BUILDING_IMAGES/
- Discoverable Partitions Specification: https://uapi-group.org/specifications/specs/discoverable_partitions_specification/
- systemd-growfs(8): https://manpages.debian.org/testing/systemd/systemd-growfs.8.en.html