diff --git a/scripts/mkbootfs.py b/scripts/mkbootfs.py
index b1a67a8481dc3d27da69e01f6966ab89b723036c..00a540a8cb0a865c9d0e378e814f1008eaaf9257 100755
--- a/scripts/mkbootfs.py
+++ b/scripts/mkbootfs.py
@@ -63,7 +63,22 @@ def expand(items):
         else:
             yield (name, hostname)
 
+def unsymlink(f):
+    try:
+        link = os.readlink(f)
+        if link.startswith('/'):
+            # try to find a match
+            base = os.path.dirname(f)
+            while not os.path.exists(base + link):
+                base = os.path.dirname(base)
+        else:
+            base = os.path.dirname(f) + '/'
+        return unsymlink(base + link)
+    except Exception:
+        return f
+
 files = list(expand(files.items()))
+files = [(x, unsymlink(y)) for (x, y) in files]
 
 pos = (len(files) + 1) * metadata_size