From f6f1496163560bd1482221d6cab11f634f22ce05 Mon Sep 17 00:00:00 2001
From: Christopher Spinrath <christopher.spinrath@rwth-aachen.de>
Date: Tue, 1 Sep 2015 21:28:31 +0200
Subject: [PATCH] image_umount_if: unount only if something is mounted

---
 Makefile | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 671ed5b..52d4a58 100644
--- a/Makefile
+++ b/Makefile
@@ -493,8 +493,10 @@ image_mount_if : $(IMAGE_PART_FILE)
 	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" = "$(IMAGE_DIR)" ] \
 		|| mount "$(IMAGE_PART_FILE)" "$(IMAGE_DIR)"
 
-image_umount :
-	umount -d "$(IMAGE_DIR)"
+image_umount_if :
+	#if something is mounted then umount
+	[ "$$(findmnt --target "$(IMAGE_DIR)" -f -n --output=target)" != "$(IMAGE_DIR)" ] \
+		|| umount -d "$(IMAGE_DIR)"
 
 image : image_content $(GRUB_ASSEMBLE_DIR)/mbr.img
 
-- 
GitLab