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

Bug#688784: Remount persistence filesystems read-only before shutdown



Package: live-config
Version: 3.0.5-1
Severity: grave
Tags: patch

Hi

Persistence filesystems have to be remounted readonly on shutdown or
reboot to avoid data corruption. The attached patch fixes this problem.
The commit message contains more details.

I set the severity to grave as this should be fixed before wheezy as it
can lead to data corruption.

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 4579aadaf3ae7af7d4a8c6ba67fb1c6d93a4fa0d Mon Sep 17 00:00:00 2001
From: Gaudenz Steinlin <gaudenz@debian.org>
Date: Tue, 25 Sep 2012 18:21:40 +0200
Subject: [PATCH] Remount persistence filesystem readonly on shutdown

All filesystems belonging to a persistence layer must be remounted
readonly to avoid data corruption. The filesystems cannot be unmounted
because they are still in use by the union mount. The sync call ensures
that all data is written to disk before shutdown or reboot. Remounting
by itself does not sync data to disk.

This code does not abort if remounting fails. We can't do much about
it anywhy at this stage.
---
 bin/boot-init.sh |   14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/bin/boot-init.sh b/bin/boot-init.sh
index ba99107..a500dff 100755
--- a/bin/boot-init.sh
+++ b/bin/boot-init.sh
@@ -154,7 +154,19 @@ do
 	cache_path "${path}"
 done
 
-mount -o remount,ro /live/overlay > /dev/null 2>&1
+mount -o remount,ro /live/overlay > /dev/null 2>&1 || true
+
+# remount all persistency mounts read only
+if [ -d /live/persistence ]
+then
+	for mp in $(ls /live/persistence)
+	do
+		mount -o remount,ro /live/persistence/${mp} > /dev/null 2>&1 || true
+	done
+
+	# sync all data to disk to make sure persistency is in a consistent state
+	sync
+fi
 
 # Check if we need to eject the drive
 if grep -qs "cdrom-detect/eject=false" /proc/cmdline || \
-- 
1.7.10.4


Reply to: