Hi,
I just created patches against cdrom-detect-1.46, hw-detect-1.98 and
mountmedia-0.23. I hope that helps.
For the patch to work, the loop-module is needed in the initrd, so I
suggest to make it a dependency of cdrom-detect.
I furthermore highly recommend to make the ext4, ntfs and udf
modules dependencies of cdrom-detect, since these are the most common
filesystems and thus being able to loopmount from them would be good.
Best regards,
Andreas
diff -rup cdrom-detect-1.46.orig/debian/cdrom-detect.postinst cdrom-detect-1.46/debian/cdrom-detect.postinst
--- cdrom-detect-1.46.orig/debian/cdrom-detect.postinst 2011-03-23 03:00:14.000000000 +0100
+++ cdrom-detect-1.46/debian/cdrom-detect.postinst 2013-11-24 09:44:59.678577887 +0100
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/sh
set -e
. /usr/share/debconf/confmodule
@@ -14,26 +14,43 @@ fail() {
exit 1
}
+list_devices_by_id()
+{
+ local dir disk="$(echo "$1" | sed 's/ /\\x20/g')"
+ for dir in /dev/disk/by-label /dev/disk/by-uuid ; do
+ [ -e ${dir}/${disk} ] && echo ${dir}/${disk} || true
+ done
+}
+
+get_fstype ()
+{
+ /sbin/blkid -s TYPE -o value $1 2>/dev/null
+}
+
try_mount() {
local device=$1
local type=$2
+ local options=$3
+ local loopdev=$4
local ret=1
- if mount -t $type -o $OPTIONS $device /cdrom; then
- log "CD-ROM mount succeeded: device=$device fstype=$type"
+ if mount -o ${loopdev:+loop,}$options -t $type $device /cdrom; then
+ log "CD-ROM ${loopdev:+loop-}mount succeeded: device=$loopdev${device#/loop} fstype=$type"
if [ -e /cdrom/.disk/info ]; then
CDNAME=$(cat /cdrom/.disk/info)
log "Detected CD '$CDNAME'"
db_set cdrom-detect/cdrom_device $device
db_set cdrom-detect/cdrom_fs $type
+ db_set cdrom-detect/cdrom_options ${loopdev:+loop,}$options
+ db_set cdrom-detect/cdrom_loopdev $loopdev
ret=0
else
- log "The CD in $device is not a Debian CD!"
+ log "The CD in $loopdev${device#/loop} is not a Debian CD!"
umount /cdrom 2>/dev/null || true
WRONG=1
fi
else
- log "CD-ROM mount failed: device=$device fstype=$type"
+ log "CD-ROM ${loopdev:+loop-}mount failed: device=$loopdev${device#/loop} fstype=$type"
fi
return $ret
@@ -61,25 +78,21 @@ OS=$(udpkg --print-os)
case "$OS" in
kfreebsd)
CDFS=cd9660
- FATFS=msdosfs
OPTIONS=ro,exec
;;
linux)
CDFS=iso9660
- FATFS=vfat
OPTIONS=ro,exec
;;
hurd)
CDFS=iso9660fs
- FATFS=fatfs
OPTIONS=ro
;;
*)
log "Unknown OS '$OS', exiting"
exit 0
-
esac
-
+
# Is a cdrom already mounted? If so, assume it's the right one.
mount | grep -q 'on /cdrom' && set_suite_and_codename && exit 0
if [ -e /cdrom/.disk/info ]; then
@@ -95,42 +108,101 @@ log "Searching for Debian installation m
mkdir /cdrom 2>/dev/null || true
+# Check whether the boot parameter 'loopmount=' is used
+for arg in $(cat /proc/cmdline); do
+ case $arg in
+ loopmount=*)
+ LOOPMOUNT=${arg#loopmount=}
+ LOOPFILE=${LOOPMOUNT#*:}
+ [ "$LOOPFILE" != "$LOOPMOUNT" ] && LOOPDEV=${LOOPMOUNT%:*}
+ ;;
+ esac
+done
+
+if [ "$LOOPMOUNT" ]; then
+ # Create mount point for loop mount
+ mkdir /loop 2>/dev/null || true
+fi
+
# Need to wait for the usb device scan to complete
if [ "$OS" = "linux" ]; then
- for count in 1 2 3 4 5 6 8 9 10; do
- devices="$(list-devices cd; list-devices maybe-usb-floppy)"
- log "Devices: '$devices'"
- if [ -n "$devices" ]; then
- break 2
- else
- sleep 1
- fi
- done
+ for count in 1 2 3 4 5 6 8 9 10; do
+ devices="$(list-devices cd; list-devices maybe-usb-floppy)"
+ log "CD/maybe-usb-floppy devices: '$devices'"
+ if [ "$devices" ]; then
+ break
+ else
+ sleep 1
+ fi
+ done
fi
+# This is for apt-cdrom-setup, that needs to know, whether or not it should try to automatically (u)mount the device.
+cd_mountable=true
+
while true; do
- WRONG=
+ WRONG=''
+
+ if [ "$LOOPMOUNT" ]; then
+ mounted=0
+ log "Searching for Debian ISO: LOOPDEV='$LOOPDEV' LOOPFILE='$LOOPFILE'"
+ loopfile=/loop/${LOOPFILE#/}
+ log "Unmounting /loop just to be sure"
+ umount /loop 2>/dev/null || true
+
+ if [ "$LOOPDEV" ] ; then
+ dev_given="device_given"
+ else
+ dev_given=""
+ fi
+
+ # First look for the given device (if given) and then on USB devices, since the ISO is probably on them
+ for fs in $dev_given "usb-partition" "cd" "partition"; do
+ if [ "$fs" = "device_given" ]; then
+ devices="$(list_devices_by_id "$LOOPDEV")"
+ else
+ devices="$(list-devices $fs)"
+ fi
+ log "Trying loopmount ($fs) on '$devices' ..."
+ for loopdev in $devices; do
+ # Determine the filesystem of the device
+ LOOPFS=$(get_fstype "$loopdev")
+ # Mount the device and try to mount the ISO specified by 'loopmount='
+ log "Try to mount device=$loopdev fstype=$LOOPFS"
+ if mount -o $OPTIONS -t $LOOPFS $loopdev /loop; then
+ log "Try to loop mount file=$loopfile fstype=$CDFS"
+ if [ -f $loopfile ] && try_mount $loopfile $CDFS $OPTIONS $loopdev; then
+ mounted=1
+ cd_mountable=false
+ break 2
+ else
+ umount /loop
+ fi
+ fi
+ done
+ done
+ if [ $mounted -eq 1 ]; then
+ log "Succesfully mounted the ISO: no need to check further devices"
+ break
+ fi
+ fi
devices="$(list-devices cd; list-devices maybe-usb-floppy)"
for device in $devices; do
- if try_mount $device $CDFS; then
+ if try_mount $device $CDFS $OPTIONS; then
break 2
fi
done
-
+
devices="$(list-devices usb-partition)"
for device in $devices; do
- if try_mount $device $CDFS; then
- db_set cdrom-detect/hybrid true
- break 2
- fi
- if try_mount $device $FATFS; then
- db_set cdrom-detect/usb-hdd true
+ filesystem=$(get_fstype $device)
+ if try_mount $device $filesystem $OPTIONS; then
+ cd_mountable=false
break 2
fi
done
-
if [ "$WRONG" ]; then
db_input critical cdrom-detect/wrong-cd || [ $? -eq 30 ]
db_go
@@ -138,7 +210,7 @@ while true; do
fi
# If a device was detected but the mount failed, ask for the CD.
- if [ -n "$devices" ]; then
+ if [ "$devices" ]; then
db_input critical cdrom-detect/retry || [ $? -eq 30 ]
db_go
db_get cdrom-detect/retry
@@ -150,7 +222,7 @@ while true; do
fail
fi
fi
-
+
# If no device was detected, perhaps a driver floppy is needed.
if [ -e /usr/lib/debian-installer/retriever/media-retriever ]; then
db_input critical cdrom-detect/load_media
@@ -162,7 +234,7 @@ while true; do
continue
fi
fi
-
+
# Otherwise manual configuration may be needed
db_input critical cdrom-detect/manual_config || [ $? -eq 30 ]
db_go
@@ -266,4 +338,12 @@ else
anna-install $RET-support || true
fi
+# Check for hd-media folder, which implies that it is not booted from CD.
+if [ -d /hd-media ]; then
+ cd_mountable=false
+fi
+
+# This is for apt-cdrom-setup, that needs to know, whether or not it should try to automatically (u)mount the device.
+db_set cdrom-detect/cdrom_mountable $cd_mountable
+
exit 0
diff -rup cdrom-detect-1.46.orig/debian/cdrom-detect.templates cdrom-detect-1.46/debian/cdrom-detect.templates
--- cdrom-detect-1.46.orig/debian/cdrom-detect.templates 2011-03-15 03:00:14.000000000 +0100
+++ cdrom-detect-1.46/debian/cdrom-detect.templates 2013-11-24 09:44:59.678577887 +0100
@@ -65,17 +65,22 @@ Default: iso9660
Description: for internal use only
File system used on cdrom-detect/cdrom_device.
-Template: cdrom-detect/hybrid
-Type: boolean
-Default: false
+Template: cdrom-detect/cdrom_options
+Type: string
+Default: ro,exec
Description: for internal use only
- Set if the CD appears to be on a USB stick.
+ Options used to mount the cdrom-detect/cdrom_device.
-Template: cdrom-detect/usb-hdd
-Type: boolean
-Default: false
+Template: cdrom-detect/cdrom_loopdev
+Type: string
Description: for internal use only
- Set if the CD appears to be a live USB-HDD image.
+ Set if a ISO is loopmounted.
+
+Template: cdrom-detect/cdrom_mountable
+Type: boot
+Default: true
+Description: for internal use (communication with apt-cdrom-setup) only
+ This should be false, if the mounted device is not a removable disk in a drive.
Template: cdrom-detect/scanning_progress_title
Type: text
diff -rup hw-detect-1.98.orig/check-missing-firmware.sh hw-detect-1.98/check-missing-firmware.sh
--- hw-detect-1.98.orig/check-missing-firmware.sh 2012-06-15 07:56:09.000000000 +0200
+++ hw-detect-1.98/check-missing-firmware.sh 2013-11-24 09:51:07.809915475 +0100
@@ -246,6 +246,15 @@ check_for_firmware() {
}
while check_missing && ask_load_firmware; do
+ # If LOOPMOUNT is used, check the (busy) device from which the ISO is loaded
+ db_get cdrom-detect/cdrom_loopdev || true
+ if [ "$RET" ]; then
+ log "Check on /loop for firmware"
+ if [ -d /loop/firmware ]; then
+ check_for_firmware /loop/firmware/*.deb /loop/firmware/*.udeb
+ fi
+ fi
+
# first, check if needed firmware (u)debs are available on the
# PXE initrd or the installation CD.
if [ -d /firmware ]; then
diff -rup mountmedia-0.23.orig/mountmedia mountmedia-0.23/mountmedia
--- mountmedia-0.23.orig/mountmedia 2012-11-23 20:49:31.000000000 +0100
+++ mountmedia-0.23/mountmedia 2013-11-24 09:52:57.020072623 +0100
@@ -27,13 +27,19 @@ media_mounted() {
mount | cut -d' ' -f3 | grep -q "^$MNT$"
}
+get_fstype ()
+{
+ /sbin/blkid -s TYPE -o value $1 2>/dev/null
+}
+
try_mount() {
# TO REMOVE, there is a bug somewhere in the kernel, the first
# mount command fail when changing floppy disk
# so we have to launch mount twice
- mount $1 -tauto $MNT || true
+ fs_type=$(get_fstype $1)
+ mount -t $fs_type $1 $MNT || true
umount $MNT || true
- mount $1 -tauto $MNT
+ mount -t $fs_type $1 $MNT
media_mounted && checkcontents $MNT
}