[arch-releng] [PATCH 06/10] Drop to recovery shell when mounting main media filesystem fails.
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> --- archiso/hooks/archiso | 12 ++++++++++-- 1 files changed, 10 insertions(+), 2 deletions(-) diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso index 7b4d756..aac2d21 100644 --- a/archiso/hooks/archiso +++ b/archiso/hooks/archiso @@ -85,16 +85,24 @@ archiso_mount_handler() { if mount -r -t "${FSTYPE}" ${archisodevice} /bootmnt > /dev/null 2>&1; then if [ -e "${isomounts}" ]; then echo "SUCCESS: Mounted archiso volume successfully." + fserror="0" else echo "ERROR: Mounting was successful, but the ${isomounts} file does not exist." - exit 1 + fserror="1" fi else echo "ERROR; Failed to mount ${archisodevice} (FS is ${FSTYPE})" - exit 1 + fserror="1" fi else echo "ERROR: ${archisodevice} found, but the filesystem type is unknown." + fserror="1" + fi + + if [ "${fserror}" = "1" ]; then + echo " Falling back to interactive prompt" + echo " You can try to fix the problem manually, log out when you are finished" + launch_interactive_shell fi msg ":: Mounting root (aufs) filesystem" -- 1.6.6.1
* 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> --- archiso/hooks/archiso | 26 ++++++++------------------ archiso/install/archiso | 1 + 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso index aac2d21..9ba539f 100644 --- a/archiso/hooks/archiso +++ b/archiso/hooks/archiso @@ -9,11 +9,11 @@ _mnt_bind() # args: /path/to/image_file _mnt_squashfs() { - /sbin/modprobe -q loop > /dev/null 2>&1 - img="${1}" - base_img="${img##*/}"; mnt="${2}" + img_fullname="${img##*/}"; + img_name="${img_fullname%.*}" + tmp_mnt="/tmpfs/mnt/${img_name}" # FIX: This options does not work (see FS#17182) if [ "${copytoram}" = "y" ]; then @@ -22,23 +22,14 @@ _mnt_squashfs() img="/tmpfs/${base_img}" fi - msg "::: Adding new aufs branch: ${base_img%.*}" - mkdir -p "/tmpfs/mnt/loop${LOOP_NUM}" - # sometimes it takes udev a while to create device nodes - 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}" + msg "::: Adding new aufs branch: ${img_name}" + mkdir -p "${tmp_mnt}" + /bin/mount -r -t squashfs "${img}" "${tmp_mnt}" 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 - _mnt_bind "/tmpfs/mnt/loop${LOOP_NUM}" "${mnt}" + _mnt_bind "${tmp_mnt}" "${mnt}" fi - export LOOP_NUM=$(( $LOOP_NUM + 1 )) } run_hook () @@ -112,7 +103,6 @@ archiso_mount_handler() { exit 1 fi - export LOOP_NUM="0" msg ":: Mounting images" while read img imgarch mountpoint type; do # check if this line is a comment (starts with #) diff --git a/archiso/install/archiso b/archiso/install/archiso index 5978f33..4d36412 100644 --- a/archiso/install/archiso +++ b/archiso/install/archiso @@ -11,6 +11,7 @@ install () FILES="" add_dir /tmpfs add_dir /bootmnt + add_device /dev/loop0 b 7 0 SCRIPT="archiso" } -- 1.6.6.1
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> --- archiso/hooks/archiso | 18 ++++++++++-------- 1 files changed, 10 insertions(+), 8 deletions(-) diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso index 9ba539f..d9b0984 100644 --- a/archiso/hooks/archiso +++ b/archiso/hooks/archiso @@ -1,9 +1,11 @@ # args: source, mountpoint _mnt_bind() { - msg "::: Binding ${1} to ${2}" - mkdir -p $newroot${2} - /bin/mount -o bind ${1} $newroot${2} + src="${1}" + mnt="${2}" + msg "::: Binding ${src} to ${mnt}" + mkdir -p "${mnt}" + /bin/mount -o bind "${src}" "${mnt}" } # args: /path/to/image_file @@ -25,8 +27,8 @@ _mnt_squashfs() msg "::: Adding new aufs branch: ${img_name}" mkdir -p "${tmp_mnt}" /bin/mount -r -t squashfs "${img}" "${tmp_mnt}" - if [ "${mnt}" = "/" ]; then - /bin/mount -t aufs -o remount,append:${tmp_mnt}=ro none "$newroot" + if [ "/${mnt#/*/}" = "/" ]; then + /bin/mount -t aufs -o remount,append:"${tmp_mnt}"=ro none "${mnt}" else _mnt_bind "${tmp_mnt}" "${mnt}" fi @@ -113,14 +115,14 @@ archiso_mount_handler() { [ ! -r "/bootmnt/${img}" ] && continue if [ "${type}" = "bind" ]; then - _mnt_bind "/bootmnt/${img}" ${mountpoint} + _mnt_bind "/bootmnt/${img}" "${newroot}${mountpoint}" elif [ "${type}" = "squashfs" ]; then - _mnt_squashfs "/bootmnt/${img}" "${mountpoint}" + _mnt_squashfs "/bootmnt/${img}" "${newroot}${mountpoint}" fi done < "${isomounts}" # Bind our bootmnt dir into the live system - _mnt_bind /bootmnt /bootmnt + _mnt_bind /bootmnt "${newroot}/bootmnt" if [ "${FSTYPE}" = "iso9660" -o "${FSTYPE}" = "udf" ]; then if [ -d /proc/sys/dev/cdrom ]; then -- 1.6.6.1
Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> --- archiso/hooks/archiso | 23 ++++++++++------------- 1 files changed, 10 insertions(+), 13 deletions(-) diff --git a/archiso/hooks/archiso b/archiso/hooks/archiso index d9b0984..ad86764 100644 --- a/archiso/hooks/archiso +++ b/archiso/hooks/archiso @@ -1,6 +1,5 @@ # args: source, mountpoint -_mnt_bind() -{ +_mnt_bind() { src="${1}" mnt="${2}" msg "::: Binding ${src} to ${mnt}" @@ -8,9 +7,8 @@ _mnt_bind() /bin/mount -o bind "${src}" "${mnt}" } -# args: /path/to/image_file -_mnt_squashfs() -{ +# args: /path/to/image_file, mountpoint +_mnt_squashfs() { img="${1}" mnt="${2}" img_fullname="${img##*/}"; @@ -34,8 +32,7 @@ _mnt_squashfs() fi } -run_hook () -{ +run_hook () { if [ "x${arch}" = "x" ]; then arch="$(uname -m)" fi @@ -59,7 +56,7 @@ run_hook () } archiso_mount_handler() { - newroot="$1" + newroot="${1}" msg -n ":: Mounting tmpfs, size=${tmpfs_size}..." mount -t tmpfs -o "size=${tmpfs_size}" tmpfs /tmpfs @@ -67,10 +64,10 @@ archiso_mount_handler() { msg ":: Waiting for boot device..." while ! poll_device ${archisodevice} 30; do - echo "ERROR: boot device didn't show up after 30 seconds..." - echo " Falling back to interactive prompt" - echo " You can try to fix the problem manually, log out when you are finished" - launch_interactive_shell + echo "ERROR: boot device didn't show up after 30 seconds..." + echo " Falling back to interactive prompt" + echo " You can try to fix the problem manually, log out when you are finished" + launch_interactive_shell done FSTYPE=$(blkid -o value -s TYPE ${archisodevice} 2> /dev/null) @@ -99,7 +96,7 @@ archiso_mount_handler() { fi msg ":: Mounting root (aufs) filesystem" - /bin/mount -t aufs -o dirs=/tmpfs=rw none $newroot + /bin/mount -t aufs -o dirs=/tmpfs=rw none "${newroot}" if [ $? -ne 0 ]; then echo "ERROR: while mounting root (aufs) filesystem." exit 1 -- 1.6.6.1
participants (1)
-
Gerardo Exequiel Pozzi