diff --git a/Makefile b/Makefile
index 13c62a71004cd779a82c59afc52b5beea32b3ddf..6d95a398420736646d13081e4272e837ee5e7e3e 100644
--- a/Makefile
+++ b/Makefile
@@ -22,6 +22,8 @@ include $(GLUON_SITEDIR)/site.mk
 
 GLUON_RELEASE ?= $(error GLUON_RELEASE not set. GLUON_RELEASE can be set in site.mk or on the command line)
 
+GLUON_DEPRECATED ?= $(error GLUON_DEPRECATED not set. Please consult the documentation)
+
 # initialize (possibly already user set) directory variables
 GLUON_TMPDIR ?= tmp
 GLUON_OUTPUTDIR ?= output
@@ -41,7 +43,7 @@ GLUON_MULTIDOMAIN ?= 0
 GLUON_WLAN_MESH ?= 11s
 GLUON_DEBUG ?= 0
 
-export GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_WLAN_MESH GLUON_DEBUG GLUON_DEVICES \
+export GLUON_RELEASE GLUON_REGION GLUON_MULTIDOMAIN GLUON_WLAN_MESH GLUON_DEBUG GLUON_DEPRECATED GLUON_DEVICES \
 	 GLUON_TARGETSDIR GLUON_PATCHESDIR GLUON_TMPDIR GLUON_IMAGEDIR GLUON_PACKAGEDIR
 
 show-release:
diff --git a/docs/multidomain-site-example/site.mk b/docs/multidomain-site-example/site.mk
index 7485ef1715340a6b9e8dc45736633d6a39b0df32..a268fd48d622f7b2ebe2b0bc2d8ca8b1e09f7de5 100644
--- a/docs/multidomain-site-example/site.mk
+++ b/docs/multidomain-site-example/site.mk
@@ -59,3 +59,6 @@ GLUON_REGION ?= eu
 
 # Languages to include
 GLUON_LANGS ?= en de
+
+# Do not build images for deprecated devices
+GLUON_DEPRECATED ?= 0
diff --git a/docs/site-example/site.mk b/docs/site-example/site.mk
index c39679092870f15973e6f799e45f33ae3b60f178..f8f84f975a379b661c575a5bd25fa90106d9fb16 100644
--- a/docs/site-example/site.mk
+++ b/docs/site-example/site.mk
@@ -53,3 +53,6 @@ GLUON_REGION ?= eu
 
 # Languages to include
 GLUON_LANGS ?= en de
+
+# Do not build images for deprecated devices
+GLUON_DEPRECATED ?= 0
diff --git a/docs/user/getting_started.rst b/docs/user/getting_started.rst
index 5e71f361f7ab3171a2fb23c9e5f79be6f91172ae..2b76bc81a762f6c661196f069f36e5ce74feb9b3 100644
--- a/docs/user/getting_started.rst
+++ b/docs/user/getting_started.rst
@@ -161,6 +161,19 @@ GLUON_BRANCH
   by default. For the ``make manifest`` command, GLUON_BRANCH defines the branch to
   generate a manifest for.
 
+GLUON_DEPRECATED
+  Controls whether images for deprecated devices should be built. The following
+  values are supported:
+
+  - ``0``: Do not build any images for deprecated devices.
+  - ``upgrade``: Only build sysupgrade images for deprecated devices.
+  - ``full``: Build both sysupgrade and factory images for deprecated devices.
+
+  Usually, devices are deprecated because their flash size is insufficient to
+  support future Gluon versions. The recommended setting is ``0`` for new sites,
+  and ``upgrade`` for existing configurations (where upgrades for existing
+  deployments of low-flash devices are required).
+
 GLUON_LANGS
   Space-separated list of languages to include for the config mode/advanced settings. Defaults to ``en``.
   ``en`` should always be included, other supported languages are ``de`` and ``fr``.
diff --git a/docs/user/site.rst b/docs/user/site.rst
index b1549b23b999941d2000e76c05134227e62dd8f0..13a78dbc7943f4ceefa8a9bc21ba86ac849eb30b 100644
--- a/docs/user/site.rst
+++ b/docs/user/site.rst
@@ -514,6 +514,19 @@ Build configuration
 The ``site.mk`` is a Makefile which defines various values
 involved in the build process of Gluon.
 
+GLUON_DEPRECATED
+    Controls whether images for deprecated devices should be built. The following
+    values are supported:
+
+    - ``0``: Do not build any images for deprecated devices.
+    - ``upgrade``: Only build sysupgrade images for deprecated devices.
+    - ``full``: Build both sysupgrade and factory images for deprecated devices.
+
+    Usually, devices are deprecated because their flash size is insufficient to
+    support future Gluon versions. The recommended setting is ``0`` for new sites,
+    and ``upgrade`` for existing configurations (where upgrades for existing
+    deployments of low-flash devices are required).
+
 GLUON_FEATURES
     Defines a list of features to include. The feature list is used to generate
     the default package set.
diff --git a/scripts/common.inc.lua b/scripts/common.inc.lua
index 0e365b369c0c753d463938fae6e3d266bb6c076d..0ec5a756ad25e7be1ef4e3dddebf19ee878c489b 100644
--- a/scripts/common.inc.lua
+++ b/scripts/common.inc.lua
@@ -8,6 +8,7 @@ envtrue = setmetatable({}, {
 assert(env.GLUON_SITEDIR)
 assert(env.GLUON_TARGETSDIR)
 assert(env.GLUON_RELEASE)
+assert(env.GLUON_DEPRECATED)
 
 
 site_code = assert(assert(dofile('scripts/site_config.lua')('site.conf')).site_code)
@@ -25,6 +26,7 @@ local default_options = {
 	aliases = {},
 	manifest_aliases = {},
 	packages = {},
+	deprecated = false,
 	broken = false,
 }
 
@@ -39,6 +41,9 @@ local function want_device(dev, options)
 	if options.broken and not envtrue.BROKEN then
 		return false
 	end
+	if options.deprecated and env.GLUON_DEPRECATED == '0' then
+		return false
+	end
 
 	if (env.GLUON_DEVICES or '') == '' then
 		return true
@@ -48,6 +53,8 @@ local function want_device(dev, options)
 	return gluon_devices[dev]
 end
 
+local full_deprecated = env.GLUON_DEPRECATED == 'full'
+
 
 local function merge(a, b)
 	local ret = {}
@@ -148,26 +155,31 @@ function device(image, name, options)
 		options = options,
 	})
 
-	if options.factory then
+	if options.sysupgrade then
 		add_image {
 			image = image,
 			name = name,
-			subdir = 'factory',
-			in_suffix = options.factory,
-			out_suffix = '',
-			extension = options.factory_ext,
+			subdir = 'sysupgrade',
+			in_suffix = options.sysupgrade,
+			out_suffix = '-sysupgrade',
+			extension = options.sysupgrade_ext,
 			aliases = options.aliases,
 			manifest_aliases = options.manifest_aliases,
 		}
 	end
-	if options.sysupgrade then
+
+	if options.deprecated and not full_deprecated then
+		return
+	end
+
+	if options.factory then
 		add_image {
 			image = image,
 			name = name,
-			subdir = 'sysupgrade',
-			in_suffix = options.sysupgrade,
-			out_suffix = '-sysupgrade',
-			extension = options.sysupgrade_ext,
+			subdir = 'factory',
+			in_suffix = options.factory,
+			out_suffix = '',
+			extension = options.factory_ext,
 			aliases = options.aliases,
 			manifest_aliases = options.manifest_aliases,
 		}
@@ -193,6 +205,10 @@ function factory_image(image, name, ext, options)
 		return
 	end
 
+	if options.deprecated and not full_deprecated then
+		return
+	end
+
 	add_image {
 		image = image,
 		name = name,