Solve: Diagnose File Persistence Issues in Linux with a Simple Shell Script


Solve: Diagnose File Persistence Issues in Linux with a Simple Shell Script







Not a Live USB Problem? Good. You're in the Right Place.

This post isn’t about running Ubuntu from a thumb drive. Most modern live distros like Tails, Kali, and Mint XFCE have figured out how to support persistence modes — and if you're using those systems, your distro likely documents how to enable it.

What we’re tackling here is something far weirder: a proper, full Linux install — maybe on a laptop, maybe in a VM — that should behave like a normal system but doesn’t. You edit a file in /etc, save something in /home, maybe install a package. Then you reboot. It’s gone. Nothing crashes, nothing screams. But your changes vanish like fog in sunlight.


A Tool for Diagnosing Real Persistence Failures

We wrote a small, no-nonsense shell script to help surface these problems. It’s called linux_persist_check.sh, and it runs on any mainstream Debian-based Linux system, including Ubuntu, Mint, Raspberry Pi OS, and many others. You run it once before reboot, and again after. That’s it. No magic, no patching.

Here’s what it does:
  • Creates a small test file in your home directory
  • Prompts you to reboot manually
  • Offers a way to confirm the file’s existence post-reboot
  • Provides optional diagnostics on system mounts and temporary filesystems

Sample Menu Interface

After launching the tool, you’ll see a clean main menu like this: 

Bash
Linux Persistence Check Utility
===============================
1. Create test file
2. Check for test file
3. Show systemd and mount info
4. Exit

Choose an option:   

Each step leaves a footprint in the session log:

Bash
==== Session Report ====
[2025-05-05 21:14:03] Test file created: /home/yourname/test_persist_file.txt
[2025-05-05 21:14:03] USER INSTRUCTED TO REBOOT SYSTEM   

If the file disappears, the next session will log that too.


Why This Matters

Persistence isn’t just about convenience. On a development machine or server, silent failures to write to disk can mean broken logging, unsaved credentials, vanished code changes, or insecure fallback modes. It’s especially dangerous when the system looks fine — but throws away your work behind the scenes.

We’ve seen this on laptops with dodgy SSD mounts, cloud VMs that revert snapshots automatically, and even physical desktops that were misconfigured during install.


Run the Tool in Five Simple Steps

You can grab the script from our Gist:

View and Download linux_persist_check.sh

1. Download the script from the link above.

2. Make it executable: 

Bash
chmod +x linux_persist_check.sh   

3. Run the script.  

Bash
./linux_persist_check.sh

It will automatically create a test file called test_persist_file.txt.

4. Reboot your system: 


Bash
sudo reboot   

5. Then run the script again to check if the file still exists.

Also, you can manually check to see if the file still exists using the ls -l command:

Bash
ls -l test_persist_file.txt   

If the test file is gone after reboot, your system likely has a persistence issue.


What If the File Disappears?

If the test file is missing after reboot, it means your Linux system isn't preserving disk writes between sessions. That could point to a misconfigured filesystem, a tmpfs or overlay mount in your home directory, an accidental read-only root mount, or an issue in your virtualization layer.

Check the diagnostics in option 3 of the script, or review your /etc/fstab entries and any custom startup scripts. And remember, the session log may offer clues about what's happening behind the scenes.


Final Thoughts

This isn’t a flashy problem, which is exactly why it causes so much pain. A silent failure to persist changes is one of the most frustrating experiences in Linux — and now, at least, you have a way to call it out.

Let us know what you find. The Gist README has room for contributions and diagnostics from your own environment. We’ll be listening.


Need Ubuntu Expertise?

We'd love to help you with your Ubuntu projects.  Feel free to reach out to us at info@pacificw.com.


Written by Aaron Rose, software engineer and technology writer at Tech-Reader.blog.

Comments

Popular posts from this blog

The New ChatGPT Reason Feature: What It Is and Why You Should Use It

Raspberry Pi Connect vs. RealVNC: A Comprehensive Comparison

The Reasoning Chain in DeepSeek R1: A Glimpse into AI’s Thought Process