Avoid the /dev/loop0 busy condition.

When using the loopback device, the losetup command is used to resolve permission issues.

diff --git a/lib/util-iso-mount.sh b/lib/util-iso-mount.sh
index 0c3e05b..b776b0d 100644
--- a/lib/util-iso-mount.sh
+++ b/lib/util-iso-mount.sh
@@ -11,7 +11,8 @@
 
 track_img() {
     info "mount: [%s]" "$2"
-    mount "$@" && IMG_ACTIVE_MOUNTS=("$2" "${IMG_ACTIVE_MOUNTS[@]}")
+    LOOPBACK=$(losetup --show -f "$1")
+    mount $LOOPBACK "$2" && IMG_ACTIVE_MOUNTS=("$2" "${IMG_ACTIVE_MOUNTS[@]}")
 }
 
 mount_img() {
@@ -24,6 +25,7 @@ umount_img() {
     if [[ -n ${IMG_ACTIVE_MOUNTS[@]} ]]; then
         info "umount: [%s]" "${IMG_ACTIVE_MOUNTS[@]}"
         umount "${IMG_ACTIVE_MOUNTS[@]}"
+        losetup -d $LOOPBACK
         unset IMG_ACTIVE_MOUNTS
         rm -r "$1"
     fi
diff --git a/lib/util-iso.sh b/lib/util-iso.sh
index edf50a0..8154067 100644
--- a/lib/util-iso.sh
+++ b/lib/util-iso.sh
@@ -323,6 +323,7 @@ make_image_root() {
         msg "Prepare [Base installation] (rootfs)"
         local path="${work_dir}/rootfs"
         mkdir -p ${path}
+        sync
 
         chroot_create "${path}" "${packages}" || die
 
@@ -349,6 +350,7 @@ make_image_desktop() {
         msg "Prepare [Desktop installation] (desktopfs)"
         local path="${work_dir}/desktopfs"
         mkdir -p ${path}
+        sync
 
         mount_fs_root "${path}"
 
@@ -393,6 +395,7 @@ make_image_live() {
         msg "Prepare [Live installation] (livefs)"
         local path="${work_dir}/livefs"
         mkdir -p ${path}
+        sync
 
         mount_fs_select "${path}"
 
@@ -434,6 +437,7 @@ make_image_mhwd() {
         msg "Prepare [drivers repository] (mhwdfs)"
         local path="${work_dir}/mhwdfs"
         mkdir -p ${path}${mhwd_repo}
+        sync
 
         mount_fs_select "${path}"
 
@@ -463,6 +467,7 @@ make_image_boot() {
         local boot="${iso_root}/boot"
 
         mkdir -p ${boot}
+        sync
 
         cp ${work_dir}/rootfs/boot/vmlinuz* ${boot}/vmlinuz-${target_arch}
 
Edited by phoepsilonix