Avoid the /dev/loop0 busy condition. #345

Closed
opened 2024-03-27 06:54:29 +00:00 by phoepsilonix · 5 comments
phoepsilonix commented 2024-03-27 06:54:29 +00:00 (Migrated from gitlab2.manjaro.org)

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}
 
When using the loopback device, the losetup command is used to resolve permission issues. ```diff:0001-losetup.patch 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 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} ```
phoepsilonix commented 2024-03-27 06:55:19 +00:00 (Migrated from gitlab2.manjaro.org)

mentioned in issue packages/extra/manjaro-tools-git#3

mentioned in issue packages/extra/manjaro-tools-git#3
phoepsilonix commented 2024-03-27 06:57:56 +00:00 (Migrated from gitlab2.manjaro.org)

changed the description

changed the description
phoepsilonix commented 2024-03-27 06:58:08 +00:00 (Migrated from gitlab2.manjaro.org)

changed the description

changed the description
oberon commented 2024-03-27 13:00:41 +00:00 (Migrated from gitlab2.manjaro.org)

created branch 345-avoid-the-dev-loop0-busy-condition to address this issue

created branch [`345-avoid-the-dev-loop0-busy-condition`](/tools/development-tools/manjaro-tools/-/compare/master...345-avoid-the-dev-loop0-busy-condition) to address this issue
oberon commented 2024-03-27 13:01:11 +00:00 (Migrated from gitlab2.manjaro.org)

mentioned in merge request !670

mentioned in merge request !670
oberon (Migrated from gitlab2.manjaro.org) closed this issue 2024-03-27 13:24:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
tools/manjaro-tools#345
No description provided.