diff --git a/meta/classes-global/sstate.bbclass b/meta/classes-global/sstate.bbclass
index 88449d19c7..2b18cafb60 100644
--- a/meta/classes-global/sstate.bbclass
+++ b/meta/classes-global/sstate.bbclass
@@ -795,6 +795,14 @@ python sstate_create_and_sign_package () {
         except:
             pass
 
+    # Create hardlink with fallback to rename. Useful for file systems that
+    # don't support hardlinks.
+    def hardlink(src, dst):
+        try:
+            os.link(src, dst)
+        except:
+            src.rename(dst)
+
     def update_file(src, dst, force=False):
         if dst.is_symlink() and not dst.exists():
             force=True
@@ -804,7 +812,7 @@ python sstate_create_and_sign_package () {
             if force:
                 src.rename(dst)
             else:
-                os.link(src, dst)
+                hardlink(src, dst)
             return True
         except:
             pass
@@ -862,7 +870,7 @@ python sstate_create_and_sign_package () {
         with NamedTemporaryFile(prefix=sstate_pkg.name, dir=sstate_pkg.parent) as tmp_pkg_fd:
             tmp_pkg = tmp_pkg_fd.name
             sstate_archive_package(tmp_pkg, d)
-            update_file(tmp_pkg, sstate_pkg)
+            update_file(Path(tmp_pkg), sstate_pkg)
             # update_file() may have renamed tmp_pkg, which must exist when the
             # NamedTemporaryFile() context handler ends.
             touch(Path(tmp_pkg))
