In some cases, genext2fs does not produce enough inodes. Specify
16384 bytes per inode by default (can be overridden using
IMAGE_EXT2_EXTRA_ARGS).

Also run e2fsck in all cases to generate a UUID in the superblock.

Finally support upgrading the image to ext4.

Signed-off-by: Jan Luebbe <j...@pengutronix.de>
---
 platforms/image_ext2.in    |   14 +++++++++++---
 rules/post/image_ext2.make |   25 +++++++++++++++++++------
 2 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/platforms/image_ext2.in b/platforms/image_ext2.in
index c26efd0..d87a8f5 100644
--- a/platforms/image_ext2.in
+++ b/platforms/image_ext2.in
@@ -14,7 +14,7 @@ config IMAGE_EXT2_SIZE
        default 20480
        prompt "Size in kilobytes"
        help
-         FIXME: This item needs to be documented
+         Size of the image in kilobytes
 
 config IMAGE_EXT2_EXTRA_ARGS
        string
@@ -33,9 +33,17 @@ config IMAGE_EXT2_GZIP
 config IMAGE_EXT2_JOURNAL
        bool
        select HOST_E2FSPROGS
-       prompt "Add a journal to the ext2 file system image, making it ext3"
+       prompt "Upgrade the ext2 file system image to ext3 by adding a journal"
+       help
+         Enable this option if you want to mount the root file system as
+         an ext3 image.
+
+config IMAGE_EXT2_EXT4
+       bool
+       select IMAGE_EXT2_JOURNAL
+       prompt "Upgrade the ext2 file system image to ext4"
        help
          Enable this option if you want to mount the root file system as
-         ext3 image.
+         an ext4 image.
 
 endif
diff --git a/rules/post/image_ext2.make b/rules/post/image_ext2.make
index ed7d037..9988ce5 100644
--- a/rules/post/image_ext2.make
+++ b/rules/post/image_ext2.make
@@ -13,13 +13,14 @@ SEL_ROOTFS-$(PTXCONF_IMAGE_EXT2_GZIP)       += 
$(IMAGEDIR)/root.ext2.gz
 
 $(IMAGEDIR)/root.ext2: $(STATEDIR)/image_working_dir
        @echo -n "Creating root.ext2 from working dir..."
-       @cd $(image/work_dir);                                                  
\
+       @cd $(image/work_dir);                                          \
        (awk -F: $(DOPERMISSIONS) $(image/permissions) &&               \
        (                                                               \
                echo -n "$(PTXCONF_SYSROOT_HOST)/bin/genext2fs ";       \
                echo -n "-b $(PTXCONF_IMAGE_EXT2_SIZE) ";               \
+               echo -n "-i 16384 ";                                    \
                echo -n "$(PTXCONF_IMAGE_EXT2_EXTRA_ARGS) ";            \
-               echo -n "-d $(image/work_dir) ";                                
\
+               echo -n "-d $(image/work_dir) ";                        \
                echo "$@" )                                             \
        ) | $(FAKEROOT) --
        @echo "done."
@@ -31,12 +32,24 @@ ifdef PTXCONF_IMAGE_EXT2_JOURNAL
 #      # mode we use output redirection (and since we're operating on files
 #      # and not on real block devices, it's very unlikely that there are
 #      # errors we want to see.
-       @echo -n "Adding a journal to root.ext2 ..."
-       @tune2fs -j "$(IMAGEDIR)/root.ext2" > /dev/null
-       @e2fsck -y "$(IMAGEDIR)/root.ext2" > /dev/null 2>&1
-       @echo  "done."
+       @echo -n "Upgrading root.ext2 to ext3..."
+       @tune2fs -O has_journal "$(IMAGEDIR)/root.ext2" >/dev/null
+       @echo "done."
+endif
+
+ifdef PTXCONF_IMAGE_EXT2_EXT4
+       @echo -n "Upgrading root.ext2 to ext4..."
+       @tune2fs -O extents,uninit_bg,dir_index "$(IMAGEDIR)/root.ext2" 
>/dev/null
+       @echo "done."
 endif
 
+       @echo -n "Running e2fsck on root.ext2..."
+       @e2fsck -pvfD "$(IMAGEDIR)/root.ext2" >/dev/null 2>&1; test $$? -le 2
+       @echo "done."
+
+       @echo -n "Summary of root.ext2:"
+       @e2fsck -pvf "$(IMAGEDIR)/root.ext2"
+
 $(IMAGEDIR)/root.ext2.gz: $(IMAGEDIR)/root.ext2
        @echo -n "Creating root.ext2.gz from root.ext2...";
        @rm -f $@
-- 
1.7.9.5


-- 
ptxdist mailing list
ptxdist@pengutronix.de

Reply via email to