[v2] wic: added fspassno parameter to partition

Message ID 20220515063600.777146-1-Vijaikumar_Kanagarajan@mentor.com
State Accepted, archived
Commit b9b9f71e6f37bfbf954ade518391b242669481e3
Headers show
Series [v2] wic: added fspassno parameter to partition | expand

Commit Message

Kanagarajan, Vijaikumar May 15, 2022, 6:36 a.m. UTC
From: Claudius Heine <ch@denx.de>

The `fspassno` parameter allows to overwrite the value of the last
column (`fs_passno`) in the /etc/fstab of the target root file system.
This allows to have periodic file system checks.

Signed-off-by: Claudius Heine <ch@denx.de>
Signed-off-by: Vijai Kumar K <Vijaikumar_Kanagarajan@mentor.com>
---
 scripts/lib/wic/help.py                  | 6 ++++++
 scripts/lib/wic/ksparser.py              | 1 +
 scripts/lib/wic/partition.py             | 1 +
 scripts/lib/wic/plugins/imager/direct.py | 3 ++-
 4 files changed, 10 insertions(+), 1 deletion(-)

Comments

Tobias Schmidl May 17, 2022, 6:16 p.m. UTC | #1
Hi all,

On Sun, May 15, 2022 at 08:36 AM, Kanagarajan, Vijaikumar wrote:
>
> From: Claudius Heine <ch@denx.de>
> 
> The `fspassno` parameter allows to overwrite the value of the last
> column (`fs_passno`) in the /etc/fstab of the target root file system.
> This allows to have periodic file system checks.
> 

I've found this to be ineffective for `/`, as the fstab update is
explicitly omitted in `scripts/lib/wic/plugins/imager/direct.py:120`:

```
for part in self.parts:
    if not part.realnum or not part.mountpoint \
       or part.mountpoint == "/" or not part.mountpoint.startswith('/'):
       ^^^^^^^^^^^^^^^^^^^^^^^^^
        continue
```

I've created a patch, originally for different reasons, that will also
address this issue.

Kind regards,

Tobias
Kanagarajan, Vijaikumar May 17, 2022, 6:21 p.m. UTC | #2
> -----Original Message-----
> From: Schmidl, Tobias (T CED SES-DE) <tobiasschmidl@siemens.com>
> Sent: 17 May 2022 23:46
> To: openembedded-core@lists.openembedded.org; Kanagarajan,
> Vijaikumar <Vijaikumar_Kanagarajan@mentor.com>
> Cc: ch@denx.de; Schild, Henning (T CED SES-DE)
> <henning.schild@siemens.com>
> Subject: Re: [PATCH v2] wic: added fspassno parameter to partition
> 
Hi Tobias,

> Hi all,
> 
> On Sun, May 15, 2022 at 08:36 AM, Kanagarajan, Vijaikumar wrote:
> >
> > From: Claudius Heine <ch@denx.de>
> >
> > The `fspassno` parameter allows to overwrite the value of the last
> > column (`fs_passno`) in the /etc/fstab of the target root file system.
> > This allows to have periodic file system checks.
> >
> 
> I've found this to be ineffective for `/`, as the fstab update is explicitly
> omitted in `scripts/lib/wic/plugins/imager/direct.py:120`:

I believe wic has changed much since the first appearance of this patch.

> 
> ```
> for part in self.parts:
>     if not part.realnum or not part.mountpoint \
>        or part.mountpoint == "/" or not part.mountpoint.startswith('/'):
>        ^^^^^^^^^^^^^^^^^^^^^^^^^
>         continue
> ```
> 
> I've created a patch, originally for different reasons, that will also address this
> issue.

If you can send that, we can drop this patch in favour of it.

Thanks,
Vijai Kumar K

> 
> Kind regards,
> 
> Tobias
Henning Schild May 17, 2022, 6:31 p.m. UTC | #3
Am Tue, 17 May 2022 18:21:27 +0000
schrieb "Kanagarajan, Vijaikumar" <Vijaikumar_Kanagarajan@mentor.com>:

> > -----Original Message-----
> > From: Schmidl, Tobias (T CED SES-DE) <tobiasschmidl@siemens.com>
> > Sent: 17 May 2022 23:46
> > To: openembedded-core@lists.openembedded.org; Kanagarajan,
> > Vijaikumar <Vijaikumar_Kanagarajan@mentor.com>
> > Cc: ch@denx.de; Schild, Henning (T CED SES-DE)
> > <henning.schild@siemens.com>
> > Subject: Re: [PATCH v2] wic: added fspassno parameter to partition
> >   
> Hi Tobias,
> 
> > Hi all,
> > 
> > On Sun, May 15, 2022 at 08:36 AM, Kanagarajan, Vijaikumar wrote:  
> > >
> > > From: Claudius Heine <ch@denx.de>
> > >
> > > The `fspassno` parameter allows to overwrite the value of the last
> > > column (`fs_passno`) in the /etc/fstab of the target root file
> > > system. This allows to have periodic file system checks.
> > >  
> > 
> > I've found this to be ineffective for `/`, as the fstab update is
> > explicitly omitted in
> > `scripts/lib/wic/plugins/imager/direct.py:120`:  
> 
> I believe wic has changed much since the first appearance of this
> patch.

Yes, some bits have changed but i also do not recall all the details.

> > 
> > ```
> > for part in self.parts:
> >     if not part.realnum or not part.mountpoint \
> >        or part.mountpoint == "/" or not
> > part.mountpoint.startswith('/'): ^^^^^^^^^^^^^^^^^^^^^^^^^
> >         continue
> > ```
> > 
> > I've created a patch, originally for different reasons, that will
> > also address this issue.  
> 
> If you can send that, we can drop this patch in favour of it.

AFAIK Tobias will be aiming at allowing wic to create fstab lines for
/, so it will not replace but instead boil down to merge order.

I can only assume that / might for some people for sure be a prime
target for --fspassno.

regards,
Henning

> Thanks,
> Vijai Kumar K
> 
> > 
> > Kind regards,
> > 
> > Tobias  
>

Patch

diff --git a/scripts/lib/wic/help.py b/scripts/lib/wic/help.py
index 4ff7470a6a..73e3380cde 100644
--- a/scripts/lib/wic/help.py
+++ b/scripts/lib/wic/help.py
@@ -940,6 +940,12 @@  DESCRIPTION
                       quotes.  If not specified, the default string is
                       "defaults".
 
+         --fspassno: Specifies the order in which filesystem checks are done
+                     at boot time by fsck.  See fs_passno parameter of
+                     fstab(5).  This parameter will be copied into the
+                     /etc/fstab file of the installed system.  If not
+                     specified the default value of "0" will be used.
+
          --label label: Specifies the label to give to the filesystem
                         to be made on the partition. If the given
                         label is already in use by another filesystem,
diff --git a/scripts/lib/wic/ksparser.py b/scripts/lib/wic/ksparser.py
index 0df9eb0d05..a49b7b97c4 100644
--- a/scripts/lib/wic/ksparser.py
+++ b/scripts/lib/wic/ksparser.py
@@ -155,6 +155,7 @@  class KickStart():
         part.add_argument('--change-directory')
         part.add_argument("--extra-space", type=sizetype("M"))
         part.add_argument('--fsoptions', dest='fsopts')
+        part.add_argument('--fspassno', dest='fspassno')
         part.add_argument('--fstype', default='vfat',
                           choices=('ext2', 'ext3', 'ext4', 'btrfs',
                                    'squashfs', 'vfat', 'msdos', 'erofs',
diff --git a/scripts/lib/wic/partition.py b/scripts/lib/wic/partition.py
index 09e491dd49..e50871b8d7 100644
--- a/scripts/lib/wic/partition.py
+++ b/scripts/lib/wic/partition.py
@@ -33,6 +33,7 @@  class Partition():
         self.include_path = args.include_path
         self.change_directory = args.change_directory
         self.fsopts = args.fsopts
+        self.fspassno = args.fspassno
         self.fstype = args.fstype
         self.label = args.label
         self.use_label = args.use_label
diff --git a/scripts/lib/wic/plugins/imager/direct.py b/scripts/lib/wic/plugins/imager/direct.py
index 4d0b836ef6..da483daed5 100644
--- a/scripts/lib/wic/plugins/imager/direct.py
+++ b/scripts/lib/wic/plugins/imager/direct.py
@@ -138,8 +138,9 @@  class DirectPlugin(ImagerPlugin):
                 device_name = "/dev/%s%s%d" % (part.disk, prefix, part.realnum)
 
             opts = part.fsopts if part.fsopts else "defaults"
+            passno = part.fspassno if part.fspassno else "0"
             line = "\t".join([device_name, part.mountpoint, part.fstype,
-                              opts, "0", "0"]) + "\n"
+                              opts, "0", passno]) + "\n"
 
             fstab_lines.append(line)
             updated = True