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

Bug#688782: Moving of mount points in initramfs from /live to /root/live does not work in important cases



Package: live-boot
Version: 3.0~b2-1
Severity: grave
Tags: patch

Hi

The attached patch fixes the move of persistence and other mounts from
/live to /root/live inside the initramfs. It also removes some
leftover mount points that are not used because the device did not
contain a persistence layer.

I'm setting the severity to grave as without these changes the
persistence filesystems can not be seen from the live system and
therefore cannot be remounted readonly on shutdown. This leaves these
filesystem in an inconsistent state which may lead to data corruption.
IMO this needs to be fixed for wheezy.

The patch consists of three individual commits that all can be applied
separately.

The readonly remounting of persistence filesystems does not work with
the latest live-config for unrelated reasons. I'll submit a separate bug
report (with patch ;-) ) to fix this issue.

Gaudenz

-- System Information:
Debian Release: wheezy/sid
  APT prefers testing
  APT policy: (800, 'testing'), (700, 'unstable'), (50, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.5-trunk-amd64 (SMP w/2 CPU cores)
Locale: LANG=de_CH.UTF-8, LC_CTYPE=de_CH.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
>From 9339bf268e1d8b58db75228e30cedccffb47caeb Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaudenz@debian.org>
Date: Tue, 25 Sep 2012 17:54:45 +0200
Subject: [PATCH 1/3] Move filesystems even if mountpoint exists

If /live has a persistence layer the mountpoint may already exist. Move
the filesystems anyway.
---
 scripts/boot/9990-main.sh |   11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/scripts/boot/9990-main.sh b/scripts/boot/9990-main.sh
index 5732b2a..a95033e 100755
--- a/scripts/boot/9990-main.sh
+++ b/scripts/boot/9990-main.sh
@@ -146,11 +146,8 @@ Main ()
 	esac
 
 	# Move to the new root filesystem so that programs there can get at it.
-	if [ ! -d /root/live/image ]
-	then
-		mkdir -p /root/live/image
-		mount --move /live/image /root/live/image
-	fi
+	[ ! -d /root/live/image ] && mkdir -p /root/live/image
+	mount --move /live/image /root/live/image
 
 	# aufs2 in kernel versions around 2.6.33 has a regression:
 	# directories can't be accessed when read for the first the time,
@@ -159,9 +156,9 @@ Main ()
 	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 ] && [ ! -d /root/live/findiso ]
+	if [ -d /live/findiso ]
 	then
-		mkdir -p /root/live/findiso
+		[ ! -d /root/live/findiso ] && mkdir -p /root/live/findiso
 		mount -n --move /live/findiso /root/live/findiso
 	fi
 
-- 
1.7.10.4

>From 79cf89b66bace9b980e7c175c0612a68c90d4507 Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaudenz@debian.org>
Date: Tue, 25 Sep 2012 17:56:51 +0200
Subject: [PATCH 2/3] Remove mountpoints if there is no persistence

Remove mountpoint if no persistence layer is found on a device.
---
 scripts/boot/9990-misc-helpers.sh |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/boot/9990-misc-helpers.sh b/scripts/boot/9990-misc-helpers.sh
index 117876f..4429c33 100755
--- a/scripts/boot/9990-misc-helpers.sh
+++ b/scripts/boot/9990-misc-helpers.sh
@@ -911,7 +911,9 @@ probe_for_file_name ()
 	then
 		echo ${ret}
 	else
+		# unmount and remove mountpoint
 		umount ${backing} > /dev/null 2>&1 || true
+		rmdir ${backing} > /dev/null 2>&1 || true
 	fi
 }
 
-- 
1.7.10.4

>From 31a6da42164d1abc7285506738a9a796b9a80afc Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaudenz@debian.org>
Date: Tue, 25 Sep 2012 17:58:50 +0200
Subject: [PATCH 3/3] Move mountpoints below /live/{persistence,rofs}

When moving a mountpoint all mounts below are not automatically moved.
This moves all these mountpoints individually.
---
 scripts/boot/9990-overlay.sh |   19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/scripts/boot/9990-overlay.sh b/scripts/boot/9990-overlay.sh
index 597ff50..5405781 100755
--- a/scripts/boot/9990-overlay.sh
+++ b/scripts/boot/9990-overlay.sh
@@ -405,8 +405,23 @@ setup_unionfs ()
 		done
 	fi
 
-	mkdir -p "${rootmnt}/live"
-	mount -o move /live "${rootmnt}/live" >/dev/null 2>&1 || mount -o bind /live "${rootmnt}/live" || log_warning_msg "Unable to move or bind /live to ${rootmnt}/live"
+	# prepare /root/live with tmpfs for moving of filesystems
+	[ ! -d	"${rootmnt}/live" ] && mkdir "${rootmnt}/live"
+	mount -t tmpfs tmpfs "${rootmnt}/live"
+
+	# move all mount points to root filesystem
+	for dir in rofs persistence
+	do
+		if [ -d /live/${dir} ]
+		then
+			mkdir "${rootmnt}/live/${dir}"
+			for mp in $(ls /live/$dir)
+			do
+				mkdir "${rootmnt}/live/${dir}/${mp}"
+				mount -o move "/live/${dir}/${mp}" "${rootmnt}/live/${dir}/${mp}" >/dev/null 2>&1 || mount -o bind "/live/${dir}/${mp}" "${rootmnt}/live/${dir}/${mp}" || log_warning_msg "Unable to move or bind /live/${dir}/${mp} to ${rootmnt}/live/${dir}/${mp}"
+			done
+		fi
+	done
 
 	# shows cow fs on /overlay (FIXME: do we still need/want this? probably yes)
 	mkdir -p "${rootmnt}/live/overlay"
-- 
1.7.10.4


Reply to: