[fstools v2 PATCH 2/2] partname: check "PARTLABEL" in root= parameter

INAGAKI Hiroshi musashino.open at gmail.com
Fri Jul 1 23:48:58 PDT 2022

This patch adds "PARTLABEL=" checking of root= parameter to
partname_volume_find function.

The Linux Kernel supports "root=PARTLABEL=<label>" syntax, but fstools
doesn't and fail to parse the path to the root device.
So check the parameter and skip parsing, find partition from all block
devices if this syntax is used.

This change is required for some NAS devices sold by I-O DATA, such as
HDL2-A and HDL2-AAX series.
On they, kernel and rootfs are stored in the storage device connected
to SATA, port1 or port2 and the path to the partition will be assigned
So "root=PARTLABEL=<label>" syntax is required instead of "/dev/sdXN".

Signed-off-by: INAGAKI Hiroshi <musashino.open at gmail.com>
v1 -> v2:

  - use "PARTLABEL=" string in root= parametr instead of the new fstools
    parameter to block searching root device

v2 -> v3:

  - rebased on the first patch of this patch series

 libfstools/partname.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libfstools/partname.c b/libfstools/partname.c
index e282402..8ccf12a 100644
--- a/libfstools/partname.c
+++ b/libfstools/partname.c
@@ -131,12 +131,13 @@ static struct volume *partname_volume_find(char *name)
 			return NULL;
-	if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam), true)) {
+	if (get_var_from_file("/proc/cmdline", "root", rootparam, sizeof(rootparam), true) &&
+	    strncmp(rootparam, "PARTLABEL=", 10)) {
 		rootdev = rootdevname(rootparam);
 		/* find partition on same device as rootfs */
 		snprintf(ueventgstr, sizeof(ueventgstr), "%s/%s/*/uevent", block_dir_name, rootdev);
 	} else {
-		/* no 'root=' kernel cmdline parameter, find on any block device */
+		/* PARTLABEL= is specifed or no 'root=' kernel cmdline parameter, find on any block device */
 		snprintf(ueventgstr, sizeof(ueventgstr), "%s/*/uevent", block_dir_name);

More information about the openwrt-devel mailing list