From 90794d7cddf1289323b7d8956bcc5c061126a2f9 Mon Sep 17 00:00:00 2001 From: Gerardo Exequiel Pozzi Date: Tue, 30 Nov 2010 22:16:19 -0300 Subject: [archiso] Add support to mount iso in loopback mode. Add two parameters: img_dev=/dev/sdNM where /dev/sdNM is the device where .iso is located. img_loop=/path/to/arch.iso where /path/to/arch.iso is the full path of the .iso in the device img_dev. Original idea from Baurzhan Muftakhidinov. Signed-off-by: Gerardo Exequiel Pozzi --- archiso/hooks/archiso_loop_mnt | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 archiso/hooks/archiso_loop_mnt (limited to 'archiso/hooks') diff --git a/archiso/hooks/archiso_loop_mnt b/archiso/hooks/archiso_loop_mnt new file mode 100644 index 0000000..0d5eba7 --- /dev/null +++ b/archiso/hooks/archiso_loop_mnt @@ -0,0 +1,33 @@ +# vim: set ft=sh: + +run_hook () { + if [ -n "${img_dev}" ] && [ -n "${img_loop}" ]; then + mount_handler="archiso_loop_mount_handler" + fi +} + +archiso_loop_mount_handler () { + newroot="${1}" + + while [ ! -b "${img_dev}" ]; do + sleep 1 + done + + msg "::: Setup a loop device from ${img_loop} located at device ${img_dev}" + FSTYPE=$(blkid -o value -s TYPE -p ${img_dev} 2> /dev/null) + if [ -n "${FSTYPE}" ]; then + if mount -r -t "${FSTYPE}" ${img_dev} /img_dev > /dev/null 2>&1; then + _dev_loop=$(losetup -f) + losetup ${_dev_loop} /img_dev/${img_loop} + fi + fi + + archiso_mount_handler ${newroot} + + if [ "${copytoram}" = "y" ]; then + msg "::: Deataching loop device ${_dev_loop}" + losetup -d ${_dev_loop} + msg "::: Unmounting ${img_dev}" + umount ${img_dev} + fi +} -- cgit v1.2.3-70-g09d2