diff mbox series

[wic] wic: Fix updating fstab for nvme devices

Message ID 20260522113400.192786-1-aleksandar.nikolic22@pm.me
State New
Headers show
Series [wic] wic: Fix updating fstab for nvme devices | expand

Commit Message

Aleksandar Nikolic May 22, 2026, 11:34 a.m. UTC
From: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>

In case wks file references nvme, update_fstab() function will not add
prefix 'p' before the partition number, as the if condition only takes
mmcblk into consideration.

In case of nvme0n1 this leads that following entries are added to fstab:

    /dev/nvme0n11
    /dev/nvme0n13

instead of:

    /dev/nvme0n1p1
    /dev/nvme0n1p3

The patch fixes this as it extends the if condition and adds prefix 'p' for
both mmcblk and nvme.

Signed-off-by: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>
---
 src/wic/plugins/imager/direct.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Trevor Woerner May 25, 2026, 4:16 p.m. UTC | #1
Hi,

Thanks for the patch, but there is a second case that needs the same
treatment.

On Fri 2026-05-22 @ 01:34:00 PM, Aleksandar Nikolic wrote:
> From: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>
> 
> In case wks file references nvme, update_fstab() function will not add
> prefix 'p' before the partition number, as the if condition only takes
> mmcblk into consideration.
> 
> In case of nvme0n1 this leads that following entries are added to fstab:
> 
>     /dev/nvme0n11
>     /dev/nvme0n13
> 
> instead of:
> 
>     /dev/nvme0n1p1
>     /dev/nvme0n1p3
> 
> The patch fixes this as it extends the if condition and adds prefix 'p' for
> both mmcblk and nvme.
> 
> Signed-off-by: Aleksandar Nikolic <aleksandar.nikolic@zeiss.com>
> ---
>  src/wic/plugins/imager/direct.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/wic/plugins/imager/direct.py b/src/wic/plugins/imager/direct.py
> index 832d0e6..38a675e 100644
> --- a/src/wic/plugins/imager/direct.py
> +++ b/src/wic/plugins/imager/direct.py
> @@ -134,8 +134,8 @@ class DirectPlugin(ImagerPlugin):
>              elif part.use_label:
>                  device_name = "LABEL=%s" % part.label
>              else:
> -                # mmc device partitions are named mmcblk0p1, mmcblk0p2..
> -                prefix = 'p' if  part.disk.startswith('mmcblk') else ''
please remove the double-spaces   ^^

> +                # mmc and nvme device partitions start with prefix 'p'
> +                prefix = 'p' if  part.disk.startswith(('mmcblk', 'nvme')) else ''
please remove the double-spaces   ^^

>                  device_name = "/dev/%s%s%d" % (part.disk, prefix, part.realnum)
>  
>              opts = part.fsopts if part.fsopts else "defaults"

The double-spaces pre-date your change, but since you're editing them
already...

There is a second site with the same hard-coded `mmcblk` test, a few
lines below in `DirectPlugin.rootdev`:

    src/wic/plugins/imager/direct.py:272
        suffix = 'p' if part.disk.startswith('mmcblk') else ''
        return "/dev/%s%s%-d" % (part.disk, suffix, part.realnum)

That property builds the kernel command-line `root=` argument, so with
the current code an NVMe rootfs boots with `root=/dev/nvme0n11`, which
doesn't exist. Could you give it the same `('mmcblk', 'nvme')` treatment
in v2?


> -- 
> 2.43.0
>
diff mbox series

Patch

diff --git a/src/wic/plugins/imager/direct.py b/src/wic/plugins/imager/direct.py
index 832d0e6..38a675e 100644
--- a/src/wic/plugins/imager/direct.py
+++ b/src/wic/plugins/imager/direct.py
@@ -134,8 +134,8 @@  class DirectPlugin(ImagerPlugin):
             elif part.use_label:
                 device_name = "LABEL=%s" % part.label
             else:
-                # mmc device partitions are named mmcblk0p1, mmcblk0p2..
-                prefix = 'p' if  part.disk.startswith('mmcblk') else ''
+                # mmc and nvme device partitions start with prefix 'p'
+                prefix = 'p' if  part.disk.startswith(('mmcblk', 'nvme')) else ''
                 device_name = "/dev/%s%s%d" % (part.disk, prefix, part.realnum)
 
             opts = part.fsopts if part.fsopts else "defaults"