El 07/04/12 20:36, intrigeri escribió:
Hi,
adrian15 wrote (07 Apr 2012 17:14:08 GMT) :
This is the alternate patch then.
I'm fine with the reasons Daniel provided against using mountpoint in
live-boot, but I still don't consider "grep -q /live/findiso
/proc/mounts" as a robust way to check that /root/live/findiso (or
/live/findiso?) is mounted.
I think we need to use something similar to mountpoint but written in
shell, that is either parse /proc/mounts, or copy the way
/bin/mountpoint works (its algorithm boils down comparing if the
major:minor matches the ones of the parent directory).
Cheers,
I rewrote the patch according to intrigeri wishes and with some pieces
of advice from Daniel.
After testing this patch with boot parametres: findiso and to ram.
I have run:
cat /proc/mounts
and the results are:
rootfs / rootfs rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
udev /dev devtmpfs
rw,relatime,size=506840k,nr_inodes=126710,mode=755 0 0
devpts /dev/pts devpts
rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000 0 0
tmpfs /run tmpfs rw,nosuid,noexec,relatime,size=102704k,mode=755 0 0
/dev/sr0 /live/findiso iso9660 ro,noatime 0 0
/dev/shm /live/image tmpfs rw,relatime,size=144388k 0 0
/dev/loop1 /live/rofs/filesystem.squashfs squashfs ro,noatime 0 0
tmpfs /live/cow tmpfs rw,noatime,mode=755 0 0
aufs / aufs rw,relatime,si=12f0b3e00b69d11c,noxino 0 0
tmpfs /live tmpfs rw,relatime 0 0
proc /proc proc rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/lock tmpfs rw,nosuid,nodev,noexec,relatime,size=5120k 0 0
tmpfs /tmp tmpfs rw,nosuid,nodev,relatime,size=205404k 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
tmpfs /run/shm tmpfs rw,nosuid,nodev,relatime,size=205404k 0 0
I don't see any /root/live/findiso so I guess it's ok.
If the patch is accepted I will send a similar patch for fromiso/isofrom
option so that it uses the is_mountpoint function.
adrian15
--
Support free software. Donate to Super Grub Disk. Apoya el software
libre. Dona a Super Grub Disk. http://www.supergrubdisk.org/donate/
diff --git a/manpages/en/live-boot.7 b/manpages/en/live-boot.7
index 6a46d9b..77ac29f 100644
--- a/manpages/en/live-boot.7
+++ b/manpages/en/live-boot.7
@@ -66,6 +66,8 @@ Target <target-name>
Lun 0 Path=<path-to-your-live-image.iso>,Type=fileio,IOMode=ro
# If you want to boot multiple machines you might want to look at tuning some parameters like
# Wthreads or MaxConnections
+.IP "\fBfindiso\fR=\fI/PATH/TO/IMAGE\fI" 4
+Look for the specified ISO file on all disks where it usually looks for the .squashfs file (so you don't have to know the device name as in fromiso=....).
.IP "\fBfromiso\fR=\fI/PATH/TO/IMAGE\fI" 4
Allows to use a filesystem from within an iso image that's available on live-media.
.IP "\fBignore_uuid\fR" 4
diff --git a/scripts/live b/scripts/live
index e248937..4954ce3 100755
--- a/scripts/live
+++ b/scripts/live
@@ -1357,6 +1357,21 @@ check_dev ()
mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
[ -n "$devuid" ] && echo "$devuid" >> $tried
+ if [ -n "${FINDISO}" ]
+ then
+ if [ -f ${mountpoint}/${FINDISO} ]
+ then
+ umount ${mountpoint}
+ mkdir /live/findiso -p
+ mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
+ loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" 0 "")
+ devname="${loopdevname}"
+ mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
+ else
+ umount ${mountpoint}
+ fi
+ fi
+
if is_live_path ${mountpoint} && \
([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
then
@@ -1643,6 +1658,26 @@ mountroot ()
# when booting FAI, this simple workaround solves it
ls /root/* >/dev/null 2>&1
+ # Move findiso directory to the new root filesystem so that programs there can get at it.
+ if [ -d /live/findiso -a ! -d /root/live/findiso ]
+ then
+ mkdir -p /root/live/findiso
+ mount -n --move /live/findiso /root/live/findiso
+ fi
+
+ # if we do not unmount the ISO we can't run "fsck /dev/ice" later on
+ # because the mountpoint is left behind in /proc/mounts, so let's get
+ # rid of it when running from RAM
+ if [ -n "$FINDISO" ] && [ "${TORAM}" ]
+ then
+ losetup -d /dev/loop0
+
+ if is_mountpoint /live/findiso
+ then
+ umount /root/live/findiso
+ fi
+ fi
+
# copy snapshot configuration if exists
if [ -f snapshot.conf ]
then
diff --git a/scripts/live-helpers b/scripts/live-helpers
index 889d157..4258ab3 100644
--- a/scripts/live-helpers
+++ b/scripts/live-helpers
@@ -143,6 +143,11 @@ Arguments ()
export STATICIP
;;
+ findiso=*)
+ FINDISO="${ARGUMENT#findiso=}"
+ export FINDISO
+ ;;
+
live-getty)
LIVE_GETTY="1"
export LIVE_GETTY
@@ -1579,3 +1584,15 @@ fix_home_rw_compatibility ()
/home source=." > "${include_list}"
fi
}
+
+is_mountpoint () {
+
+ local directory="$1"
+
+ if [ $(stat -fc%d:%D "${directory}") != $(stat -fc%d:%D "${directory}/..") ]
+ then
+ return 0
+ else
+ return 1
+ fi
+}