bootctl: add new --print-root-device option
authorLennart Poettering <lennart@poettering.net>
Mon, 20 Feb 2023 16:25:14 +0000 (17:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Tue, 21 Feb 2023 17:19:38 +0000 (18:19 +0100)
commitc56be2c294f55545ea34417a2ec4f6ad2cd1df6f
tree93cee6bbda623c51da5ff8d4c9ea16cf776c6a90
parentb469b969f30dbb4d4aeeccab79ec8f3782e769aa
bootctl: add new --print-root-device option

We already have this nice code in system that determines the block
device backing the root file system, but it's only used internally in
systemd-gpt-generator. Let's make this more accessible and expose it
directly in bootctl.

It doesn't fit immediately into the topic of bootctl, but I think it's
close enough and behaves very similar to the existing "bootctl
--print-boot-path" and "--print-esp-path" tools.

If --print-root-device (or -R) is specified once, will show the block device
backing the root fs, and if specified twice (probably easier: -RR) it
will show the whole block device that block device belongs to in case it
is a partition block device.

Suggested use:

        # cfdisk `bootctl -RR`

To get access to the partition table, behind the OS install, for
whatever it might be.
man/bootctl.xml
src/boot/bootctl.c
src/boot/bootctl.h
src/gpt-auto-generator/gpt-auto-generator.c
src/shared/blockdev-util.c
src/shared/blockdev-util.h
test/test-bootctl-json.sh