diff --git a/lfs/Config b/lfs/Config
index d63a1dc9a..c667a3cc7 100644
--- a/lfs/Config
+++ b/lfs/Config
@@ -209,7 +209,7 @@ define PAK
 	tar xf /install/packages/package/files.tmp -C /install/packages/package/tmp/ \
 		-p --numeric-owner
 	rm -f /install/packages/package/files.tmp
-	cd /install/packages/package/tmp/ && XZ_OPT=-T0 tar -c -p --numeric-owner -J -f /install/packages/package/files.tar.xz *
+	cd /install/packages/package/tmp/ && XZ_OPT="$(XZ_OPT)" tar -c -p --numeric-owner -J -f /install/packages/package/files.tar.xz *
 	rm -r /install/packages/package/tmp
 	-cat /install/packages/package/ROOTFILES | grep -v "#" > /install/packages/package/ROOTFILES.tmp
 	mv /install/packages/package/ROOTFILES.tmp /install/packages/package/ROOTFILES
diff --git a/lfs/cdrom b/lfs/cdrom
index 7a7fff166..820c55b87 100644
--- a/lfs/cdrom
+++ b/lfs/cdrom
@@ -35,9 +35,6 @@ else
 	TAR_OPTIONS = --xz
 endif
 
-# Enable multi-threaded compression for LZMA
-export XZ_OPT = --threads=0
-
 ###############################################################################
 # Top-level Rules
 ###############################################################################
@@ -74,7 +71,7 @@ $(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
 
 	# Compress root filesystem
 	# Reason for this tar+untar+tar is removing of entries listed two or more in src/ROOTFILES
-	tar -c -C / --files-from=/tmp/ROOTFILES \
+	XZ_OPT="$(XZ_OPT)" tar -c -C / --files-from=/tmp/ROOTFILES \
 		-f /$(SNAME).tar --exclude='#*' --exclude='dev/pts/*' \
 		--exclude='proc/*' --exclude='tmp/ROOTFILES'
 	rm -f /tmp/ROOTFILES
diff --git a/make.sh b/make.sh
index 419f9fa95..b6f3f37d2 100755
--- a/make.sh
+++ b/make.sh
@@ -526,6 +526,7 @@ enterchroot() {
 		CCACHE_COMPRESS="${CCACHE_COMPRESS}" \
 		CCACHE_COMPILERCHECK="${CCACHE_COMPILERCHECK}" \
 		KVER="${KVER}" \
+		XZ_OPT="${XZ_OPT}" \
 		$(fake_environ) \
 		$(qemu_environ) \
 		"$@"
@@ -860,6 +861,21 @@ fi
 # Get the amount of memory in this build system
 HOST_MEM=$(system_memory)
 
+# Checking host memory, tuning XZ_OPT
+
+if [ $HOST_MEM -lt 16384 ]; then
+	print_build_stage "Host-Memory: $HOST_MEM MiB"
+	print_build_stage "Not enough host memory (less than 1024 MiB, please consider upgrading)"
+
+	exit 1
+
+else
+
+	XZ_MEM="$(( HOST_MEM * 7 / 10 ))MiB"
+	XZ_OPT="-T4 -8 --memory=$XZ_MEM"
+
+fi
+
 if [ -n "${BUILD_ARCH}" ]; then
 	configure_build "${BUILD_ARCH}"
 else
@@ -1760,7 +1776,7 @@ toolchain)
 	buildtoolchain
 	echo "`date -u '+%b %e %T'`: Create toolchain image for ${BUILD_ARCH}" | tee -a $LOGFILE
 	test -d $BASEDIR/cache/toolchains || mkdir -p $BASEDIR/cache/toolchains
-	cd $BASEDIR && XZ_OPT="-T0 -8" tar -Jc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.xz \
+	cd $BASEDIR && XZ_OPT="$(XZ_OPT)" tar -Jc --exclude='log/_build.*.log' -f cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.xz \
 		build/${TOOLS_DIR} build/bin/sh log >> $LOGFILE
 	md5sum cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.tar.xz \
 		> cache/toolchains/$SNAME-$VERSION-toolchain-$TOOLCHAINVER-${BUILD_ARCH}.md5
