diff --git a/meta/classes/useradd.bbclass b/meta/classes/useradd.bbclass
index d7ed6cb931..6738ad12f4 100644
--- a/meta/classes/useradd.bbclass
+++ b/meta/classes/useradd.bbclass
@@ -22,11 +22,15 @@ PACKAGE_WRITE_DEPS += "shadow-native"
 useradd_preinst () {
 OPT=""
 SYSROOT=""
+GROUPMEMS_OPT=""
 
 if test "x$D" != "x"; then
 	# Installing into a sysroot
 	SYSROOT="$D"
 	OPT="--prefix $D"
+	# groupmems does not support --prefix (unlike useradd/groupadd/usermod),
+	# only -R/--root is recognized. Use --root specifically for groupmems.
+	GROUPMEMS_OPT="--root $D"
 
 	# Make sure login.defs is there, this is to make debian package backend work
 	# correctly while doing rootfs.
@@ -92,7 +96,7 @@ if test "x`echo $GROUPMEMS_PARAM | tr -d '[:space:]'`" != "x"; then
 	opts=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 1 | sed -e 's#[ \t]*$##'`
 	remaining=`echo "$GROUPMEMS_PARAM" | cut -d ';' -f 2- | sed -e 's#[ \t]*$##'`
 	while test "x$opts" != "x"; do
-		perform_groupmems "$SYSROOT" "$OPT $opts"
+		perform_groupmems "$SYSROOT" "$GROUPMEMS_OPT $opts"
 		if test "x$opts" = "x$remaining"; then
 			break
 		fi
