[systemd-devel] How to use systemd-repart partitions?

Chris Murphy lists at colorremedies.com
Sat May 30 08:08:40 UTC 2020


On Wed, May 20, 2020 at 4:01 AM Lennart Poettering
<lennart at poettering.net> wrote:
>
> On Mi, 20.05.20 00:12, Tobias Hunger (tobias.hunger at gmail.com) wrote:
>
> >
> > The one thing that is frustrating is to get a machine image generated
> > by my build server onto a new piece of hardware. So I wanted to see
> > how far I can get with systemd-repart and co. to get this initial
> > deployment to new hardware more automated after booting with the
> > machine image from an USB stick.
>
> So I eventually want to cover three usecases with systemd-repart:
>
> 1. building OS images
> 2. installing an OS from an installer medium onto a host medium
> 3. adapting an OS images to the medium it has been dd'ed to on first
>    boot
>
> I think the 3rd usecase we already cover quite OK.
>
> To deliver the others, I want to add Encrypt= and Format= as
> mentioned. To cover the 2nd usecase I then also want to provide
> CopyBlocks= and CopyFiles=. The former would stream data into a
> partition that is created on the block level. Primary usecase would be
> to copy a partition 1:1 from the installer medium onto the host
> medium. The latter would copy in a file tree on the fs level.

Future feature for the former case:
- Btrfs seed/sprout feature expressly supports this use case for
replicating a seed image when destination is also Btrfs.
# mount /dev/seed /mnt
# btrfs device add /dev/sprout /mnt
# mount -o remount,rw /mnt
# btrfs device remove /dev/seed /mnt

This results in replication happening, from seed to sprout device.

Future feature to consider for the latter case, maybe it's more of an
optimization:
- ability to create btrfs subvolumes
- ability to 'cp -a --reflink'

Possibly an unaware installer just copies files over blindly. But then
the "repart" task is to create a snapshottable layout after the fact
without having to recopy everything.


> On first boot, "systemd-repart" would run to add in swap or so, maybe
> scaled by RAM size or so, and maybe format and encrypt /home.

Or add in zram-generator configuration if the generator is available,
and not worry about creating a persistent device.


-- 
Chris Murphy


More information about the systemd-devel mailing list