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

Re: Persistence file on the same partition of the live filesystem



On 26/11/12 20:42, Daniel Baumann wrote:
On 11/26/2012 09:25 PM, David Hare wrote:
This subject has been raised before but didn't get much interest.

because it's a rather low priority thing, however, if you send patches..
i'll look at them.

I have a patch for current sid but am not sure if I am free to post it
here as it is "unofficial" and maybe not so clean.

let's improve them then together?


Thanks Daniel for your reply. I know everyone is busy getting ready for Wheezy but please consider this for the future, it's been on the "wish-list" some years now.

My original interest was because a Debian "travelling OS" on a small pendrive was needed. The official method was to partition it but that left little room to use it for normal data-storage.

Now I have larger devices I can use them for multiple OS's and configurations (and data storage) without having a large read-only part.

I am no scripting "expert" nor do I know well all the inner workings of the amazing debian-live stuff. But I do have ideas for increased functionality and some things are obvious.

This is the patch I use for current sid live-boot in 9990-misc-helpers.sh. It works here using "findiso" boot on usb, that's what I use and don't know much about other methods. It has (at the moment) a quirk in that the live-media partition gets mounted on /lib/live/mount/persistence/sd_whatever but that does not seem to affect performance, at least for me.

The idea is based originally on a very old post on Ubuntu forum, I can't find it anymore and don't know who wrote it (I am not actually an Ubuntu user)

To use the patch the original initrd from the live-build must be first decompressed, 9990-misc-helpers.sh patched there, then recompressed. Then boot using the new initrd.

The patch has markers on what is changed (it is not much) and at the top what to put on cmdline to allow RW.

Note, this is at the moment a personal hack and may have problems I don't know about.. If official Debian-Live would consider at least the basic idea, good. I would prefer to actually help the Debian-Live project than just do personal hacks

David

--- /home/dzz/patch/9990-misc-helpers.sh	2012-11-07 14:10:04.000000000 +0000
+++ /home/dzz/patch/9990-misc-helpers.sh.hacked	2012-11-26 01:31:01.000000000 +0000
@@ -2,6 +2,30 @@
 
 #set -e
 
+# PATCH + #########################################################################################
+
+# set in main.sh
+# _CMDLINE="$(cat /proc/cmdline)"
+# 
+
+# example cmdline append for rw mount:
+# basemountmode=rw,noatime
+# then we can write to the device that contains the live-media
+# and use the same partition for a persistent loopback file
+# if not specified at all, will default to "ro,noatime"
+
+mountmode=$(cat /proc/cmdline|grep -o "basemountmode=.*"|sed 's/ .*//'|sed 's/basemountmode=//')
+basemountmodeparam=$(cat /proc/cmdline|grep -o "basemountmode=.*"|sed 's/ .*//')
+
+if [ -z $mountmode ]; then
+mountmode="ro,noatime"
+else
+echo "$basemountmodeparam was selected by user"
+echo "The live-media device will be mounted $mountmode"
+fi
+
+# PATCH END #######################################################################################
+
 is_live_path ()
 {
 	DIRECTORY="${1}"
@@ -227,7 +251,13 @@
 	then
 		devuid=$(blkid -o value -s UUID "$devname")
 		[ -n "$devuid" ] && grep -qs "\<$devuid\>" $tried && continue
-		mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
+		
+# - PATCH >>
+		# mount -t ${fstype} -o ro,noatime "${devname}" ${mountpoint} || continue
+
+# + PATCH >> # TODO what about vfat write permissions?
+		mount -t ${fstype} -o ${mountmode} "${devname}" ${mountpoint} || continue
+
 		[ -n "$devuid" ] && echo "$devuid" >> $tried
 
 		if [ -n "${FINDISO}" ]
@@ -235,8 +265,16 @@
 			if [ -f ${mountpoint}/${FINDISO} ]
 			then
 				umount ${mountpoint}
+				
+				# PATCH  # TODO what about vfat write permissions in /root/lib/live/findiso?	
 				mkdir -p /live/findiso
-				mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
+				
+# - PATCH >>
+				# mount -t ${fstype} -o ro,noatime "${devname}" /live/findiso
+
+# + PATCH >> # TODO what about vfat write permissions)?
+				mount -t ${fstype} -o ${mountmode} "${devname}" /live/findiso
+
 				loopdevname=$(setup_loop "/live/findiso/${FINDISO}" "loop" "/sys/block/loop*" 0 "")
 				devname="${loopdevname}"
 				mount -t iso9660 -o ro,noatime "${devname}" ${mountpoint}
@@ -729,9 +767,21 @@
 	local probe=${2}
 
 	local backing="/live/persistence/$(basename ${device})"
-
 	mkdir -p "${backing}"
+
 	local old_backing="$(where_is_mounted ${device})"
+	
+# + PATCH ### TODO : what if it is on /live/image? #######################
+
+	if [ "${old_backing}" = "/live/findiso" ]
+	then	
+	local backing=${old_backing}	
+	echo ${backing}
+	return 0	
+	fi
+	
+# PATCH END ##############################################################
+	
 	if [ -z "${old_backing}" ]
 	then
 		local fstype="$(get_fstype ${device})"
@@ -749,6 +799,7 @@
 			rmdir "${backing}"
 			return 1
 		fi
+		
 	elif [ "${backing}" != "${old_backing}" ]
 	then
 		if mount --move ${old_backing} ${backing} >/dev/null
@@ -940,7 +991,8 @@
 	local white_listed_devices="${2}"
 	local ret=""
 
-	local black_listed_devices="$(what_is_mounted_on /live/medium)"
+# PATCH TODO: we might not want /live/image blacklisted
+	local black_listed_devices="$(what_is_mounted_on /live/image)"
 
 	for dev in $(storage_devices "${black_listed_devices}" "${white_listed_devices}")
 	do
@@ -1258,14 +1310,9 @@
 			continue
 		fi
 
-		local include_list
-		if [ -r "${backing}/${persistence_list}" ]
-		then
-			include_list="${backing}/${persistence_list}"
-		elif [ -r "${backing}/${old_persistence_list}" ]
+		local include_list="${backing}/${persistence_list}"
+		if [ ! -r "${include_list}" ]
 		then
-			include_list="${backing}/${old_persistence_list}"
-		else
 			continue
 		fi
 

Reply to: