Sparsebundle Corruption after a Monterey crash

It had to happen at some point in time.

Monterey crashed overnight and for the first time ever, it corrupted the 2 sparsebundles that were mounted. When trying to mount them, I could not mount them again on my M1 mini or my server, both running Monterey. I restored them to the previous version from Time Machine and now they are working again.

At the time of the crash, only Chronosync was running, so I wanted to future-proof my setup to prevent corruption from happening overnight again. I wrote a quick shell script called unmountSparsebundle to unmount all 4 sparsebundles that could possibly be mounted. Essentially, the script just runs the diskutil command in terminal:

diskutil unmount /Volumes/My\ Documents

Rinse and repeat for all 4 mounted sparsebundles. Escape spaces in the file name by a preceding backslash.

Since Chronosync mainly runs at night, I set up a cron job to automatically run the script every night at 11:30pm. That’s rather easy to do:

  • Go to Terminal
  • Export your existing cron jobs by running
    “crontab -l > ~/my_crontab”.
    That creates a file called my_crontab in your home folder
  • Add one line at the end to the my_crontab file: “30 23 * * * ~/unmountSparsebundle” where unmountSparsebundle is the name of your shell script, which resides in your home folder. “30 23” means 11:30pm, whereas “* * *” means all days, all months, all weekdays
  • (Optional): Run “crontab -r” to remove all your cron jobs
  • Run “crontab ~/my_crontab” to upload all cron jobs, including the one that you just added.

That’s it.

I’m sorry to hear your disk images corrupted. You didn’t mention data loss so I am hoping you were able to recover completely from backup. Can I assume you were using them for encrypted storage of some sort? I gave up on sparsebundle disk images many years ago after finding them to be unreliable when I needed them to be rock solid.

2 Likes

Any Dockers or other VMs running?
My Monterey mystery crashes seemed to be related.
(Back to BS now, but was contemplating trying M again.)

1 Like

Yes, I was using these for encrypted storage. They contain sensitive data, such as tax returns.

Fortunately, I had only made changes to these 2 impacted bundles the day before, so I had to recreate only a few files. Not a lot of work. But it does have me scared what could potentially happen.

You mentioned you abandoned yours. How do you secure sensitive data?

Sorry to hear that you have the some issues as well. I’ve had them for generations of macOS. And they only happen at night when backups are running. Only Chronosync is running at that time. During the day I get a few crashes due to bluetooth issues, but I now recognize the symptoms and typically reboot before it happens.

No Dockers or VMs at all.

1 Like

Have you considered using an encrypted disc image?

Or how about just turning on File Vault if it’s your boot drive. If not, encrypted external?

1 Like

File Vault for my internal drive. My Time Capsule backup is encrypted and so is the Carbon Copy Cloner external backup drive sitting on my desk.

Also set “Require password immediately after sleep or screen saver begins” and use the StrongBox app for passwords, etc.

1 Like

@JohnAtl, now you’ve got me confused. I thought a sparse bundle was a type of disk image? That could be encrypted?

Yes, that’s true. My thinking is that a non-sparse disk image might be more reliable.

But that does not solve the issue. If something is written to a disk image (spars bundle or actual partition) when macOS crashes, the disk image may get corrupted. At least on paper I doubt that an actual disk image is safer.

Yes, File Vault is turned on, all backups are encrypted, any login requires a password and I’ve used 1password forever.
All 4 sparsebundles reside on iCloud, so I can access them on all my devices, if need be. And passwords to these four are not stored in the keychain.

I don’t have definitive data either way.
My thoughts:

  • There have been macOS bugs related to sparse disk images.
  • Time Machine uses sparse disk images and fails regularly for me (stopped using it), and several others who have mentioned it on this forum and elsewhere.
  • If you’re mounting disk images that are in a shared iCloud folder, as well as being accessed from multiple devices (perhaps simultaneously), there’s a lot going on there, and a lot of ways for it to fail.

If it were me, I would look for another secure way to share files.
Perhaps tailscale or ResilioSync, or one of these.

Today, the same 2 sparsebundles were corrupted again, even although I only made changes in one. Not sure what’s going on.
After restoring the content that was changed, I created 4 encrypted DMGs and moved all the content from the 4 sparse bundles to the new DMGs. Let’s see how that goes.

1 Like

I’ve been thinking about it. Syncing disc images to the cloud sounds like a bad idea. If they are mounted and in use, they will be changing as they are being copied to the cloud. If the images were not mounted, it would probably work, as it would be an atomic commit. But as it is now, part of the image will be in, say, one state of saving a file, while part is in another state. When the upload completes, the process of uploading the whole image starts again.

1 Like

Correct - that’s why I moved them off iCloud. I don’t have them open on my server und my mac at the same time anyway and while I’m home, it’s enough to just open them on the Mac and then back them up onto the server. And if needed, I can always remotely log into my server from my iPad to grab a file when I’m traveling (again).

1 Like

I put all of my secure files in 1Password. There’s a limit (1GB? 5GB? I don’t remember exactly) but my needs for documents that need that level of security are very small (driver’s licenses, vaccination forms, tax forms).

I trust 1Password more than I trust any kind of disk image.

1 Like

I do the same for individual files that are sensitive (passport, etc.) and that I may have to access at short notice.
One of the (now) DMG files I keep is for taxes. I typically have hundreds of files per tax year and these I don’t want to store in 1password. It may be overkill, though, to store them in a separate encrypted DMG, since my FileVault is encrypted and I use pretty strong passwords everywhere.