summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2016-06-15 10:44:06 +0200
committer Eric Hameleers <alien@slackware.com>2016-06-15 10:44:06 +0200
commita4a87869b08723a3d784bec866e53939d9579d1d (patch)
treea2429341b24b202fafcc8341f4b259d5a470dd77
parentee32cb1ffb96484dd23ade86ac45c12aa8833bbb (diff)
downloadliveslak-a4a87869b08723a3d784bec866e53939d9579d1d.tar.gz
liveslak-a4a87869b08723a3d784bec866e53939d9579d1d.tar.xz
liveinit: use boot parameter "nop=wipe" to erase existing persistent data.
Sometimes your Slackware Live develops issues because the persistent data storage is conflicting with new packages or data which you added to the Live OS. This can be fixed by erasing persistent data, thereby reverting the Live OS to its initial state - i.e. when the USB stick was booted for the first time. For this purpose the functionality of the existing "nop" boot parameter was extended to allow the '=' and specifying a value of 'wipe'. Note that the persistent data will be wiped before the Live OS boots, and it does not matter if you are using a persistence directory or a container file for storing persistent data. This wipe includes all your persistent personal data in /home/ unless you have moved your /home into a container file on the USB stick.
-rwxr-xr-xliveinit16
1 files changed, 16 insertions, 0 deletions
diff --git a/liveinit b/liveinit
index cb3f9d2..68a0713 100755
--- a/liveinit
+++ b/liveinit
@@ -48,6 +48,9 @@ LIVEPATH=""
# to avoid anything that writes to disk after we copy the OS to RAM.
VIRGIN=0
+# If set to '1', existing persistent data will be wiped:
+WIPE_PERSISTENCE=0
+
# Used for debugging the init;
# Set DEBUG to '1' to enable explicit pauses; '2' enables verbose script exec;
# and '4' dumps you into a debug shell right before the switch_root:
@@ -176,6 +179,11 @@ for ARG in $(cat /proc/cmdline); do
nop)
VIRGIN=1
;;
+ nop=*)
+ if [ "$(echo $ARG | cut -f2 -d=)" = "wipe" ]; then
+ WIPE_PERSISTENCE=1
+ fi
+ ;;
persistence=*)
PERSISTENCE=$(echo $ARG | cut -f2 -d=)
;;
@@ -670,6 +678,10 @@ if [ "$RESCUE" = "" ]; then
# Try a write... just to be dead sure:
if touch /mnt/media/${PERSISTENCE}/.rwtest 2>/dev/null && rm /mnt/media/${PERSISTENCE}/.rwtest 2>/dev/null ; then
# Writable media and we are allowed to write to it.
+ if [ "$WIPE_PERSISTENCE" = "1" ]; then
+ echo "${MARKER}: Wiping existing persistent data in '/${PERSISTENCE}'."
+ find /mnt/media/${PERSISTENCE}/ -mindepth 1 -exec rm -rf {} \; 2>/dev/null
+ fi
echo "${MARKER}: Writing persistent changes to media directory '/${PERSISTENCE}'."
UPPERDIR=/mnt/media/${PERSISTENCE}
OVLWORK=/mnt/media/.ovlwork
@@ -700,6 +712,10 @@ if [ "$RESCUE" = "" ]; then
echo "${MARKER}: Failed to mount persistence file '/${PERSISTENCE}.img'."
echo "${MARKER}: Falling back to RAM."
else
+ if [ "$WIPE_PERSISTENCE" = "1" ]; then
+ echo "${MARKER}: Wiping existing persistent data in '/${PERSISTENCE}.img'."
+ find /mnt/live/${prdir}/${PERSISTENCE}/ -mindepth 1 -exec rm -rf {} \; 2>/dev/null
+ fi
echo "${MARKER}: Writing persistent changes to file '/${PERSISTENCE}.img'."
UPPERDIR=/mnt/live/${prdir}/${PERSISTENCE}
OVLWORK=/mnt/live/${prdir}/.ovlwork