Skip to contentSkip to conversation

wic: partition: Add fsck to avoid corrupt EXT file systems

PATCH In review Daniel Schultz 2 participants 2 messages Mar 30, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 wic: partition: Add fsck to avoid corrupt EXT file systems

This patch avoids the creation of a corrupt EXT file system.

Since there are no checks if a EXT file system was successfully created, this should add to prevent possible system failures.

---
 scripts/lib/wic/partition.py | 3 +++
 1 file changed, 3 insertions(+)
scripts/lib/wic/partition.py +3 -0
index 3b3bd2d..152eb7b 100644
@@ -239,6 +239,9 @@ class Partition():
             (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir)
         exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
 
+        mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
+        exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
+
     def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
                              native_sysroot, pseudo):
         """
Signature · 1 line
1.9.1
#1 lore raw

Hi Daniel,

Quoted 16 lines · Daniel Schultz

This patch avoids the creation of a corrupt EXT file system.

Since there are no checks if a EXT file system was successfully created, this should add to prevent possible system failures.

---
 scripts/lib/wic/partition.py | 3 +++
 1 file changed, 3 insertions(+)
scripts/lib/wic/partition.py +0 -0
index 3b3bd2d..152eb7b 100644

scripts/lib/wic/partition.py class Partition(): · line 247

Quoted 9 lines
scripts/lib/wic/partition.py +3 -0
@@ -239,6 +239,9 @@ class Partition():
             (self.fstype, extra_imagecmd, rootfs, label_str, rootfs_dir)
         exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
 
+        mkfs_cmd = "fsck.%s -pvfD %s" % (self.fstype, rootfs)
+        exec_native_cmd(mkfs_cmd, native_sysroot, pseudo=pseudo)
+
     def prepare_rootfs_btrfs(self, rootfs, oe_builddir, rootfs_dir,
                              native_sysroot, pseudo):
         """

maybe it's worth noting this check should not primary target fixing a corrupt ext4 (bad if mkfs created on!) but performs some directory optimization on the build host that otherwise would be performed on the target the next time something triggers an fsck. Performing those optimizations on the target will also make fsck trigger a reboot!

As the options as provided will not fix a real corrupted EXT it might also be useful to change the patch description to not confuse about the impact of the change.

Regards, Enrico

Signature · 4 lines
Pengutronix e.K.                           | Enrico Jörns                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-5080 |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |