[Buildroot] [PATCH 4/4] fs/ext2: add support for specifying UUID

Yann E. MORIN yann.morin.1998 at free.fr
Mon Sep 1 13:44:35 UTC 2014

Some post-image script might want to call our own genext2fs wrapper,
instead of re-inventing their own wrapper. Also, such scripts may want
to set a specific UUID to the newly generated filesystem.

Given how tricky the ext2/3/4 handling can be (remember our past bad
experiences with it?), and given that we already have a proven, stable
solution for generating ext2/3/4 filesystems, add a new option that
allows external callers to specify the UUID, instead of letting tune2fs
compute a random one, which is kept as the default behaviour if no UUID
is specified.

Signed-off-by: "Yann E. MORIN" <yann.morin.1998 at free.fr>
 fs/ext2/genext2fs.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/ext2/genext2fs.sh b/fs/ext2/genext2fs.sh
index 598aee2..a3150d5 100755
--- a/fs/ext2/genext2fs.sh
+++ b/fs/ext2/genext2fs.sh
@@ -9,6 +9,7 @@ CALC_INODES=1
 # Backward compatibility
 if [ -n "${GEN}" -o -n "${REV}" ]; then
@@ -18,7 +19,7 @@ fi
 # Tell getopts to stop after all existing options,
 # and not parse the ones we add
 set -- "${@}" --
-while getopts x:d:D:b:i:N:m:g:e:zfqUPhVvG:R:L: f
+while getopts x:d:D:b:i:N:m:g:e:zfqUPhVvG:R:L:u: f
     case $f in
         # The following options are specific to our wrapper,
@@ -26,6 +27,7 @@ do
         G) GEN=$OPTARG; continue ;;
         R) REV=$OPTARG; continue ;;
         L) LABEL=$OPTARG; continue ;;
+        u) UUID=$OPTARG; continue ;;
         # Any other option is recognised by the real genext2fs,
         # so we want to keep them.
         b) CALC_BLOCKS=0 ;;
@@ -76,7 +78,7 @@ e2tunefsck() {
     # Although a random UUID may seem bad for reproducibility, there
     # already are so many things that are not reproducible in a
     # filesystem: file dates, file ordering, content of the files...
-    tune2fs -U random "${IMG}"
+    tune2fs -U "${UUID}" "${IMG}"
     # Upgrade the filesystem
     if [ $# -ne 0 ]; then

More information about the buildroot mailing list