diff --git a/lustre/tests/replay-sanity.sh b/lustre/tests/replay-sanity.sh
index 73d228fb65966c973e46377f2732b5b7c63c6c59..535043877fe348dbf6a28a7d7d139a9bfd2fddfe 100755
--- a/lustre/tests/replay-sanity.sh
+++ b/lustre/tests/replay-sanity.sh
@@ -102,7 +102,11 @@ if [ $UID -ne 0 ]; then
         RUNAS=""
 else
         RUNAS_ID=${RUNAS_ID:-500}
-        RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+        if [ -z "$RUNAS_GID" ]; then
+	    RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+        else
+	    RUNAS=${RUNAS:-"runas -u $RUNAS_ID -g $RUNAS_GID"}
+        fi
 fi
 
 OLDTMPDIR=$TMPDIR
diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh
index 48f9c8aece7f4c2516b31a5123222977271dc2f2..a1447f7b76a4cfe78562e709e80febbf223bb192 100644
--- a/lustre/tests/sanity.sh
+++ b/lustre/tests/sanity.sh
@@ -58,7 +58,11 @@ if [ $UID -ne 0 ]; then
 	RUNAS=""
 else
 	RUNAS_ID=${RUNAS_ID:-500}
-	RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+        if [ -z "$RUNAS_GID" ]; then
+	    RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+        else
+	    RUNAS=${RUNAS:-"runas -u $RUNAS_ID -g $RUNAS_GID"}
+        fi
 fi
 
 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then
diff --git a/lustre/tests/sanityN.sh b/lustre/tests/sanityN.sh
index 576712b9e478104d1a3de21846b17be92d1e97cf..fcd0ee662a978cbb625bdaad269e66f70ab9a41d 100644
--- a/lustre/tests/sanityN.sh
+++ b/lustre/tests/sanityN.sh
@@ -31,7 +31,11 @@ if [ $UID -ne 0 ]; then
 	RUNAS=""
 else
 	RUNAS_ID=${RUNAS_ID:-500}
-	RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+        if [ -z "$RUNAS_GID" ]; then
+	    RUNAS=${RUNAS:-"runas -u $RUNAS_ID"}
+        else
+	    RUNAS=${RUNAS:-"runas -u $RUNAS_ID -g $RUNAS_GID"}
+        fi
 fi
 
 if [ `using_krb5_sec $SECURITY` == 'y' ] ; then