diff --git a/man/systemd-repart.xml b/man/systemd-repart.xml
index 8f48081097..bad3cf5ed2 100644
--- a/man/systemd-repart.xml
+++ b/man/systemd-repart.xml
@@ -19,7 +19,7 @@
systemd-repart
systemd-repart.service
- Automatically grow and add partitions
+ Automatically grow and add partitions, and generate disk images (DDIs).
@@ -612,6 +612,16 @@
+
+
+
+ Show a list of candidate block devices this command may operate on. Specifically,
+ this enumerates block devices currently present that support partition tables, and shows their device
+ node paths along with any of their symlinks.
+
+
+
+
diff --git a/src/partition/repart.c b/src/partition/repart.c
index ab41769348..9a5695d562 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -18,6 +18,7 @@
#include "alloc-util.h"
#include "blkid-util.h"
+#include "blockdev-list.h"
#include "blockdev-util.h"
#include "btrfs-util.h"
#include "build.h"
@@ -6962,6 +6963,7 @@ static int help(void) {
" --image-policy=POLICY\n"
" Specify disk image dissection policy\n"
" --definitions=DIR Find partition definitions in specified directory\n"
+ " --list-devices List candidate block devices to operate on\n"
"\n%3$sVerity:%4$s\n"
" --private-key=PATH|URI\n"
" Private key to use when generating verity roothash\n"
@@ -7062,6 +7064,7 @@ static int parse_argv(int argc, char *argv[]) {
ARG_MAKE_DDI,
ARG_GENERATE_FSTAB,
ARG_GENERATE_CRYPTTAB,
+ ARG_LIST_DEVICES,
};
static const struct option options[] = {
@@ -7105,6 +7108,7 @@ static int parse_argv(int argc, char *argv[]) {
{ "make-ddi", required_argument, NULL, ARG_MAKE_DDI },
{ "generate-fstab", required_argument, NULL, ARG_GENERATE_FSTAB },
{ "generate-crypttab", required_argument, NULL, ARG_GENERATE_CRYPTTAB },
+ { "list-devices", no_argument, NULL, ARG_LIST_DEVICES },
{}
};
@@ -7496,6 +7500,13 @@ static int parse_argv(int argc, char *argv[]) {
return r;
break;
+ case ARG_LIST_DEVICES:
+ r = blockdev_list(BLOCKDEV_LIST_REQUIRE_PARTITION_SCANNING|BLOCKDEV_LIST_SHOW_SYMLINKS|BLOCKDEV_LIST_IGNORE_ZRAM);
+ if (r < 0)
+ return r;
+
+ return 0;
+
case '?':
return -EINVAL;
diff --git a/test/units/TEST-58-REPART.sh b/test/units/TEST-58-REPART.sh
index 77adce47bb..2c69228d4e 100755
--- a/test/units/TEST-58-REPART.sh
+++ b/test/units/TEST-58-REPART.sh
@@ -1308,6 +1308,10 @@ testcase_urandom() {
[[ "$(sfdisk -q -l "$image" | grep -c "$image")" -eq 1 ]]
}
+testcase_list_devices() {
+ systemd-repart --list-devices
+}
+
OFFLINE="yes"
run_testcases