File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -130,6 +130,14 @@ function unpack() {
130130 fi
131131}
132132
133+ function detach_all_loopback(){
134+ # Cleans up mounted loopback devices from the image name
135+ # NOTE: it might need a better way to grep for the image name, its might clash with other builds
136+ for img in $( losetup | grep $1 | awk ' { print $1 }' ) ; do
137+ losetup -d $img
138+ done
139+ }
140+
133141function mount_image() {
134142 image_path=$1
135143 root_partition=$2
@@ -145,6 +153,8 @@ function mount_image() {
145153 echo " Mounting image $image_path on $mount_path , offset for boot partition is $boot_offset , offset for root partition is $root_offset "
146154
147155 # mount root and boot partition
156+
157+ detach_all_loopback $image_path
148158 sudo mount -o loop,offset=$root_offset $image_path $mount_path /
149159 if [[ " $boot_partition " != " $root_partition " ]]; then
150160 sudo mount -o loop,offset=$boot_offset ,sizelimit=$( expr $root_offset - $boot_offset ) $image_path $mount_path /boot
@@ -237,7 +247,7 @@ $start
237247p
238248w
239249FDISK
240-
250+ detach_all_loopback $image
241251 LODEV=$( losetup -f --show -o $offset $image )
242252 trap ' losetup -d $LODEV' EXIT
243253
You can’t perform that action at this time.
0 commit comments