
diff --git a/pkg/oci/image.go b/pkg/oci/image.go
index 56f9c9b41..a8e6355d5 100644
--- a/pkg/oci/image.go
+++ b/pkg/oci/image.go
@@ -30,6 +30,13 @@ import (
 	"github.com/mudler/LocalAI/pkg/xio"
 )
 
+// stagingDirName is the directory created beside an extraction target to
+// stage in-flight image downloads. Staging lives on the destination's
+// filesystem rather than os.TempDir(): /tmp is commonly a RAM-backed
+// tmpfs far smaller than a backend image, while the destination must
+// hold the extracted bytes anyway.
+const stagingDirName = "downloading"
+
 // ref: https://github.com/mudler/luet/blob/master/pkg/helpers/docker/docker.go#L117
 type staticAuth struct {
 	auth *registrytypes.AuthConfig
@@ -325,8 +332,15 @@ func (pw *progressWriter) Write(p []byte) (int, error) {
 
 // ExtractOCIImage will extract a given targetImage into a given targetDestination
 func ExtractOCIImage(ctx context.Context, img v1.Image, imageRef string, targetDestination string, downloadStatus func(string, string, string, float64)) error {
-	// Create a temporary tar file
-	tmpTarFile, err := os.CreateTemp("", "localai-oci-*.tar")
+	// One level above the destination's parent: for a backend install
+	// (backends/<name>) staging must not live inside the scanned
+	// backends directory itself.
+	downloadDir := filepath.Join(filepath.Dir(filepath.Dir(filepath.Clean(targetDestination))), stagingDirName)
+	if err := os.MkdirAll(downloadDir, 0755); err != nil {
+		return fmt.Errorf("failed to create staging directory: %v", err)
+	}
+	defer os.Remove(downloadDir)
+	tmpTarFile, err := os.CreateTemp(downloadDir, "localai-oci-*.tar")
 	if err != nil {
 		return fmt.Errorf("failed to create temporary tar file: %v", err)
 	}
@@ -504,7 +518,7 @@ func DownloadOCIImageTar(ctx context.Context, img v1.Image, imageRef string, tar
 	}
 
 	// Create a temporary directory to store the compressed layers
-	tmpDir, err := os.MkdirTemp("", "localai-oci-layers-*")
+	tmpDir, err := os.MkdirTemp(filepath.Dir(tarFilePath), "localai-oci-layers-*")
 	if err != nil {
 		return fmt.Errorf("failed to create temporary directory: %v", err)
 	}
