[T(A)ILS-dev] Patch to boot Tails 0.6.2 .iso image from USB …

Borrar esta mensaxe

Responder a esta mensaxe
Autor: Dirk Praet
Data:  
Para: tails-dev
Asunto: [T(A)ILS-dev] Patch to boot Tails 0.6.2 .iso image from USB through GRUB2
Hi,

When I tried to boot the TAILS 0.6.2 .iso image from USB through GRUB2 ,
I unfortunately found out that it didn't work. Applying the upstream
initramfs-patches didn't do the trick either.

I therefor extracted the initrd image and applied some code from more
recent Debian Live distributions to the scripts/live script to make it
work with the findiso argument. I don't know if this is going to be
useful to anyone, but for those interested, see below GRUB2 menu entry
and diff-patch for scripts/live attached. On my USB-drive, all isos live
in /iso . Patched initrd's live in /boot .

menuentry "T.A.I.L.S 0.6.2" {
savedefault
loopback loop /iso/tails-i386-lenny-0.6.2.iso
echo "Loading kernel.."
linux (loop)/live/vmlinuz boot=live config splash vga=788
live-media=removable nopersistent noprompt=usb keyboard-layouts=us
timezone=local findiso=/iso/tails-i386-lenny-0.6.2.iso
echo "Loading initrd.."
initrd /boot/tails/initrd-mod-0.6.2.gz

Kind regards,

Dirk


--- live.org    2011-03-24 19:59:35.098800058 +0100
+++ live    2011-03-24 19:52:18.069052152 +0100
@@ -63,6 +63,11 @@
                 export ACCESS
                 ;;


+                        bootid=*)
+                                BOOTID="${ARGUMENT#bootid=}"
+                                export BOOTID
+                                ;;
+
             console=*)
                 DEFCONSOLE="${ARGUMENT#*=}"
                 export DEFCONSOLE
@@ -135,6 +140,16 @@
                 export FROMISO
                 ;;


+                        findiso=*)
+                                FINDISO="${ARGUMENT#findiso=}"
+                                export FINDISO
+                                ;;
+
+                        ignore_bootid)
+                                IGNORE_BOOTID="Yes"
+                                export IGNORE_BOOTID
+                                ;;
+
             ignore_uuid)
                 IGNORE_UUID="Yes"
                 export IGNORE_UUID
@@ -211,6 +226,11 @@
                 export NOACCESSIBILITY
                 ;;


+                        nodhcphostname)
+                                NODHCPHOSTNAME="Yes"
+                                export NODHCPHOSTNAME
+                                ;;
+
             nofastboot)
                 NOFASTBOOT="Yes"
                 export NOFASTBOOT
@@ -392,6 +412,41 @@
     return 1
 }


+grml_match_bootid()
+{
+         path="$1"
+  
+        if [ -n "$IGNORE_BOOTID" ] ; then
+                echo " * Ignoring verification of bootid.txt as requested via ignore_bootid.">>/live.log
+                return 0
+        fi
+ 
+       if [ -n "$BOOTID" ] && ! [ -r "${path}/conf/bootid.txt" ] ; then
+               echo "  * Warning: bootid=... specified but no bootid.txt found on currently requested device.">>/live.log
+               return 1
+       fi
+
+       [ -r "${path}/conf/bootid.txt" ] || return 0
+
+       bootid_conf=$(cat "${path}/conf/bootid.txt")
+
+       if [ -z "$BOOTID" -a -z "$IGNORE_BOOTID" ]
+       then
+               echo " * Warning: bootid.txt found but ignore_bootid / bootid=.. bootoption missing...">>/live.log
+               return 1
+       fi
+
+       if [ "$BOOTID" = "$bootid_conf" ]
+       then
+               echo " * Successfully verified /conf/bootid.txt from ISO, continuing... ">>/live.log
+       else
+               echo " * Warning: BOOTID of ISO does not match. Retrying and continuing search...">>/live.log
+               return 1
+       fi
+
+       return 0
+}
+
 matches_uuid ()
 {
     if [ "${IGNORE_UUID}" ] || [ ! -e /conf/uuid.conf ]
@@ -1531,13 +1586,31 @@


     if is_supported_fs ${fstype}
     then
-        devuid=$(blkid -o value -s UUID "$devname")
+        #lenny is missing blkid
+                if command -v blkid >/dev/null 2>&1 ; then
+                        devuid=$(blkid -o value -s UUID "${devname}")
+                elif [ -x /lib/udev/vol_id ]; then
+                        devuid=$(/lib/udev/vol_id --uuid "${devname}" 2>/dev/null)
+                fi
         [ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
         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*" "" '')
+                                devname="${loopdevname}"
+                                mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
+                        fi
+                fi
+
         if is_live_path ${mountpoint} && \
-            ([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
+            #([ "${skip_uuid_check}" ] || matches_uuid ${mountpoint})
+                         ([ "${skip_uuid_check}" ] || grml_match_bootid ${mountpoint})
         then
             echo ${mountpoint}
             return 0
@@ -1652,19 +1725,19 @@
                     return 0
                 fi
             done
-        elif [ "${fstype}" = "squashfs" -o \
-            "${fstype}" = "btrfs" -o \
-            "${fstype}" = "ext2" -o \
-            "${fstype}" = "ext3" -o \
-            "${fstype}" = "ext4" -o \
-            "${fstype}" = "jffs2" ]
-        then
+#        elif [ "${fstype}" = "squashfs" -o \
+#            "${fstype}" = "btrfs" -o \
+#            "${fstype}" = "ext2" -o \
+#            "${fstype}" = "ext3" -o \
+#            "${fstype}" = "ext4" -o \
+#            "${fstype}" = "jffs2" ]
+#        then
             # This is an ugly hack situation, the block device has
             # an image directly on it.  It's hopefully
             # live-boot, so take it and run with it.
-            ln -s "${devname}" "${devname}.${fstype}"
-            echo "${devname}.${fstype}"
-            return 0
+#            ln -s "${devname}" "${devname}.${fstype}"
+#            echo "${devname}.${fstype}"
+#            return 0
         fi
     done


@@ -1853,6 +1926,22 @@
         log_end_msg
     fi


+        # 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
+          grep -q /live/findiso /proc/mounts && umount /root/live/findiso
+        fi
+
     maybe_break live-bottom
     log_begin_msg "Running /scripts/live-bottom\n"