systemd/units
Lennart Poettering 1761066b13 storagetm: add new systemd-storagetm component
This implements a "storage target mode", similar to what MacOS provides
since a long time as "Target Disk Mode":

        https://en.wikipedia.org/wiki/Target_Disk_Mode

This implementation is relatively simple:

1. a new generic target "storage-target-mode.target" is added, which
   when booted into defines the target mode.

2. a small tool and service "systemd-storagetm.service" is added which
   exposes a specific device or all devices as NVMe-TCP devices over the
   network.  NVMe-TCP appears to be hot shit right now how to expose
   block devices over the network. And it's really simple to set up via
   configs, hence our code is relatively short and neat.

The idea is that systemd-storagetm.target can be extended sooner or
later, for example to expose block devices also as USB mass storage
devices and similar, in case the system has "dual mode" USB controller
that can also work as device, not just as host. (And people could also
plug in sharing as NBD, iSCSI, whatever they want.)

How to use this? Boot into your system with a kernel cmdline of
"rd.systemd.unit=storage-target-mode.target ip=link-local", and you'll see on
screen the precise "nvme connect" command line to make the relevant
block devices available locally on some other machine. This all requires
that the target mode stuff is included in the initrd of course. And the
system will the stay in the initrd forever.

Why bother? Primarily three use-cases:

1. Debug a broken system: with very few dependencies during boot get
   access to the raw block device of a broken machine.

2. Migrate from system to another system, by dd'ing the old to the new
   directly.

3. Installing an OS remotely on some device (for example via Thunderbolt
   networking)

(And there might be more, for example the ability to boot from a
laptop's disk on another system)

Limitations:

1. There's no authentication/encryption. Hence: use this on local links
   only.

2. NVMe target mode on Linux supports r/w operation only. Ideally, we'd
   have a read-only mode, for security reasons, and default to it.

Future love:

1. We should have another mode, where we simply expose the homed LUKS
   home dirs like that.

2. Some lightweight hookup with plymouth, to display a (shortened)
   version of the info we write to the console.

To test all this, just run:

    mkosi --kernel-command-line-extra="rd.systemd.unit=storage-target-mode.target" qemu
2023-11-02 14:19:32 +01:00
..
user
user-.slice.d
user@.service.d
user@0.service.d
basic.target
blockdev@.target units/blockdev@.target: conflict with umount.target 2023-09-27 12:33:40 +02:00
bluetooth.target
boot-complete.target
console-getty.service.in units: Load agetty credentials in all getty units 2023-07-27 16:50:58 +02:00
container-getty@.service.in units: Load agetty credentials in all getty units 2023-07-27 16:50:58 +02:00
cryptsetup-pre.target
cryptsetup.target
debug-shell.service.in
dev-hugepages.mount
dev-mqueue.mount
emergency.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
emergency.target
exit.target
factory-reset.target
final.target
first-boot-complete.target
getty-pre.target
getty.target
getty@.service.in units: Load agetty credentials in all getty units 2023-07-27 16:50:58 +02:00
graphical.target
halt.target
hibernate.target
hybrid-sleep.target
initrd-cleanup.service
initrd-fs.target
initrd-parse-etc.service.in units/initrd-parse-etc.service: Conflict with emergency.target 2023-08-08 20:24:39 +01:00
initrd-root-device.target
initrd-root-fs.target
initrd-switch-root.service
initrd-switch-root.target
initrd-udevadm-cleanup-db.service
initrd-usr-fs.target
initrd.target
integritysetup-pre.target
integritysetup.target
kexec.target
kmod-static-nodes.service.in units: introduce systemd-tmpfiles-setup-dev-early.service 2023-08-12 07:55:20 +09:00
ldconfig.service
local-fs-pre.target
local-fs.target
machine.slice
machines.target
meson.build storagetm: add new systemd-storagetm component 2023-11-02 14:19:32 +01:00
modprobe@.service units: modprobe@.service: don't unescape instance name 2023-10-21 11:41:22 +01:00
multi-user.target
network-online.target
network-pre.target
network.target
nss-lookup.target
nss-user-lookup.target
paths.target
poweroff.target
printer.target
proc-sys-fs-binfmt_misc.automount
proc-sys-fs-binfmt_misc.mount
quotaon.service.in
rc-local.service.in
reboot.target
remote-cryptsetup.target
remote-fs-pre.target
remote-fs.target
remote-veritysetup.target
rescue.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
rescue.target
rpcbind.target
serial-getty@.service.in units: Load agetty credentials in all getty units 2023-07-27 16:50:58 +02:00
shutdown.target
sigpwr.target
sleep.target
slices.target
smartcard.target
sockets.target
soft-reboot.target
sound.target
storage-target-mode.target storagetm: add new systemd-storagetm component 2023-11-02 14:19:32 +01:00
suspend-then-hibernate.target
suspend.target
swap.target
sys-fs-fuse-connections.mount
sys-kernel-config.mount
sys-kernel-debug.mount
sys-kernel-tracing.mount
sysinit.target
syslog.socket
system-systemd\x2dcryptsetup.slice
system-systemd\x2dveritysetup.slice
system-update-cleanup.service
system-update-pre.target
system-update.target
systemd-ask-password-console.path
systemd-ask-password-console.service
systemd-ask-password-wall.path
systemd-ask-password-wall.service
systemd-backlight@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-battery-check.service.in units: order battery-check before hibernate-resume 2023-09-07 20:21:16 +08:00
systemd-binfmt.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-bless-boot.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-boot-check-no-failures.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-boot-random-seed.service
systemd-boot-update.service
systemd-bsod.service.in bsod: several cleanups 2023-08-22 23:20:14 +09:00
systemd-confext.service
systemd-coredump.socket
systemd-coredump@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-exit.service
systemd-firstboot.service
systemd-fsck-root.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-fsck@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-growfs-root.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-growfs@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-halt.service
systemd-hibernate-resume.service.in hibernate-resume: split out the logic of finding hibernate location 2023-09-07 20:21:16 +08:00
systemd-hibernate.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-homed-activate.service
systemd-homed.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-hostnamed.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-hwdb-update.service.in
systemd-hybrid-sleep.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-importd.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-initctl.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-initctl.socket
systemd-journal-catalog-update.service
systemd-journal-flush.service
systemd-journal-gatewayd.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-journal-gatewayd.socket
systemd-journal-remote.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-journal-remote.socket
systemd-journal-upload.service.in systemd-journal-upload: Increase failure tolerance (#19426, #2877) 2023-10-12 23:10:59 +01:00
systemd-journald-audit.socket
systemd-journald-dev-log.socket
systemd-journald-varlink@.socket
systemd-journald.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-journald.socket
systemd-journald@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-journald@.socket
systemd-kexec.service
systemd-localed.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-logind.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-machine-id-commit.service
systemd-machined.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-modules-load.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-network-generator.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-networkd-wait-online.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-networkd-wait-online@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-networkd.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-networkd.socket
systemd-nspawn@.service.in nspawn: set CoredumpReceive=yes on container's scope when --boot is set 2023-10-13 15:28:50 -04:00
systemd-oomd.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-oomd.socket oomd: correct listening sockets 2023-09-25 23:27:18 +02:00
systemd-pcrextend.socket pcrextend: make pcrextend tool acccessible via varlink 2023-10-06 11:49:38 +02:00
systemd-pcrextend@.service.in pcrextend: make pcrextend tool acccessible via varlink 2023-10-06 11:49:38 +02:00
systemd-pcrfs-root.service.in units: move units over to ConditionSecurity=measured-uki 2023-09-27 12:13:26 +02:00
systemd-pcrfs@.service.in units: move units over to ConditionSecurity=measured-uki 2023-09-27 12:13:26 +02:00
systemd-pcrmachine.service.in units: move units over to ConditionSecurity=measured-uki 2023-09-27 12:13:26 +02:00
systemd-pcrphase-initrd.service.in units: move units over to ConditionSecurity=measured-uki 2023-09-27 12:13:26 +02:00
systemd-pcrphase-sysinit.service.in units: move units over to ConditionSecurity=measured-uki 2023-09-27 12:13:26 +02:00
systemd-pcrphase.service.in units: move units over to ConditionSecurity=measured-uki 2023-09-27 12:13:26 +02:00
systemd-portabled.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-poweroff.service
systemd-pstore.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-quotacheck.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-random-seed.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-reboot.service
systemd-remount-fs.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-repart.service.in repart: Don't fail on boot if we can't find the root block device 2023-09-22 16:01:12 +01:00
systemd-resolved.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-rfkill.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-rfkill.socket
systemd-soft-reboot.service
systemd-storagetm.service.in storagetm: add new systemd-storagetm component 2023-11-02 14:19:32 +01:00
systemd-suspend-then-hibernate.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-suspend.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-sysctl.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-sysext.service
systemd-sysext.socket sysext: make some calls available via varlink 2023-10-16 12:08:39 +02:00
systemd-sysext@.service sysext: make some calls available via varlink 2023-10-16 12:08:39 +02:00
systemd-sysupdate-reboot.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-sysupdate-reboot.timer
systemd-sysupdate.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-sysupdate.timer
systemd-sysusers.service units: introduce systemd-tmpfiles-setup-dev-early.service 2023-08-12 07:55:20 +09:00
systemd-time-wait-sync.service.in treewide: fix typos 2023-09-19 10:05:38 +02:00
systemd-timedated.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-timesyncd.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-tmpfiles-clean.service
systemd-tmpfiles-clean.timer
systemd-tmpfiles-setup-dev-early.service units: introduce systemd-tmpfiles-setup-dev-early.service 2023-08-12 07:55:20 +09:00
systemd-tmpfiles-setup-dev.service units: introduce systemd-tmpfiles-setup-dev-early.service 2023-08-12 07:55:20 +09:00
systemd-tmpfiles-setup.service units: introduce systemd-tmpfiles-setup-dev-early.service 2023-08-12 07:55:20 +09:00
systemd-tpm2-setup-early.service.in tpm2-setup: add new early boot tool for initializing the SRK 2023-09-29 19:36:04 +02:00
systemd-tpm2-setup.service.in tpm2-setup: add new early boot tool for initializing the SRK 2023-09-29 19:36:04 +02:00
systemd-udev-settle.service
systemd-udev-trigger.service
systemd-udevd-control.socket
systemd-udevd-kernel.socket
systemd-udevd.service.in Revert "unit: make udev rules take precesence over tmpfiles" 2023-08-09 07:13:09 +09:00
systemd-update-done.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-update-utmp-runlevel.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-update-utmp.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-user-sessions.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-userdbd.service.in Revert "userdbd: Order systemd-userdbd.service after systemd-remount-fs.service" 2023-09-27 11:02:06 +02:00
systemd-userdbd.socket
systemd-vconsole-setup.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
systemd-volatile-root.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
time-set.target
time-sync.target
timers.target
tmp.mount
umount.target
usb-gadget.target
user-runtime-dir@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
user.slice
user@.service.in Drop split-usr and unmerged-usr support 2023-07-28 19:34:03 +01:00
var-lib-machines.mount
veritysetup-pre.target
veritysetup.target