diff --git a/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot b/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot
index 069805180..41bc251af 100755
--- a/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot
+++ b/diskimage_builder/elements/yum-minimal/root.d/08-yum-chroot
@@ -23,6 +23,8 @@ fi
 set -eu
 set -o pipefail
 
+source $_LIB/common-functions
+
 if [ -f ${TARGET_ROOT}/.extra_settings ] ; then
     . ${TARGET_ROOT}/.extra_settings
 fi
@@ -223,13 +225,7 @@ function _install_pkg_manager {
 sudo mkdir -p $TARGET_ROOT/proc $TARGET_ROOT/dev $TARGET_ROOT/sys
 sudo mount -t proc none $TARGET_ROOT/proc
 sudo mount --bind /dev $TARGET_ROOT/dev
-# Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
-# introduced in v4.7 allows multiple instances of devpts. However,
-# some distributions are running older kernels so we need to take
-# care on what options we use to mount a new instance of devpts
-# filesystem since it's not completely independent. The best thing
-# to do is to simply use the existing mount options.
-sudo mount -t devpts -o $(mount | grep devpts | sed 's/.*(\(.*\))/\1/') devpts $TARGET_ROOT/dev/pts
+sudo mount -t devpts $(mount_dev_pts_options) devpts $TARGET_ROOT/dev/pts
 sudo mount -t sysfs none $TARGET_ROOT/sys
 
 # initalize rpmdb
diff --git a/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot b/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot
index d9a0d7260..843cf018c 100755
--- a/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot
+++ b/diskimage_builder/elements/zypper-minimal/root.d/08-zypper-chroot
@@ -24,6 +24,8 @@ fi
 set -eu
 set -o pipefail
 
+source $_LIB/common-functions
+
 function cleanup() {
     sudo umount $TARGET_ROOT/proc
     sudo umount $TARGET_ROOT/dev/pts
@@ -87,13 +89,7 @@ sudo zypper ${ZYPPER_TARGET_OPTS} refresh
 sudo mkdir -p $TARGET_ROOT/proc $TARGET_ROOT/dev $TARGET_ROOT/sys
 sudo mount -t proc none $TARGET_ROOT/proc
 sudo mount --bind /dev $TARGET_ROOT/dev
-# Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
-# introduced in v4.7 allows multiple instances of devpts. However,
-# some distributions are running older kernels so we need to take
-# care on what options we use to mount a new instance of devpts
-# filesystem since it's not completely independent. The best thing
-# to do is to simply use the existing mount options.
-sudo mount -t devpts -o $(mount | grep devpts | sed 's/.*(\(.*\))/\1/') devpts $TARGET_ROOT/dev/pts
+sudo mount -t devpts $(mount_dev_pts_options) devpts $TARGET_ROOT/dev/pts
 sudo mount -t sysfs none $TARGET_ROOT/sys
 
 # Install filesystem, base and useful tools
diff --git a/diskimage_builder/lib/common-functions b/diskimage_builder/lib/common-functions
index 981e9c742..2244de831 100644
--- a/diskimage_builder/lib/common-functions
+++ b/diskimage_builder/lib/common-functions
@@ -312,17 +312,22 @@ function create_base () {
     mount_proc_dev_sys
 }
 
+# Get mount options for mounting /dev/pts
+# Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
+# introduced in v4.7 allows multiple instances of devpts. However,
+# some distributions are running older kernels so we need to take
+# care on what options we use to mount a new instance of devpts
+# filesystem since it's not completely independent. The best thing
+# to do is to simply use the existing mount options.
+function mount_dev_pts_options() {
+    echo "-o $(findmnt --first-only /dev/pts --noheadings --output OPTIONS)"
+}
+
 function mount_proc_dev_sys () {
     # supporting kernel file systems
     sudo mount -t proc none $TMP_MOUNT_PATH/proc
     sudo mount --bind /dev $TMP_MOUNT_PATH/dev
-    # Kernel commit https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=eedf265aa003b4781de24cfed40a655a664457e6
-    # introduced in v4.7 allows multiple instances of devpts. However,
-    # some distributions are running older kernels so we need to take
-    # care on what options we use to mount a new instance of devpts
-    # filesystem since it's not completely independent. The best thing
-    # to do is to simply use the existing mount options.
-    sudo mount -t devpts -o $(mount | grep devpts | sed 's/.*(\(.*\))/\1/') devpts $TMP_MOUNT_PATH/dev/pts
+    sudo mount -t devpts $(mount_dev_pts_options) devpts $TMP_MOUNT_PATH/dev/pts
     sudo mount -t sysfs none $TMP_MOUNT_PATH/sys
 }