grub2-bhyve icon indicating copy to clipboard operation
grub2-bhyve copied to clipboard

Add EXT4_FEATURE_INCOMPAT_CSUM_SEED to EXT2_DRIVER_IGNORED_INCOMPAT

Open markpeek opened this issue 1 year ago • 1 comments

After installing alpine-standard-3.20.1-x86_64.iso into a bhyve VM, grub did not recognize the filesystem and would not boot. This was caused by the filesystem using the metadata_csum_seed feature that was not supported by this version of grub.

This is from the installed alpine (note the "metadata_csum_seed"):

# dumpe2fs /dev/vda3 | grep "Filesystem feature"
dumpe2fs 1.47.0 (5-Feb-2023)
Filesystem features:      has_journal ext_attr resize_inode dir_index orphan_file filetype needs_recovery extent 64bit flex_bg metadata_csum_seed sparse_super large_file huge_file dir_nlink extra_isize metadata_csum orphan_present

The upstream code has this change here: https://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/fs/ext2.c#n118

Note: it might make sense to add the other ignored FEATURES (*_MMP and *LARGEDIR) as well.

markpeek avatar Jul 22 '24 22:07 markpeek

Just to confirm: that was the only change required for Alpine to boot ?

grehan-freebsd avatar Jul 24 '24 10:07 grehan-freebsd

I can confirm that disabling metadata_csum_seed on boot partition allow alpine to boot again.

I've used that command on the host (after attach vm disk to memory disk) to do alpine boot after install:

tune2fs -O ^metadata_csum_seed /dev/md0s1

biancalana avatar Apr 24 '25 17:04 biancalana

As mentioned by @markpeek, looking at upstream there are aditional flags that can be added also:

index bd1ab24..9ddf296 100644
--- a/grub-core/fs/ext2.c
+++ b/grub-core/fs/ext2.c
@@ -100,7 +100,10 @@ GRUB_MOD_LICENSE ("GPLv3+");
 #define EXT2_FEATURE_INCOMPAT_META_BG          0x0010
 #define EXT4_FEATURE_INCOMPAT_EXTENTS          0x0040 /* Extents used */
 #define EXT4_FEATURE_INCOMPAT_64BIT            0x0080
+#define EXT4_FEATURE_INCOMPAT_MMP              0x0100
 #define EXT4_FEATURE_INCOMPAT_FLEX_BG          0x0200
+#define EXT4_FEATURE_INCOMPAT_CSUM_SEED        0x2000
+#define EXT4_FEATURE_INCOMPAT_LARGEDIR         0x4000 /* >2GB or 3 level htree */

 /* The set of back-incompatible features this driver DOES support. Add (OR)
  * flags here as the related features are implemented into the driver.  */
@@ -114,9 +117,26 @@ GRUB_MOD_LICENSE ("GPLv3+");
  *                 journal because they will ignore the journal, but the next
  *                 ext3 driver to mount the volume will find the journal and
  *                 replay it, potentially corrupting the metadata written by
- *                 the ext2 drivers. Safe to ignore for this RO driver.  */
-#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER )
-
+ *                 the ext2 drivers. Safe to ignore for this RO driver.
+ * mmp:            Not really back-incompatible - was added as such to
+ *                 avoid multiple read-write mounts. Safe to ignore for this
+ *                 RO driver.
+ * checksum seed:  Not really back-incompatible - was added to allow tools
+ *                 such as tune2fs to change the UUID on a mounted metadata
+ *                 checksummed filesystem. Safe to ignore for now since the
+ *                 driver doesn't support checksum verification. However, it
+ *                 has to be removed from this list if the support is added later.
+ * large_dir:      Not back-incompatible given that the GRUB ext2 driver does
+ *                 not implement EXT2_FEATURE_COMPAT_DIR_INDEX. If the GRUB
+ *                 eventually supports the htree feature (aka dir_index)
+ *                 it should support 3 level htrees and then move
+ *                 EXT4_FEATURE_INCOMPAT_LARGEDIR to
+ *                 EXT2_DRIVER_SUPPORTED_INCOMPAT.
+ */
+#define EXT2_DRIVER_IGNORED_INCOMPAT ( EXT3_FEATURE_INCOMPAT_RECOVER \
+                                      | EXT4_FEATURE_INCOMPAT_MMP \
+                                      | EXT4_FEATURE_INCOMPAT_CSUM_SEED \
+                                      | EXT4_FEATURE_INCOMPAT_LARGEDIR)

 #define EXT3_JOURNAL_MAGIC_NUMBER      0xc03b3998U```

biancalana avatar Apr 24 '25 17:04 biancalana

@grehan-freebsd/ @cemeyer, can you help here ?

biancalana avatar May 15 '25 18:05 biancalana

No, sorry.

cemeyer avatar May 15 '25 20:05 cemeyer

news ?

biancalana avatar Aug 28 '25 22:08 biancalana