Take advantage of module autoloading when mounting images as loop
* Make first /dev/loop0 device at archiso install hook. * Remove unneeded losetup, all is done directly via mount. * Images are now mounted on /tmpfs/mnt/image-name instead of /tmpfs/mnt/loopN, removing unneeded counter. * Add some variables to make code more readable. Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar>
This commit is contained in:
parent
59d7a39994
commit
7d7dad06e2
@ -9,11 +9,11 @@ _mnt_bind()
|
|||||||
# args: /path/to/image_file
|
# args: /path/to/image_file
|
||||||
_mnt_squashfs()
|
_mnt_squashfs()
|
||||||
{
|
{
|
||||||
/sbin/modprobe -q loop > /dev/null 2>&1
|
|
||||||
|
|
||||||
img="${1}"
|
img="${1}"
|
||||||
base_img="${img##*/}";
|
|
||||||
mnt="${2}"
|
mnt="${2}"
|
||||||
|
img_fullname="${img##*/}";
|
||||||
|
img_name="${img_fullname%.*}"
|
||||||
|
tmp_mnt="/tmpfs/mnt/${img_name}"
|
||||||
|
|
||||||
# FIX: This options does not work (see FS#17182)
|
# FIX: This options does not work (see FS#17182)
|
||||||
if [ "${copytoram}" = "y" ]; then
|
if [ "${copytoram}" = "y" ]; then
|
||||||
@ -22,23 +22,14 @@ _mnt_squashfs()
|
|||||||
img="/tmpfs/${base_img}"
|
img="/tmpfs/${base_img}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
msg "::: Adding new aufs branch: ${base_img%.*}"
|
msg "::: Adding new aufs branch: ${img_name}"
|
||||||
mkdir -p "/tmpfs/mnt/loop${LOOP_NUM}"
|
mkdir -p "${tmp_mnt}"
|
||||||
# sometimes it takes udev a while to create device nodes
|
/bin/mount -r -t squashfs "${img}" "${tmp_mnt}"
|
||||||
while [ ! -e "/dev/loop${LOOP_NUM}" ]; do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
if ! /sbin/losetup "/dev/loop${LOOP_NUM}" ${img}; then
|
|
||||||
echo "ERROR: Cannot mount loop device /dev/loop${LOOP_NUM}"
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
/bin/mount -r -t squashfs "/dev/loop${LOOP_NUM}" "/tmpfs/mnt/loop${LOOP_NUM}"
|
|
||||||
if [ "${mnt}" = "/" ]; then
|
if [ "${mnt}" = "/" ]; then
|
||||||
/bin/mount -t aufs -o remount,append:/tmpfs/mnt/loop${LOOP_NUM}=ro none "$newroot"
|
/bin/mount -t aufs -o remount,append:${tmp_mnt}=ro none "$newroot"
|
||||||
else
|
else
|
||||||
_mnt_bind "/tmpfs/mnt/loop${LOOP_NUM}" "${mnt}"
|
_mnt_bind "${tmp_mnt}" "${mnt}"
|
||||||
fi
|
fi
|
||||||
export LOOP_NUM=$(( $LOOP_NUM + 1 ))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
run_hook ()
|
run_hook ()
|
||||||
@ -112,7 +103,6 @@ archiso_mount_handler() {
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export LOOP_NUM="0"
|
|
||||||
msg ":: Mounting images"
|
msg ":: Mounting images"
|
||||||
while read img imgarch mountpoint type; do
|
while read img imgarch mountpoint type; do
|
||||||
# check if this line is a comment (starts with #)
|
# check if this line is a comment (starts with #)
|
||||||
|
@ -11,6 +11,7 @@ install ()
|
|||||||
FILES=""
|
FILES=""
|
||||||
add_dir /tmpfs
|
add_dir /tmpfs
|
||||||
add_dir /bootmnt
|
add_dir /bootmnt
|
||||||
|
add_device /dev/loop0 b 7 0
|
||||||
SCRIPT="archiso"
|
SCRIPT="archiso"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user