[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#863388: live-boot: Added new functionality to live-boot: rootcopy, modularized filesystems, package installer



Package: live-boot
Version: 4.0.2-1
Severity: wishlist
Tags: patch

Dear Maintainer,
There are a few features I have come to love in other live systems that are not
available in the current live-boot system.  I have attached a patch that adds
these features and think it maybe valuable upstream.
1. rootcopy:  This allows for one or more folders on the boot medium that
contain a folder structure relative to /.  before init, these files are copied
to the rootfs.  This feature allows users to make small changes to their
environment (like wallpaper changes or dekstop icons) without needing to
remaster or have a persistent volume.

2. modularized filesystems: This allows for the use of a file, *.module, that
contains newlibe seperated squashfs filenames to be loaded in order.  This is a
change from the default behavior of coping all squashfs files and mounting them
in alphabetical order.

3. packge installer: This allows for a user to include a small apt repo in the
live media.  By creating a *.package file, a user can tell the system to
install these packages from the repo on boot before init.  This is helpful for
testing packages without having to remaster.

I have been using these for quite some time and found them to be critical in my
use.  I would like inclusion upstream so I don't have to continually patch as
new versions are released.



-- Package-specific info:

-- System Information:
Debian Release: 8.7
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages live-boot depends on:
ii  live-boot-initramfs-tools [live-boot-backend]  4.0.2-1

Versions of packages live-boot recommends:
pn  live-boot-doc  <none>
pn  live-tools     <none>
ii  rsync          3.1.1-3
pn  uuid-runtime   <none>

Versions of packages live-boot suggests:
ii  cryptsetup    2:1.7.3-3
pn  curlftpfs     <none>
pn  httpfs2       <none>
pn  unionfs-fuse  <none>
ii  wget          1.16-1+deb8u1

-- debconf information:
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/^(.*?)(\\)?\${ <-- HERE ([^{}]+)}(.*)$/ at /usr/share/perl5/Debconf/Question.pm line 72.
Unescaped left brace in regex is deprecated, passed through in regex; marked by <-- HERE in m/\${ <-- HERE ([^}]+)}/ at /usr/share/perl5/Debconf/Config.pm line 30.
diff -ruN lib/live/boot/9990-cleanup.sh /lib/live/boot/9990-cleanup.sh
--- lib/live/boot/9990-cleanup.sh	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/9990-cleanup.sh	2017-05-15 15:59:13.000000000 +0000
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#set -e
+
+
+
+Cleanup ()
+{
+	. /bin/live-boot
+	. /scripts/functions
+	log_begin_msg "Cleaning up your mess..."
+	# Unmount boot media if we did a rootcopy or module install
+	([ -n ${ROOTCOPY} ] || [ -n ${MODULES} ]) && umount /root/lib/live/mount/medium
+	#[ -n ${MODULES} ] && umount /root/lib/live/mount/medium
+
+	# Copy through initrd versions of live-boot scripts
+	cp -af /lib/live/boot/* /root/lib/live/boot/
+	cp -af /scripts/live /root/usr/share/initramfs-tools/scripts/live
+
+	# Remove duplicate /live/overlay
+	umount /root/lib/live/mount/overlay
+        maybe_break cleanup	
+	log_end_msg
+}
diff -ruN lib/live/boot/9990-cmdline-old /lib/live/boot/9990-cmdline-old
--- lib/live/boot/9990-cmdline-old	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-cmdline-old	2017-05-26 03:45:29.229477053 +0000
@@ -208,7 +208,8 @@
 
 			toram)
 				TORAM="true"
-				export TORAM
+				MODULETORAM="filesystem.squashfs"
+				export TORAM MODULETORAM
 				;;
 
 			toram=*)
@@ -241,6 +242,31 @@
 				UNIONTYPE="${_PARAMETER#union=}"
 				export UNIONTYPE
 				;;
+
+			rootcopy)
+				ROOTCOPY="true"
+				export ROOTCOPY
+				;;
+
+			rootcopy=*)
+				ROOTCOPY="${_PARAMETER#rootcopy=}"
+				export ROOTCOPY
+				;;
+
+			packagesdir=*)
+				PACKAGESDIR="${_PARAMETER#packagesdir=}"
+				export PACKAGESDIR
+				;;
+
+			packages=*)
+				PACKAGES="${_PARAMETER#packages=}"
+				export PACKAGES
+				;;
+
+			repodir=*)
+				REPODIR="${_PARAMETER#repodir=}"
+				export REPODIR
+				;;
 		esac
 	done
 
diff -ruN lib/live/boot/9990-main.sh /lib/live/boot/9990-main.sh
--- lib/live/boot/9990-main.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-main.sh	2017-05-26 03:12:30.501381288 +0000
@@ -211,4 +211,17 @@
 	exec 2>&7 7>&-
 	kill ${tailpid}
 	[ -w "${rootmnt}/var/log/" ] && mkdir -p "${rootmnt}/var/log/live" && cp boot.log "${rootmnt}/var/log/live" 2>/dev/null
+
+	# install user modules
+	Packages
+
+	# Clone Root mods
+	Rootcopy
+
+	# Cleanup
+	Cleanup
+
+	# Copy through initrd versions of live-boot scripts
+	cp -af /lib/live/boot/* /root/lib/live/boot/
+	cp -af /scripts/live /root/usr/share/initramfs-tools/scripts/live
 }
diff -ruN lib/live/boot/9990-misc-helpers.sh /lib/live/boot/9990-misc-helpers.sh
--- lib/live/boot/9990-misc-helpers.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-misc-helpers.sh	2017-04-19 02:26:02.000000000 +0000
@@ -2,6 +2,30 @@
 
 #set -e
 
+## Patched for version: live-boot-1:20160511
+
+## New cmdline parameter " mountmode=rw"
+## Overrides the live-media partition default RO mount
+##
+## Then the partition containing the live-media will be writable
+## Persistent loopback files in the same partition should then work
+##
+## If " mountmode=rw" is not specified:
+## No changes will be made to original defaults (ro,noatime)
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+if cat /proc/cmdline|grep -q "mountmode=rw" ; then
+	custom_mountmode=rw,noatime
+	echo -e "\n Custom mount options were selected"
+	echo -e " The live-media device will be mounted ${custom_mountmode} \n"
+	sleep 2
+# else live-media partition mount opts default to "ro,noatime"
+fi
+
+## PATCH end ##
+
+
 is_live_path()
 {
 	DIRECTORY="${1}/${LIVE_MEDIA_PATH}"
@@ -126,6 +150,26 @@
 			then
 				mkdir /live/fromiso
 				mount -t $fs_type "$ISO_DEVICE" /live/fromiso
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+					## custom_mountmode: if set, remount /live/fromiso
+					if [ -n "${custom_mountmode}" ]; then
+
+							if [ "$fstype" = "vfat" ]; then
+								custom_mountopts=rw,noatime,umask=000
+							else
+								custom_mountopts=${custom_mountmode}
+							fi
+
+						umount /live/fromiso
+						mount -t ${fstype} -o ${custom_mountopts} "$ISO_DEVICE" /live/fromiso
+
+					fi
+## PATCH end
+
+
 				ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
 				loopdevname=$(setup_loop "/live/fromiso/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
 				devname="${loopdevname}"
@@ -196,6 +240,26 @@
 		devuid=$(blkid -o value -s UUID "$devname")
 		[ -n "$devuid" ] && grep -qs "\<$devuid\>" /var/lib/live/boot/devices-already-tried-to-mount && continue
 		mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+			## custom_mountmode: if set, remount the live-media device
+			## but only if is_live_path (we might be "findiso")
+			if is_live_path ${mountpoint} &&  [ -n "${custom_mountmode}" ]; then
+
+					if [ "$fstype" = "vfat" ]; then
+						custom_mountopts=rw,noatime,umask=000
+					else
+						custom_mountopts=${custom_mountmode}
+					fi
+				umount ${mountpoint}
+				mount -t ${fstype} -o ${custom_mountopts} "${devname}" ${mountpoint} || continue
+			fi
+
+## PATCH end
+
+
 		[ -n "$devuid" ] && echo "$devuid" >> /var/lib/live/boot/devices-already-tried-to-mount
 
 		if [ -n "${FINDISO}" ]
@@ -205,6 +269,25 @@
 				umount ${mountpoint}
 				mkdir -p /live/findiso
 				mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+				## custom_mountmode: if set, remount /live/findiso
+				if [ -n "${custom_mountmode}" ]; then
+
+						if [ "$fstype" = "vfat" ]; then
+							custom_mountopts=rw,noatime,umask=000
+						else
+							custom_mountopts=${custom_mountmode}
+						fi
+
+					umount /live/findiso
+					mount -t ${fstype} -o ${custom_mountopts} "${devname}" /live/findiso || continue
+				fi
+## PATCH end
+
+
 				loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" 0 "")
 				devname="${loopdevname}"
 				mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
@@ -713,6 +796,26 @@
 
 	mkdir -p "${backing}"
 	old_backing="$(where_is_mounted ${device})"
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+	## custom_mountmode: (only if) is set rw
+	## set ${backing} and stop if live-media device is already mounted
+	##
+	if [ -n "${custom_mountmode}" ]; then
+
+		if [ "${old_backing}" = "/live/findiso" ] || [ "${old_backing}" = "/live/fromiso" ] || [ "${old_backing}" = "/live/medium" ]
+		then
+			backing=${old_backing}
+			echo ${backing}
+			return 0
+		fi
+	fi
+
+## PATCH end
+
+
 	if [ -z "${old_backing}" ]
 	then
 		fstype="$(get_fstype ${device})"
@@ -1025,6 +1128,19 @@
 		black_listed_devices="${black_listed_devices} $(what_is_mounted_on d)"
 	done
 
+ 
+## PATCH (addition to support rw mount of live-media partition) ##
+
+	## custom_mountmode: If used with persistence, unset black_listed_devices
+	## persistence files in the live-media partition can then be used (but note warning above)
+
+	if cat /proc/cmdline|grep -q " persistence" && [ -n "${custom_mountmode}" ]; then
+		black_listed_devices=""
+	fi
+
+## PATCH end
+
+
 	for dev in $(storage_devices "${black_listed_devices}" "${white_listed_devices}")
 	do
 		local result luks_device
diff -ruN lib/live/boot/9990-overlay.sh /lib/live/boot/9990-overlay.sh
--- lib/live/boot/9990-overlay.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-overlay.sh	2017-05-26 03:31:26.365436261 +0000
@@ -38,6 +38,8 @@
 	# Let's just mount the read-only file systems first
 	rootfslist=""
 
+	image_string=""
+
 	if [ -z "${PLAIN_ROOT}" ]
 	then
 		# Read image names from ${MODULE}.module if it exists
@@ -53,6 +55,23 @@
 			do
 				image_string="${image_string} ${image_directory}/${IMAGE}"
 			done
+
+			# Clear this out so we don't get confused later on.  If we are loading a module
+			# then the MODULETORAMFILE check below (for a single file) will break
+			unset MODULETORAMFILE
+
+		elif $( echo $MODULETORAM | grep -q "module" ) && [ -e "${image_directory}/${MODULETORAM}" ]
+		then
+			echo "Detected RAM based Modules for loading.  Processing..."
+			image_string=""
+			for IMAGE in $(cat ${image_directory}/${MODULETORAM})
+			do
+				image_string="${image_string} ${image_directory}/${IMAGE}"
+			done
+
+			# Clear this out so we don't get confused later on
+			unset MODULETORAMFILE
+			
 		else
 			# ${MODULE}.module does not exist, create a list of images
 			for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
@@ -83,6 +102,7 @@
 			# Now sort the list
 			image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
 		fi
+		export image_string
 
 		[ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
 
diff -ruN lib/live/boot/9990-package-install.sh /lib/live/boot/9990-package-install.sh
--- lib/live/boot/9990-package-install.sh	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/9990-package-install.sh	2017-05-26 03:27:37.229425171 +0000
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#set -e
+Packages()
+{
+. /scripts/functions
+. /lib/live/boot/9990-initramfs-tools.sh
+
+
+if [ "${PACKAGES}" ]; then
+	# Source Medium is /root/lib/live/mount/medium and rootfs is /root
+	[ -z ${PACKAGESDIR} ] && PACKAGESDIR=${LIVE_MEDIA_PATH}/packages
+	[ -z ${REPODIR} ] && REPODIR=${LIVE_MEDIA_PATH}/repo
+
+	mv /root/etc/apt/sources.list /root/etc/apt/sources.list.bak
+        echo "deb file:/lib/live/mount/medium/${REPODIR}/ /" >> /root/etc/apt/sources.list
+	for i in $(echo $PACKAGES | tr "," "\n" ); do
+		log_begin_msg "Installing Package $i..."
+		chroot /root apt-get update
+		chroot /root apt-get -y --force-yes install `cat /root/lib/live/mount/medium/${PACKAGESDIR}/$i`
+		log_end_msg
+	done
+	maybe_break packages
+	mv /root/etc/apt/sources.list.bak /root/etc/apt/sources.list
+fi
+}
diff -ruN lib/live/boot/9990-rootcopy.sh /lib/live/boot/9990-rootcopy.sh
--- lib/live/boot/9990-rootcopy.sh	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/9990-rootcopy.sh	2017-05-26 03:27:48.085425697 +0000
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#set -e
+Rootcopy()
+{
+. /scripts/functions
+. /lib/live/boot/9990-initramfs-tools.sh
+
+if [ "${ROOTCOPY}" ]; then
+	# Source Medium is /root/lib/live/mount/medium and rootfs is /root
+	[ "${ROOTCOPY}" == "true" ] && ROOTCOPY=${LIVE_MEDIA_PATH}/rootcopy
+	for i in $(echo $ROOTCOPY | tr "," "\n" ); do
+		log_begin_msg "Copying rootcopy from $i to /..."
+		if [ -d /root/lib/live/mount/medium/$i/ ]; then
+			cp -af /root/lib/live/mount/medium/$i/* /root
+		elif [ -d /root/lib/live/mount/medium/${LIVE_MEDIA_PATH}/$i/ ]; then
+			cp -af /root/lib/live/mount/medium/${LIVE_MEDIA_PATH}/$i/* /root
+		else
+			echo "Source directory does not exist!!!"
+		fi
+		log_end_msg
+	done
+	maybe_break rootcopy
+fi
+}
diff -ruN lib/live/boot/9990-toram-todisk.sh /lib/live/boot/9990-toram-todisk.sh
--- lib/live/boot/9990-toram-todisk.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-toram-todisk.sh	2017-04-16 20:40:03.000000000 +0000
@@ -8,13 +8,30 @@
 	copytodev="${2}"
 	copyto="${copyfrom}_swap"
 
-	if [ -z "${MODULETORAM}" ]
+	if [ -z "${MODULETORAM}" ] && [ -z "${MODULE}" ]
 	then
 		size=$(fs_size "" ${copyfrom}/ "used")
 	else
 		MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
 
-		if [ -f "${MODULETORAMFILE}" ]
+		if [ -e "${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module" ]
+		then
+			#if $( echo $MODULETORAMFILE | grep -q "module" )
+			# This allows you to load modules into RAM
+			# Be carefule that your modules are small enough
+
+			MODULEFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module"
+			echo "Detected Ram File Module List. Calculating size..."
+			size=0
+			for IMAGE in $(cat $MODULEFILE)
+                        do
+                                image_string="${image_string} ${copyfrom}/${LIVE_MEDIA_PATH}/${IMAGE}"
+				size=$( expr ${size} + $(ls -la ${copyfrom}/${LIVE_MEDIA_PATH}/${IMAGE} | awk '{print $5}') / 1024 + 5000 )
+				echo "Added ${IMAGE} ${size}"
+			done
+			maybe_break toram
+			MODULETORAMFILE=${image_string}
+		elif [ -f "${MODULETORAMFILE}" ]
 		then
 			size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
 		else
@@ -73,12 +90,19 @@
 	else
 		if [ -n "${MODULETORAMFILE}" ]
 		then
-			if [ -x /bin/rsync ]
+			for M in ${MODULETORAMFILE}; do
+				if [ -x /bin/rsync ]
+				then
+					echo " * Copying $M to RAM" 1>/dev/console
+					rsync -a --progress ${M} ${copyto} 1>/dev/console # copy only the filesystem module
+				else
+					cp ${M} ${copyto} # copy only the filesystem module
+				fi
+				maybe_break toram
+			done
+			if [ -e "${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module" ]
 			then
-				echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
-				rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
-			else
-				cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
+				cp ${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module ${copyto}
 			fi
 		else
 			if [ -x /bin/rsync ]
@@ -95,7 +119,7 @@
 			fi
 		fi
 
-		umount ${copyfrom}
+		[ -n ${PACKAGES} ] || [ -n ${ROOTCOPY} ] || umount ${copyfrom}
 		mount -r -o move ${copyto} ${copyfrom}
 	fi
 
diff -ruN lib/live/boot/boot.md5 /lib/live/boot/boot.md5
--- lib/live/boot/boot.md5	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/boot.md5	2017-04-19 02:11:44.000000000 +0000
@@ -0,0 +1,21 @@
+aca4581de9da13ef3f054643262d651b  0001-init-vars.sh
+252014ccf467d476b3f132411d7119a4  0010-debug
+c8b8424c5b0f3d7043662261fcdbb356  0020-read-only
+2de36b6fbca9e4073ba99f43c0682f58  0030-verify-checksums
+7d6a8f11913aa46c0642f8245a3e700b  2010-remove-persistence
+e56fb2fe631948e929cece2389b8de03  3020-swap
+6ea92bf49f89818c97602f693cd58a2c  9990-cmdline-old
+75e821afa65e04f890d15adc5b38fa93  9990-fstab.sh
+c2d0e5e0b020a15af1c6f042c13d60fd  9990-initramfs-tools.sh
+c7afeeb9ff1ca69debc95bfb4c03e370  9990-main.sh
+dc4f2c88d1db6fea12529e0b8dd06480  9990-misc-helpers.sh
+d51d965fcb2baf7ea7e40d62706aa61e  9990-mount-cifs.sh
+89f1159e5134ebef512dd94e4cd870e2  9990-mount-http.sh
+ec73885bd66cbe12f17d6749fd720dd9  9990-mount-iscsi.sh
+aea3e84d351200426abd021fa018ea6b  9990-mount-nfs.sh
+999ecf6767a051b60417d2c551090d16  9990-netbase.sh
+477dfafc18335e83bd58bd195dde6bcc  9990-netboot.sh
+423526e743b6acf59bb291ed7c2cd554  9990-networking.sh
+e21ad38c62aefee49a0666d8ea13c179  9990-overlay.sh
+8d15347ac1ab4bd6fff2bc098910c0c5  9990-select-eth-device.sh
+78ecef6aa0dfb888ab69f67d7f173713  9990-toram-todisk.sh
diff -ruN lib/live/boot/9990-cleanup.sh /lib/live/boot/9990-cleanup.sh
--- lib/live/boot/9990-cleanup.sh	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/9990-cleanup.sh	2017-05-15 15:59:13.000000000 +0000
@@ -0,0 +1,24 @@
+#!/bin/sh
+
+#set -e
+
+
+
+Cleanup ()
+{
+	. /bin/live-boot
+	. /scripts/functions
+	log_begin_msg "Cleaning up your mess..."
+	# Unmount boot media if we did a rootcopy or module install
+	([ -n ${ROOTCOPY} ] || [ -n ${MODULES} ]) && umount /root/lib/live/mount/medium
+	#[ -n ${MODULES} ] && umount /root/lib/live/mount/medium
+
+	# Copy through initrd versions of live-boot scripts
+	cp -af /lib/live/boot/* /root/lib/live/boot/
+	cp -af /scripts/live /root/usr/share/initramfs-tools/scripts/live
+
+	# Remove duplicate /live/overlay
+	umount /root/lib/live/mount/overlay
+        maybe_break cleanup	
+	log_end_msg
+}
diff -ruN lib/live/boot/9990-cmdline-old /lib/live/boot/9990-cmdline-old
--- lib/live/boot/9990-cmdline-old	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-cmdline-old	2017-05-26 03:45:29.229477053 +0000
@@ -208,7 +208,8 @@
 
 			toram)
 				TORAM="true"
-				export TORAM
+				MODULETORAM="filesystem.squashfs"
+				export TORAM MODULETORAM
 				;;
 
 			toram=*)
@@ -241,6 +242,31 @@
 				UNIONTYPE="${_PARAMETER#union=}"
 				export UNIONTYPE
 				;;
+
+			rootcopy)
+				ROOTCOPY="true"
+				export ROOTCOPY
+				;;
+
+			rootcopy=*)
+				ROOTCOPY="${_PARAMETER#rootcopy=}"
+				export ROOTCOPY
+				;;
+
+			packagesdir=*)
+				PACKAGESDIR="${_PARAMETER#packagesdir=}"
+				export PACKAGESDIR
+				;;
+
+			packages=*)
+				PACKAGES="${_PARAMETER#packages=}"
+				export PACKAGES
+				;;
+
+			repodir=*)
+				REPODIR="${_PARAMETER#repodir=}"
+				export REPODIR
+				;;
 		esac
 	done
 
diff -ruN lib/live/boot/9990-main.sh /lib/live/boot/9990-main.sh
--- lib/live/boot/9990-main.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-main.sh	2017-05-26 03:12:30.501381288 +0000
@@ -211,4 +211,17 @@
 	exec 2>&7 7>&-
 	kill ${tailpid}
 	[ -w "${rootmnt}/var/log/" ] && mkdir -p "${rootmnt}/var/log/live" && cp boot.log "${rootmnt}/var/log/live" 2>/dev/null
+
+	# install user modules
+	Packages
+
+	# Clone Root mods
+	Rootcopy
+
+	# Cleanup
+	Cleanup
+
+	# Copy through initrd versions of live-boot scripts
+	cp -af /lib/live/boot/* /root/lib/live/boot/
+	cp -af /scripts/live /root/usr/share/initramfs-tools/scripts/live
 }
diff -ruN lib/live/boot/9990-misc-helpers.sh /lib/live/boot/9990-misc-helpers.sh
--- lib/live/boot/9990-misc-helpers.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-misc-helpers.sh	2017-04-19 02:26:02.000000000 +0000
@@ -2,6 +2,30 @@
 
 #set -e
 
+## Patched for version: live-boot-1:20160511
+
+## New cmdline parameter " mountmode=rw"
+## Overrides the live-media partition default RO mount
+##
+## Then the partition containing the live-media will be writable
+## Persistent loopback files in the same partition should then work
+##
+## If " mountmode=rw" is not specified:
+## No changes will be made to original defaults (ro,noatime)
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+if cat /proc/cmdline|grep -q "mountmode=rw" ; then
+	custom_mountmode=rw,noatime
+	echo -e "\n Custom mount options were selected"
+	echo -e " The live-media device will be mounted ${custom_mountmode} \n"
+	sleep 2
+# else live-media partition mount opts default to "ro,noatime"
+fi
+
+## PATCH end ##
+
+
 is_live_path()
 {
 	DIRECTORY="${1}/${LIVE_MEDIA_PATH}"
@@ -126,6 +150,26 @@
 			then
 				mkdir /live/fromiso
 				mount -t $fs_type "$ISO_DEVICE" /live/fromiso
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+					## custom_mountmode: if set, remount /live/fromiso
+					if [ -n "${custom_mountmode}" ]; then
+
+							if [ "$fstype" = "vfat" ]; then
+								custom_mountopts=rw,noatime,umask=000
+							else
+								custom_mountopts=${custom_mountmode}
+							fi
+
+						umount /live/fromiso
+						mount -t ${fstype} -o ${custom_mountopts} "$ISO_DEVICE" /live/fromiso
+
+					fi
+## PATCH end
+
+
 				ISO_NAME="$(echo $FROMISO | sed "s|$ISO_DEVICE||")"
 				loopdevname=$(setup_loop "/live/fromiso/${ISO_NAME}" "loop" "/sys/block/loop*" "" '')
 				devname="${loopdevname}"
@@ -196,6 +240,26 @@
 		devuid=$(blkid -o value -s UUID "$devname")
 		[ -n "$devuid" ] && grep -qs "\<$devuid\>" /var/lib/live/boot/devices-already-tried-to-mount && continue
 		mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+			## custom_mountmode: if set, remount the live-media device
+			## but only if is_live_path (we might be "findiso")
+			if is_live_path ${mountpoint} &&  [ -n "${custom_mountmode}" ]; then
+
+					if [ "$fstype" = "vfat" ]; then
+						custom_mountopts=rw,noatime,umask=000
+					else
+						custom_mountopts=${custom_mountmode}
+					fi
+				umount ${mountpoint}
+				mount -t ${fstype} -o ${custom_mountopts} "${devname}" ${mountpoint} || continue
+			fi
+
+## PATCH end
+
+
 		[ -n "$devuid" ] && echo "$devuid" >> /var/lib/live/boot/devices-already-tried-to-mount
 
 		if [ -n "${FINDISO}" ]
@@ -205,6 +269,25 @@
 				umount ${mountpoint}
 				mkdir -p /live/findiso
 				mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+				## custom_mountmode: if set, remount /live/findiso
+				if [ -n "${custom_mountmode}" ]; then
+
+						if [ "$fstype" = "vfat" ]; then
+							custom_mountopts=rw,noatime,umask=000
+						else
+							custom_mountopts=${custom_mountmode}
+						fi
+
+					umount /live/findiso
+					mount -t ${fstype} -o ${custom_mountopts} "${devname}" /live/findiso || continue
+				fi
+## PATCH end
+
+
 				loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" 0 "")
 				devname="${loopdevname}"
 				mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
@@ -713,6 +796,26 @@
 
 	mkdir -p "${backing}"
 	old_backing="$(where_is_mounted ${device})"
+
+
+## PATCH (addition to support rw mount of live-media partition) ##
+
+	## custom_mountmode: (only if) is set rw
+	## set ${backing} and stop if live-media device is already mounted
+	##
+	if [ -n "${custom_mountmode}" ]; then
+
+		if [ "${old_backing}" = "/live/findiso" ] || [ "${old_backing}" = "/live/fromiso" ] || [ "${old_backing}" = "/live/medium" ]
+		then
+			backing=${old_backing}
+			echo ${backing}
+			return 0
+		fi
+	fi
+
+## PATCH end
+
+
 	if [ -z "${old_backing}" ]
 	then
 		fstype="$(get_fstype ${device})"
@@ -1025,6 +1128,19 @@
 		black_listed_devices="${black_listed_devices} $(what_is_mounted_on d)"
 	done
 
+ 
+## PATCH (addition to support rw mount of live-media partition) ##
+
+	## custom_mountmode: If used with persistence, unset black_listed_devices
+	## persistence files in the live-media partition can then be used (but note warning above)
+
+	if cat /proc/cmdline|grep -q " persistence" && [ -n "${custom_mountmode}" ]; then
+		black_listed_devices=""
+	fi
+
+## PATCH end
+
+
 	for dev in $(storage_devices "${black_listed_devices}" "${white_listed_devices}")
 	do
 		local result luks_device
diff -ruN lib/live/boot/9990-overlay.sh /lib/live/boot/9990-overlay.sh
--- lib/live/boot/9990-overlay.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-overlay.sh	2017-05-26 03:31:26.365436261 +0000
@@ -38,6 +38,8 @@
 	# Let's just mount the read-only file systems first
 	rootfslist=""
 
+	image_string=""
+
 	if [ -z "${PLAIN_ROOT}" ]
 	then
 		# Read image names from ${MODULE}.module if it exists
@@ -53,6 +55,23 @@
 			do
 				image_string="${image_string} ${image_directory}/${IMAGE}"
 			done
+
+			# Clear this out so we don't get confused later on.  If we are loading a module
+			# then the MODULETORAMFILE check below (for a single file) will break
+			unset MODULETORAMFILE
+
+		elif $( echo $MODULETORAM | grep -q "module" ) && [ -e "${image_directory}/${MODULETORAM}" ]
+		then
+			echo "Detected RAM based Modules for loading.  Processing..."
+			image_string=""
+			for IMAGE in $(cat ${image_directory}/${MODULETORAM})
+			do
+				image_string="${image_string} ${image_directory}/${IMAGE}"
+			done
+
+			# Clear this out so we don't get confused later on
+			unset MODULETORAMFILE
+			
 		else
 			# ${MODULE}.module does not exist, create a list of images
 			for FILESYSTEM in squashfs ext2 ext3 ext4 xfs jffs2 dir
@@ -83,6 +102,7 @@
 			# Now sort the list
 			image_string="$(echo ${image_string} | sed -e 's/ /\n/g' | sort )"
 		fi
+		export image_string
 
 		[ -n "${MODULETORAMFILE}" ] && image_string="${image_directory}/$(basename ${MODULETORAMFILE})"
 
diff -ruN lib/live/boot/9990-package-install.sh /lib/live/boot/9990-package-install.sh
--- lib/live/boot/9990-package-install.sh	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/9990-package-install.sh	2017-05-26 03:27:37.229425171 +0000
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+#set -e
+Packages()
+{
+. /scripts/functions
+. /lib/live/boot/9990-initramfs-tools.sh
+
+
+if [ "${PACKAGES}" ]; then
+	# Source Medium is /root/lib/live/mount/medium and rootfs is /root
+	[ -z ${PACKAGESDIR} ] && PACKAGESDIR=${LIVE_MEDIA_PATH}/packages
+	[ -z ${REPODIR} ] && REPODIR=${LIVE_MEDIA_PATH}/repo
+
+	mv /root/etc/apt/sources.list /root/etc/apt/sources.list.bak
+        echo "deb file:/lib/live/mount/medium/${REPODIR}/ /" >> /root/etc/apt/sources.list
+	for i in $(echo $PACKAGES | tr "," "\n" ); do
+		log_begin_msg "Installing Package $i..."
+		chroot /root apt-get update
+		chroot /root apt-get -y --force-yes install `cat /root/lib/live/mount/medium/${PACKAGESDIR}/$i`
+		log_end_msg
+	done
+	maybe_break packages
+	mv /root/etc/apt/sources.list.bak /root/etc/apt/sources.list
+fi
+}
diff -ruN lib/live/boot/9990-rootcopy.sh /lib/live/boot/9990-rootcopy.sh
--- lib/live/boot/9990-rootcopy.sh	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/9990-rootcopy.sh	2017-05-26 03:27:48.085425697 +0000
@@ -0,0 +1,25 @@
+#!/bin/sh
+
+#set -e
+Rootcopy()
+{
+. /scripts/functions
+. /lib/live/boot/9990-initramfs-tools.sh
+
+if [ "${ROOTCOPY}" ]; then
+	# Source Medium is /root/lib/live/mount/medium and rootfs is /root
+	[ "${ROOTCOPY}" == "true" ] && ROOTCOPY=${LIVE_MEDIA_PATH}/rootcopy
+	for i in $(echo $ROOTCOPY | tr "," "\n" ); do
+		log_begin_msg "Copying rootcopy from $i to /..."
+		if [ -d /root/lib/live/mount/medium/$i/ ]; then
+			cp -af /root/lib/live/mount/medium/$i/* /root
+		elif [ -d /root/lib/live/mount/medium/${LIVE_MEDIA_PATH}/$i/ ]; then
+			cp -af /root/lib/live/mount/medium/${LIVE_MEDIA_PATH}/$i/* /root
+		else
+			echo "Source directory does not exist!!!"
+		fi
+		log_end_msg
+	done
+	maybe_break rootcopy
+fi
+}
diff -ruN lib/live/boot/9990-toram-todisk.sh /lib/live/boot/9990-toram-todisk.sh
--- lib/live/boot/9990-toram-todisk.sh	2014-12-10 09:37:04.000000000 +0000
+++ /lib/live/boot/9990-toram-todisk.sh	2017-04-16 20:40:03.000000000 +0000
@@ -8,13 +8,30 @@
 	copytodev="${2}"
 	copyto="${copyfrom}_swap"
 
-	if [ -z "${MODULETORAM}" ]
+	if [ -z "${MODULETORAM}" ] && [ -z "${MODULE}" ]
 	then
 		size=$(fs_size "" ${copyfrom}/ "used")
 	else
 		MODULETORAMFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULETORAM}"
 
-		if [ -f "${MODULETORAMFILE}" ]
+		if [ -e "${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module" ]
+		then
+			#if $( echo $MODULETORAMFILE | grep -q "module" )
+			# This allows you to load modules into RAM
+			# Be carefule that your modules are small enough
+
+			MODULEFILE="${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module"
+			echo "Detected Ram File Module List. Calculating size..."
+			size=0
+			for IMAGE in $(cat $MODULEFILE)
+                        do
+                                image_string="${image_string} ${copyfrom}/${LIVE_MEDIA_PATH}/${IMAGE}"
+				size=$( expr ${size} + $(ls -la ${copyfrom}/${LIVE_MEDIA_PATH}/${IMAGE} | awk '{print $5}') / 1024 + 5000 )
+				echo "Added ${IMAGE} ${size}"
+			done
+			maybe_break toram
+			MODULETORAMFILE=${image_string}
+		elif [ -f "${MODULETORAMFILE}" ]
 		then
 			size=$( expr $(ls -la ${MODULETORAMFILE} | awk '{print $5}') / 1024 + 5000 )
 		else
@@ -73,12 +90,19 @@
 	else
 		if [ -n "${MODULETORAMFILE}" ]
 		then
-			if [ -x /bin/rsync ]
+			for M in ${MODULETORAMFILE}; do
+				if [ -x /bin/rsync ]
+				then
+					echo " * Copying $M to RAM" 1>/dev/console
+					rsync -a --progress ${M} ${copyto} 1>/dev/console # copy only the filesystem module
+				else
+					cp ${M} ${copyto} # copy only the filesystem module
+				fi
+				maybe_break toram
+			done
+			if [ -e "${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module" ]
 			then
-				echo " * Copying $MODULETORAMFILE to RAM" 1>/dev/console
-				rsync -a --progress ${MODULETORAMFILE} ${copyto} 1>/dev/console # copy only the filesystem module
-			else
-				cp ${MODULETORAMFILE} ${copyto} # copy only the filesystem module
+				cp ${copyfrom}/${LIVE_MEDIA_PATH}/${MODULE}.module ${copyto}
 			fi
 		else
 			if [ -x /bin/rsync ]
@@ -95,7 +119,7 @@
 			fi
 		fi
 
-		umount ${copyfrom}
+		[ -n ${PACKAGES} ] || [ -n ${ROOTCOPY} ] || umount ${copyfrom}
 		mount -r -o move ${copyto} ${copyfrom}
 	fi
 
diff -ruN lib/live/boot/boot.md5 /lib/live/boot/boot.md5
--- lib/live/boot/boot.md5	1970-01-01 00:00:00.000000000 +0000
+++ /lib/live/boot/boot.md5	2017-04-19 02:11:44.000000000 +0000
@@ -0,0 +1,21 @@
+aca4581de9da13ef3f054643262d651b  0001-init-vars.sh
+252014ccf467d476b3f132411d7119a4  0010-debug
+c8b8424c5b0f3d7043662261fcdbb356  0020-read-only
+2de36b6fbca9e4073ba99f43c0682f58  0030-verify-checksums
+7d6a8f11913aa46c0642f8245a3e700b  2010-remove-persistence
+e56fb2fe631948e929cece2389b8de03  3020-swap
+6ea92bf49f89818c97602f693cd58a2c  9990-cmdline-old
+75e821afa65e04f890d15adc5b38fa93  9990-fstab.sh
+c2d0e5e0b020a15af1c6f042c13d60fd  9990-initramfs-tools.sh
+c7afeeb9ff1ca69debc95bfb4c03e370  9990-main.sh
+dc4f2c88d1db6fea12529e0b8dd06480  9990-misc-helpers.sh
+d51d965fcb2baf7ea7e40d62706aa61e  9990-mount-cifs.sh
+89f1159e5134ebef512dd94e4cd870e2  9990-mount-http.sh
+ec73885bd66cbe12f17d6749fd720dd9  9990-mount-iscsi.sh
+aea3e84d351200426abd021fa018ea6b  9990-mount-nfs.sh
+999ecf6767a051b60417d2c551090d16  9990-netbase.sh
+477dfafc18335e83bd58bd195dde6bcc  9990-netboot.sh
+423526e743b6acf59bb291ed7c2cd554  9990-networking.sh
+e21ad38c62aefee49a0666d8ea13c179  9990-overlay.sh
+8d15347ac1ab4bd6fff2bc098910c0c5  9990-select-eth-device.sh
+78ecef6aa0dfb888ab69f67d7f173713  9990-toram-todisk.sh

Reply to: