Mike Burns 3ab53ce
From 5a957602cbb1d916fd28b64514a1ec83767b641a Mon Sep 17 00:00:00 2001
b53dbd4
From: Ethan Gafford <egafford@redhat.com>
Mike Burns 3ab53ce
Date: Tue, 17 Mar 2015 13:06:38 -0400
b53dbd4
Subject: [PATCH] Open MKFS_OPTS for extension in disk-image-create
b53dbd4
b53dbd4
At present, MKFS_OPTS is closed for modification. The ability
b53dbd4
to extend the set of MKFS_OPTS adds a great deal of power for
b53dbd4
knowledgeable end-users. (And in some specific circumstances,
b53dbd4
it is vital to success, as in the case of building RHEL/CentOS
b53dbd4
6 images from RHEL/CentOS 7 hosts, in which case -O ^64bit is
b53dbd4
required in order for the image to boot.)
b53dbd4
Mike Burns 3ab53ce
Change-Id: I714e86a5a413779e63f598fbbb5a79d23cf6d8c3
b53dbd4
---
b53dbd4
 bin/disk-image-create | 12 +++++++-----
b53dbd4
 1 file changed, 7 insertions(+), 5 deletions(-)
b53dbd4
b53dbd4
diff --git a/bin/disk-image-create b/bin/disk-image-create
Mike Burns 3ab53ce
index 67928ab..ecc3f49 100755
b53dbd4
--- a/bin/disk-image-create
b53dbd4
+++ b/bin/disk-image-create
Mike Burns 3ab53ce
@@ -59,6 +59,8 @@ function show_options () {
b53dbd4
     echo "       Making this value unnecessarily large will consume extra disk space "
b53dbd4
     echo "       on the root partition with extra file system inodes."
b53dbd4
     echo "    --min-tmpfs size -- minimum size in GB needed in tmpfs to build the image"
b53dbd4
+    echo "    --mkfs-options -- option flags to be passed directly to mkfs."
b53dbd4
+    echo "       Options should be passed as a single string value."
b53dbd4
     echo "    --no-tmpfs -- do not use tmpfs to speed image build"
b53dbd4
     echo "    --offline -- do not update cached resources"
b53dbd4
     echo "    --qemu-img-options -- option flags to be passed directly to qemu-img."
Mike Burns 3ab53ce
@@ -94,7 +96,8 @@ IMAGE_TYPES=("qcow2")
b53dbd4
 COMPRESS_IMAGE="true"
Mike Burns 3ab53ce
 export DIB_ROOT_LABEL=""
Mike Burns 3ab53ce
 DIB_DEFAULT_INSTALLTYPE=${DIB_DEFAULT_INSTALLTYPE:-"source"}
Mike Burns 3ab53ce
-TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize:,qemu-img-options:,ramdisk-element:,root-label:,install-type: -n $SCRIPTNAME -- "$@"`
b53dbd4
+MKFS_OPTS=""
Mike Burns 3ab53ce
+TEMP=`getopt -o a:ho:t:xucnp: -l no-tmpfs,offline,help,min-tmpfs:,image-size:,image-cache:,max-online-resize:,mkfs-options:,qemu-img-options:,ramdisk-element:,root-label:,install-type: -n $SCRIPTNAME -- "$@"`
b53dbd4
 if [ $? -ne 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
Mike Burns 3ab53ce
b53dbd4
 # Note the quotes around `$TEMP': they are essential!
Mike Burns 3ab53ce
@@ -114,6 +117,7 @@ while true ; do
Mike Burns 3ab53ce
         --image-size) export DIB_IMAGE_SIZE=$2; shift 2;;
b53dbd4
         --image-cache) export DIB_IMAGE_CACHE=$2; shift 2;;
b53dbd4
         --max-online-resize) export MAX_ONLINE_RESIZE=$2; shift 2;;
b53dbd4
+        --mkfs-options) MKFS_OPTS=$2; shift 2;;
Mike Burns 3ab53ce
         --min-tmpfs) export DIB_MIN_TMPFS=$2; shift 2;;
b53dbd4
         --no-tmpfs) shift; export DIB_NO_TMPFS=1;;
b53dbd4
         --offline) shift; export DIB_OFFLINE=1;;
Mike Burns 3ab53ce
@@ -196,8 +200,6 @@ fi
b53dbd4
 unmount_image
b53dbd4
 mv $TMP_BUILD_DIR/mnt $TMP_BUILD_DIR/built
Mike Burns 3ab53ce
b53dbd4
-MKFS_OPTS=""
b53dbd4
-
b53dbd4
 if [ -n "$DIB_IMAGE_SIZE" ]; then
b53dbd4
   truncate -s${DIB_IMAGE_SIZE}G $TMP_IMAGE_PATH
b53dbd4
 else
Mike Burns 3ab53ce
@@ -212,12 +214,12 @@ else
b53dbd4
     # Very conservative to handle images being resized a lot
b53dbd4
     # Without -J option specified, default journal size will be set to 32M
b53dbd4
     # and online resize will be failed with error of needs too many credits.
b53dbd4
-    MKFS_OPTS="-i 4096 -J size=64"
b53dbd4
+    MKFS_OPTS="-i 4096 -J size=64 $MKFS_OPTS"
b53dbd4
   fi
b53dbd4
 fi
Mike Burns 3ab53ce
b53dbd4
 if [ -n "$MAX_ONLINE_RESIZE" ]; then
b53dbd4
-    MKFS_OPTS="$MKFS_OPTS -E resize=$MAX_ONLINE_RESIZE"
b53dbd4
+    MKFS_OPTS="-E resize=$MAX_ONLINE_RESIZE $MKFS_OPTS"
b53dbd4
 fi
Mike Burns 3ab53ce
b53dbd4
 LOOPDEV=$(sudo losetup --show -f $TMP_IMAGE_PATH)