diff --git a/.gitignore b/.gitignore
index 8e2378c..fd8e426 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,2 @@
 SOURCES/libguestfs.keyring
-SOURCES/supermin-5.1.19.tar.gz
+SOURCES/supermin-5.2.1.tar.gz
diff --git a/.supermin.metadata b/.supermin.metadata
index 30bf9b1..9b30f0a 100644
--- a/.supermin.metadata
+++ b/.supermin.metadata
@@ -1,2 +1,2 @@
 1bbc40f501a7fef9eef2a39b701a71aee2fea7c4 SOURCES/libguestfs.keyring
-20456d58b52a9274fe8689c95bf80183d957a93b SOURCES/supermin-5.1.19.tar.gz
+7a5a5ee7c9b13b88bc3e7719f4639da52a84aafd SOURCES/supermin-5.2.1.tar.gz
diff --git a/SOURCES/0001-Fix-Bytes-String-for-OCaml-4.06.patch b/SOURCES/0001-Fix-Bytes-String-for-OCaml-4.06.patch
deleted file mode 100644
index f03043d..0000000
--- a/SOURCES/0001-Fix-Bytes-String-for-OCaml-4.06.patch
+++ /dev/null
@@ -1,58 +0,0 @@
-From 5c5eff66dfaccb212b8906e769e40633d8b8f5e4 Mon Sep 17 00:00:00 2001
-From: "Richard W.M. Jones" <rjones@redhat.com>
-Date: Tue, 13 Feb 2018 08:20:52 +0000
-Subject: [PATCH 1/2] Fix Bytes/String for OCaml 4.06.
-
----
- src/format_ext2_kernel.ml |  4 ++--
- src/mode_build.ml         | 10 ++++++----
- 2 files changed, 8 insertions(+), 6 deletions(-)
-
-diff --git a/src/format_ext2_kernel.ml b/src/format_ext2_kernel.ml
-index d5d529d..98bff3a 100644
---- a/src/format_ext2_kernel.ml
-+++ b/src/format_ext2_kernel.ml
-@@ -290,9 +290,9 @@ and read_leshort chan offset =
- 
- and read_string chan offset len =
-   seek_in chan offset;
--  let buf = String.create len in
-+  let buf = Bytes.create len in
-   really_input chan buf 0 len;
--  buf
-+  Bytes.to_string buf
- 
- and copy_or_symlink_file copy_kernel src dest =
-   if not copy_kernel then
-diff --git a/src/mode_build.ml b/src/mode_build.ml
-index 95869cb..b5f5fa6 100644
---- a/src/mode_build.ml
-+++ b/src/mode_build.ml
-@@ -299,9 +299,10 @@ and update_appliance appliance lines = function
- (* Determine the [file_type] of [file], or exit with an error. *)
- and get_file_type file =
-   let chan = open_in file in
--  let buf = String.create 512 in
--  let len = input chan buf 0 (String.length buf) in
-+  let buf = Bytes.create 512 in
-+  let len = input chan buf 0 (Bytes.length buf) in
-   close_in chan;
-+  let buf = Bytes.to_string buf in
- 
-   if len >= 3 && buf.[0] = '\x1f' && buf.[1] = '\x8b' && buf.[2] = '\x08'
-   then                                  (* gzip-compressed file *)
-@@ -335,8 +336,9 @@ and get_file_content file buf len =
- and get_compressed_file_content zcat file =
-   let cmd = sprintf "%s %s" zcat (quote file) in
-   let chan_out, chan_in, chan_err = open_process_full cmd [||] in
--  let buf = String.create 512 in
--  let len = input chan_out buf 0 (String.length buf) in
-+  let buf = Bytes.create 512 in
-+  let len = input chan_out buf 0 (Bytes.length buf) in
-+  let buf = Bytes.to_string buf in
-   (* We're expecting the subprocess to fail because we close the pipe
-    * early, so:
-    *)
--- 
-2.19.0.rc0
-
diff --git a/SOURCES/0001-Open-Unix.LargeFile-to-avoid-lstat-Value-too-large-f.patch b/SOURCES/0001-Open-Unix.LargeFile-to-avoid-lstat-Value-too-large-f.patch
new file mode 100644
index 0000000..c5d4ea3
--- /dev/null
+++ b/SOURCES/0001-Open-Unix.LargeFile-to-avoid-lstat-Value-too-large-f.patch
@@ -0,0 +1,180 @@
+From fd9f17c7eb63979af882533a0d234bfc8ca42de3 Mon Sep 17 00:00:00 2001
+From: "Richard W.M. Jones" <rjones@redhat.com>
+Date: Mon, 1 Feb 2021 10:07:02 +0000
+Subject: [PATCH] Open Unix.LargeFile to avoid "lstat: Value too large for
+ defined data type".
+
+On 32 bit platforms, because OCaml native ints are limited to 31 bits,
+there is a trap in the normal Unix.stat, Unix.lstat functions where
+any field in the stat struct may overflow.  The result is random
+errors like:
+
+  supermin: error: lstat: Value too large for defined data type: /tmp/tmp.Ss9aYEBASm/d2/root
+
+You would probably only see this on armv7.
+
+The OCaml Unix module has a "LargeFile" submodule which fixes this by
+using int64 for some (unfortunately not all) fields.
+
+For more information see the OCaml sources, file
+otherlibs/unix/stat.c, all instances of "EOVERFLOW".
+---
+ src/format_chroot.ml      | 1 +
+ src/format_ext2.ml        | 1 +
+ src/format_ext2_initrd.ml | 1 +
+ src/format_ext2_kernel.ml | 5 +++--
+ src/mode_build.ml         | 1 +
+ src/package_handler.ml    | 1 +
+ src/ph_dpkg.ml            | 1 +
+ src/ph_pacman.ml          | 1 +
+ src/ph_rpm.ml             | 1 +
+ src/supermin.ml           | 1 +
+ src/utils.ml              | 1 +
+ 11 files changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/src/format_chroot.ml b/src/format_chroot.ml
+index 346c24b..34606f7 100644
+--- a/src/format_chroot.ml
++++ b/src/format_chroot.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/format_ext2.ml b/src/format_ext2.ml
+index 6348c29..e311ea6 100644
+--- a/src/format_ext2.ml
++++ b/src/format_ext2.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/format_ext2_initrd.ml b/src/format_ext2_initrd.ml
+index 38977e6..6268442 100644
+--- a/src/format_ext2_initrd.ml
++++ b/src/format_ext2_initrd.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/format_ext2_kernel.ml b/src/format_ext2_kernel.ml
+index 98bff3a..3be4413 100644
+--- a/src/format_ext2_kernel.ml
++++ b/src/format_ext2_kernel.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+@@ -95,8 +96,8 @@ and find_kernel_from_lib_modules debug =
+     let kernels =
+       filter_map (
+         fun kernel_file ->
+-          let size = try (stat kernel_file).st_size with Unix_error _ -> 0 in
+-          if size < 10000 then None
++          let size = try (stat kernel_file).st_size with Unix_error _ -> 0L in
++          if size < 10000_L then None
+           else (
+             let kernel_name = Filename.basename kernel_file in
+             let modpath = Filename.dirname kernel_file in
+diff --git a/src/mode_build.ml b/src/mode_build.ml
+index ed47366..ff7733e 100644
+--- a/src/mode_build.ml
++++ b/src/mode_build.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/package_handler.ml b/src/package_handler.ml
+index 0409438..f0d6db3 100644
+--- a/src/package_handler.ml
++++ b/src/package_handler.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/ph_dpkg.ml b/src/ph_dpkg.ml
+index 1e785de..6d4fce1 100644
+--- a/src/ph_dpkg.ml
++++ b/src/ph_dpkg.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/ph_pacman.ml b/src/ph_pacman.ml
+index 67f7512..50500a5 100644
+--- a/src/ph_pacman.ml
++++ b/src/ph_pacman.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/ph_rpm.ml b/src/ph_rpm.ml
+index 9745efd..183b5f3 100644
+--- a/src/ph_rpm.ml
++++ b/src/ph_rpm.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Utils
+diff --git a/src/supermin.ml b/src/supermin.ml
+index e923111..9f838d9 100644
+--- a/src/supermin.ml
++++ b/src/supermin.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ open Types
+diff --git a/src/utils.ml b/src/utils.ml
+index b25df88..f5990ef 100644
+--- a/src/utils.ml
++++ b/src/utils.ml
+@@ -17,6 +17,7 @@
+  *)
+ 
+ open Unix
++open Unix.LargeFile
+ open Printf
+ 
+ let (+^) = Int64.add
+-- 
+2.29.0.rc2
+
diff --git a/SOURCES/0001-Use-external-command-mv-to-rename-old-output-directo.patch b/SOURCES/0001-Use-external-command-mv-to-rename-old-output-directo.patch
deleted file mode 100644
index c701ebe..0000000
--- a/SOURCES/0001-Use-external-command-mv-to-rename-old-output-directo.patch
+++ /dev/null
@@ -1,38 +0,0 @@
-From 6579cf5f72d5de345ae1cc97d0344dfa1771460a Mon Sep 17 00:00:00 2001
-From: "Richard W.M. Jones" <rjones@redhat.com>
-Date: Mon, 28 Jan 2019 22:20:33 +0000
-Subject: [PATCH] Use external command mv to rename old output directory
- (RHBZ#1670191).
-
-See https://bugzilla.redhat.com/show_bug.cgi?id=1670191#c0
-for explanation.
-
-Thanks: Sam Eiderman
----
- src/supermin.ml | 10 ++++------
- 1 file changed, 4 insertions(+), 6 deletions(-)
-
-diff --git a/src/supermin.ml b/src/supermin.ml
-index 71d8b64..7c7135b3 100644
---- a/src/supermin.ml
-+++ b/src/supermin.ml
-@@ -264,12 +264,10 @@ appliance automatically.
- 
-   (* Delete the old output directory if it exists. *)
-   let old_outputdir =
--    try
--      let old_outputdir = outputdir ^ "." ^ string_random8 () in
--      rename outputdir old_outputdir;
--      Some old_outputdir
--    with
--      Unix_error _ -> None in
-+    let old_outputdir = outputdir ^ "." ^ string_random8 () in
-+    let cmd = sprintf "mv %s %s 2>/dev/null"
-+                      (quote outputdir) (quote old_outputdir) in
-+    if Sys.command cmd == 0 then Some old_outputdir else None in
- 
-   if debug >= 1 then
-     printf "supermin: renaming %s to %s\n%!" new_outputdir outputdir;
--- 
-2.22.0
-
diff --git a/SOURCES/0002-build-Pass-CFLAGS-LDFLAGS-to-final-supermin-link-RHB.patch b/SOURCES/0002-build-Pass-CFLAGS-LDFLAGS-to-final-supermin-link-RHB.patch
deleted file mode 100644
index 389454b..0000000
--- a/SOURCES/0002-build-Pass-CFLAGS-LDFLAGS-to-final-supermin-link-RHB.patch
+++ /dev/null
@@ -1,34 +0,0 @@
-From 34f0b5e73dca76e27d65af6d4709d45d256c8f3f Mon Sep 17 00:00:00 2001
-From: "Richard W.M. Jones" <rjones@redhat.com>
-Date: Fri, 31 Aug 2018 09:00:44 +0100
-Subject: [PATCH 2/2] build: Pass CFLAGS & LDFLAGS to final supermin link
- (RHBZ#1624175).
-
-We also use -runtime-variant _pic which selects the OCaml runtime
-linked with -fPIC.  This will cause a performance regression on i686
-although that probably doesn't matter now.
-
-A bigger issue is that it will stop supermin from building with older
-versions of OCaml (<= 4.02.2).  We might instead try detecting if it's
-the old version in ./configure but that gets a bit fragile.
----
- src/supermin-link.sh.in | 6 +++++-
- 1 file changed, 5 insertions(+), 1 deletion(-)
-
-diff --git a/src/supermin-link.sh.in b/src/supermin-link.sh.in
-index 29b84a1..b7fded6 100644
---- a/src/supermin-link.sh.in
-+++ b/src/supermin-link.sh.in
-@@ -21,4 +21,8 @@
- # Hack automake to link 'supermin' binary properly.  There is no other
- # way to add the -cclib parameter to the end of the command line.
- 
--exec "$@" -linkpkg -cclib '@EXT2FS_LIBS@ @COM_ERR_LIBS@ @LIBRPM_LIBS@'
-+exec "$@" \
-+     -linkpkg \
-+     -runtime-variant _pic \
-+     -ccopt '@CFLAGS@' \
-+     -cclib '@LDFLAGS@ @EXT2FS_LIBS@ @COM_ERR_LIBS@ @LIBRPM_LIBS@'
--- 
-2.19.0.rc0
-
diff --git a/SOURCES/supermin-5.1.19.tar.gz.sig b/SOURCES/supermin-5.1.19.tar.gz.sig
deleted file mode 100644
index 4243209..0000000
--- a/SOURCES/supermin-5.1.19.tar.gz.sig
+++ /dev/null
@@ -1,16 +0,0 @@
------BEGIN PGP SIGNATURE-----
-
-iQIcBAABAgAGBQJZwR6OAAoJEJFzj3Pht2igbngP/1/pVFvkQurS8BZjon56yfnd
-10F8hc9rvBPmzjSCozPgm45dSRGbAWSzm0keiyZmSq9MDm/v+ynxI938JZ3+guyW
-NjJTWWqNvg75+LR6+j8CwxK7LmcJj4r/bHCqYS2dYbQlTLvBGoGlko0BevYp9kdW
-bm0ZuT7ls8jvZd6Zz9Evy3g/48MMGjVY8tw/dSSuK+fPWVB6eDg5yWiv/jlbLTKK
-0X6aJV9xje4pdHI46wYbXdqCMkh/vQfbfZzEXJ06wBogc+3pk2sQE6u7vjcaPv6s
-O0I93xAdK8O9Bjf6qIrRjv1fxzqkCJZImW9+AX+LBV7BClmzPBHehFmm6U2xE+AN
-HXU/CKKWlECi7VCdAMhQdovh74Qeh2FvMQy3pCSwLZ/lrKhN97B4rI4I4iHPSi42
-4mvtBVFe1avC56G+Gd78byOMWLz3PQjCgnWlYU3hrlMiDoeuTZjAgRDwym96waso
-sATqKNHljPUQLKhvv7K2A7Zs9nOTs/j2Gnni/FnjQGAzH3x2T/sihqZNShxXHBKB
-NFPcfhGcF8NqonWKyhwxg9pjUWFlY9x6B8jJz8fYCEbtnXDFfcdL5Jgz6N+MUsi9
-ZbyXPW4vCPgEmx+KMCBffpmYRAMvuuCE/2Y4fJ6iMlSV6QAIOtJUkCmImKnIhpei
-uXWUvUCc2RUiCdM/yAU6
-=28E/
------END PGP SIGNATURE-----
diff --git a/SOURCES/supermin-5.2.1.tar.gz.sig b/SOURCES/supermin-5.2.1.tar.gz.sig
new file mode 100644
index 0000000..3aa05b4
--- /dev/null
+++ b/SOURCES/supermin-5.2.1.tar.gz.sig
@@ -0,0 +1,17 @@
+-----BEGIN PGP SIGNATURE-----
+
+iQJFBAABCAAvFiEE93dPsa0HSn6Mh2fqkXOPc+G3aKAFAmAXzH4RHHJpY2hAYW5u
+ZXhpYS5vcmcACgkQkXOPc+G3aKDLlxAAuqTnWZF8M4KYwSY1XydtgsF4CGjUmhHM
+/L6KRsVOR7+hc/yevg/ZJMYieRs1jSW0FHh/16AdRjLRuLhV4BFZGd3wybbYsNUe
+aIrbG4dna7pjRYN6wKZIWTNfiYnf7Mqd0MvTfU6rUN0P8O0skbI1xUpcDnViP+GR
+sI+yIhM/EpithouoRBqz3sSDtkImXbepSphhnxMb64At6eLWDD09F32uHSqMBALI
+ThFeu6mGWNvdsbJAVzDjoXGOynthMLGSb4mE0+uPDP3rFs0FhygNtcdn2KQDTG1S
+Jd7MQ2/3w/BilSDTUY/sxqED04GSARxKINgFIOcmHvDnyPltLRX8ET8hCtCkNT1Y
+6DgOvUpf77cRKZR6PiQYwor7/bvCwWmOF4AtEaq1x6aWm4D/qFrtN+ofWYsJC5Kz
+qBEas7lR40SiiE8EKFDdEoyazps4ZVl5RpZO6Re4yhPbtLhiT8hwzyyNaia9MTyU
+k6hU8fivnvnMCAwksJwBN35HxCRgHpOK/CP1IvoxuGA0Q5zwDp7KiHqQjszI5LIa
+i2N4VNVwRi/MRrtu7l+B63elKH52SFOJhnLUdUhAJFVhB1jqXZ2y8kOWiZwB2dFc
+7KPfkyGRoK39U7ipoI5sUThxl7tfkJSHpbo9/SEL7wFx2fL64oCqdz6t5T4ERPia
+6ZGfgCLJNMU=
+=aVXZ
+-----END PGP SIGNATURE-----
diff --git a/SPECS/supermin.spec b/SPECS/supermin.spec
index 0a31ca5..1ac0b68 100644
--- a/SPECS/supermin.spec
+++ b/SPECS/supermin.spec
@@ -1,38 +1,47 @@
-%ifnarch %{ocaml_native_compiler}
-%global __strip /bin/true
-%global debug_package %{nil}
+# On platforms and architectures that support it, the default is
+# ‘--with dietlibc’.
+#
+# To use glibc-static instead, do ‘--without dietlibc’.  This results
+# in a much larger (about 40 times larger) init binary.
+#
+# On other platforms, there is no dietlibc, so the default for those
+# is ‘--without dietlibc’.
+#
+# See also:
+# https://github.com/libguestfs/supermin/commit/9bb57e1a8d0f3b57eb09f65dd574f702b67e1c2f
+
+%if 0%{?rhel}
+%bcond_with dietlibc
+%else
+%ifarch aarch64 %{arm} %{ix86} %{power} s390x x86_64
+%bcond_without dietlibc
+%else
+%bcond_with dietlibc
+%endif
 %endif
 
 # Whether we should verify tarball signature with GPGv2.
 %global verify_tarball_signature 1
 
+# The source directory.
+%global source_directory 5.2-stable
+
 Summary:       Tool for creating supermin appliances
 Name:          supermin
-Version:       5.1.19
-Release:       10%{?dist}
+Version:       5.2.1
+Release:       1%{?dist}
 License:       GPLv2+
 
-ExcludeArch: i686
+ExcludeArch:   %{ix86}
 
 URL:           http://people.redhat.com/~rjones/supermin/
-Source0:       http://libguestfs.org/download/supermin/%{name}-%{version}.tar.gz
-%if 0%{verify_tarball_signature}
-Source1:       http://libguestfs.org/download/supermin/%{name}-%{version}.tar.gz.sig
-%endif
-
+Source0:       http://download.libguestfs.org/supermin/%{source_directory}/%{name}-%{version}.tar.gz
+Source1:       http://download.libguestfs.org/supermin/%{source_directory}/%{name}-%{version}.tar.gz.sig
 # Keyring used to verify tarball signature.
-%if 0%{verify_tarball_signature}
 Source2:       libguestfs.keyring
-%endif
-
-# Upstream patch which fixes byte/string problems.
-Patch1:        0001-Fix-Bytes-String-for-OCaml-4.06.patch
-
-# Pass CFLAGS & LDFLAGS to final supermin link (RHBZ#1624175).
-Patch2:        0002-build-Pass-CFLAGS-LDFLAGS-to-final-supermin-link-RHB.patch
 
-# Upstream fix for supermin failing in docker.
-Patch3:        0001-Use-external-command-mv-to-rename-old-output-directo.patch
+# Upstream fix for stat field overflow on armv7.
+Patch1:        0001-Open-Unix.LargeFile-to-avoid-lstat-Value-too-large-f.patch
 
 BuildRequires: /usr/bin/pod2man
 BuildRequires: /usr/bin/pod2html
@@ -43,7 +52,11 @@ BuildRequires: dnf-plugins-core
 BuildRequires: /usr/sbin/mke2fs
 BuildRequires: e2fsprogs-devel
 BuildRequires: findutils
+%if %{with dietlibc}
+BuildRequires: dietlibc-devel
+%else
 BuildRequires: glibc-static
+%endif
 BuildRequires: ocaml, ocaml-findlib-devel
 %if 0%{verify_tarball_signature}
 BuildRequires: gnupg2
@@ -110,6 +123,9 @@ gpgv2 --homedir "$tmphome" --keyring %{SOURCE2} %{SOURCE1} %{SOURCE0}
 %build
 %configure --disable-network-tests
 
+%if %{with dietlibc}
+make -C init CC="diet gcc"
+%endif
 make %{?_smp_mflags}
 
 
@@ -148,6 +164,10 @@ make check || {
 
 
 %changelog
+* Thu Sep 2 2021 Danilo C. L. de Paula <ddepaula@redhat.com> - 5.2.1-1.el8
+- Resolves: bz#2000225
+  (Rebase virt:rhel module:stream based on AV-8.6)
+
 * Mon Apr 27 2020 Danilo C. L. de Paula <ddepaula@redhat.com> - 5.1.19
 - Resolves: bz#1810193
   (Upgrade components in virt:rhel module:stream for RHEL-8.3 release)