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

New patches to fix live-sn was Re: Patches to correct live-sn



Greetings,

On Wed, May 6, 2009 at 3:37 AM, Marco Amadori <amadorim@vdavda.com> wrote:
> On Wednesday 06 May 2009, 04:36:53, Richard Nelson wrote:
>
>> Greetings,
>>
>> I am attaching patches for what I believe is a working live-sn setup.
>> I looked through all the options provided and removed many since a
>> working live-sn is essential and one good working way is better than
>> many that do not function or seem to be subsets of the essential need.
>> I believe with /etc/live-snapshot.list you tune in for what you want
>> like /home.
>
> Fixing by removing some features you do not use?
>

I got a little aggressive in making live-sn work. So this try is less
aggressive.

> Would you please like to split the patch in two?
>
> 1. Fix the bug.
>

I believe these patches will make live-sn work. In the process I went
ahead and partially fixed home-sn, but it only works like live-sn so
in concept it is still broken but at least it works more that it did
before.

> 2. Removes features you do not like.
>

Not so much not like but failed to see the purpose of with the idea of
live-sn. Your mailer helped me understand more.

> The patch #1 will be merged sooner than #2 I think.
>
> I know that often less is better, but this removes also things which are meant
> as helpers to create other ways to use persistence and stackable fs.
>

Ok, well this time I tried to be less aggressive in getting live-sn working.

>
> Ok "live-snapshot" is more than just a snapshot helper, maybe it need a name
> split or something, but just removing useful features does not seems viable
> for me.
>

Agreed.

>> I have tested all the remaining persistent partitions types of
>> live-sn, live-rw, and home-rw and all worked ok on my development
>> machine.
>
> Thanks for the quality work you did, but would you like to repost just the
> patch "fix the problem I found" only? Then we could open a discussion if live-
> snapshot other feature could be placed on another script/binary.
>

Ok. As for live-snapshot it is really nice, but I do not care about
splitting I just want to work so I hope these patches are better.

Thanks for the consideration and dialog.

> --
> ESC:wq
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>
> --
> To UNSUBSCRIBE, email to debian-live-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
>
--- /usr/share/initramfs-tools/scripts/live	2009-05-04 10:35:39.000000000 -0500
+++ live	2009-05-06 15:42:25.000000000 -0500
@@ -922,16 +922,16 @@
 	# Look for ${snap_label}.* in block devices
 	snap_label="${1}"
 
-	if [ "${PERSISTENT}" != "nofiles" ]
-	then
-		# search for image files
-		snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snal_label}.ext4 ${snap_label}.jffs2")
-	fi
-
-	if [ -z "${snapdata}" ]
-	then
+#	if [ "${PERSISTENT}" != "nofiles" ]
+#	then
+#		# search for image files
+#		snapdata=$(find_files "${snap_label}.squashfs ${snap_label}.cpio.gz ${snap_label}.ext2 ${snap_label}.ext3 ${snal_label}.ext4 ${snap_label}.jffs2")
+#	fi
+#
+#	if [ -z "${snapdata}" ]
+#	then
 		snapdata=$(find_cow_device "${snap_label}")
-	fi
+#	fi
 	echo "${snapdata}"
 }
 
@@ -941,17 +941,21 @@
 	# and remember the device and filename for resync on exit in live-initramfs.init
 
 	snapdata="${1}"
-	snap_mount="${2}"
+	snap_mount="${2}/${3}-dir"
 	snap_type="${3}"
 
 	if [ ! -z "${snapdata}" ]
 	then
 		log_success_msg "found snapshot: ${snapdata}"
-		snapdev="$(echo ${snapdata} | cut -f1 -d ' ')"
-		snapback="$(echo ${snapdata} | cut -f2 -d ' ')"
-		snapfile="$(echo ${snapdata} | cut -f3 -d ' ')"
+		snapdev="${1}"
+		snapback="${2}"
+		snapfile="${3}"
 
 		RES=""
+		if [ ! -d "${snapback}" ]
+		then
+			mkdir "${snapback}"
+		fi
 		if ! try_mount "${snapdev}" "${snapback}" "ro"
 		then
 			break
@@ -966,7 +970,10 @@
 			RES=$?
 		else
 			# cpio.gz snapshot
-			cd "${snap_mount}"
+			#cd "${snap_mount}"
+			# Below is hard coded for cpio.gz only. 
+			snapfile="${snapfile}.cpio.gz"
+			cd "/root"
 			zcat "${snapback}/${snapfile}" | /bin/cpio --extract --preserve-modification-time --no-absolute-filenames --sparse --unconditional --make-directories > /dev/null 2>&1
 			RES=$?
 			if [ "${RES}" != "0" ]
@@ -1015,7 +1022,14 @@
 		return 1
 	fi
 
-	echo "export ${snap_type}SNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
+	log_success_msg "Attempting to set snapshot type: ${snapfile}"
+	if [ "${snapfile}"=="live-sn.cpio.gz" ]
+	then
+		echo "export ROOTSNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
+	else
+		# Only live-sn and home-sn are options so this one has to be home-sn.
+		echo "export HOMESNAP="${snap_mount}":${snapdev}:${snapfile}" >> /etc/live.conf # for resync on reboot/halt
+	fi
 	return 0
 }
 
@@ -1305,9 +1319,9 @@
 		fi
 
 		# Look for other snapshots to copy in
-		try_snap "${root_snapdata}" "${rootmnt}" "ROOT"
+		try_snap "${root_snapdata}" "${mountpoint}" "${root_snapshot_label}"
 		# This second type should be removed when snapshot grow smarter
-		try_snap "${home_snapdata}" "${rootmnt}/home" "HOME"
+		try_snap "${home_snapdata}" "${mountpoint}" "${home_snapshot_label}"
 	fi
 
 	if [ -n "${SHOWMOUNTS}" ]
--- /sbin/live-snapshot	2009-04-22 14:43:11.000000000 -0500
+++ live-snapshot	2009-05-06 13:57:09.000000000 -0500
@@ -48,11 +48,10 @@
 PROGRAM=$(basename "${EXECUTABLE}")
 
 # Needs to be available at run and reboot time
-SAFE_TMPDIR="/live"
+# Using /live/image here to match initramfs-tools/scripts
+SAFE_TMPDIR="/live/image"
 
-# Permits multiple runs
-MOUNTP="$(mktemp -d -p ${SAFE_TMPDIR} live-snapshot-mnt.XXXXXX)"
-DEST="${MOUNTP}/live-sn.cpio.gz"
+DEST=""
 DEF_SNAP_COW="/live/cow"
 TMP_FILELIST="${PROGRAM}.list"
 
@@ -60,7 +59,27 @@
 SNAP_COW="${DEF_SNAP_COW}"
 SNAP_DEV=""
 SNAP_OUTPUT=""
-SNAP_RESYNC_STRING=""
+
+# Set the snap information that should be pulled in from /etc/live.conf
+if [ -n "${ROOTSNAP}" ]
+then
+	SNAP_RESYNC_STRING="${ROOTSNAP}"
+	MOUNTP="$(echo "${SNAP_RESYNC_STRING}" | cut -f1 -d ':')"
+elif [ -n "${HOMESNAP}" ]
+then
+	SNAP_RESYNC_STRING="${HOMESNAP}"
+	MOUNTP="$(echo "${SNAP_RESYNC_STRING}" | cut -f1 -d ':')"
+else
+	MOUNTP="${SAFE_TMPDIR}"
+fi
+
+# Permits multiple runs
+# Ensure the mount point exists.
+if [ ! -d "${MOUNTP}" ]
+then
+	mkdir "${MOUNTP}"
+fi
+
 SNAP_TYPE="cpio"
 SNAP_LIST="/etc/live-snapshot.list"
 EXCLUDE_LIST="/etc/live-snapshot.exclude_list"

Reply to: