Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Cleans linux persistent partition.
#!/usr/bin/env bash
#Assumes system is not booted into persistence mode (omit persistence kernel parameters on boot in grub).
if grep -qs " persistence[ |$]" /proc/cmdline
echo "Script not intended to be run in persistence mode."
exit 1
echo "Backing up files from rw branch which were moved into ro branch (the squashfs)."
cd /media/sdb2
sudo mkdir bak
sudo mv bin bak
sudo mv boot bak
sudo mv etc bak
sudo mv lib bak
sudo mv lib64 bak
sudo mv opt bak
sudo mv root bak
sudo mv sbin bak
sudo mv selinux bak
sudo mv srv bak
sudo mv usr bak
sudo mv var bak
sudo sync
echo The files were moved into /bak on the persistent partition. Boot into the persistence system, and if there are no new boot errors, delete the /bak folder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment