Why is My Nextcloud Snap Using More Storage?

Here’s another one of my quick Linux tips, this time largely dealing with what happens to a Nextcloud instance installed with Snap as it takes up too much mystery storage.

How Did You Fix It?

I still recommend reading up on this before jumping to the solution in case you had the same issue I did, as I found various solutions to similar issues online that didn’t quite fix anything for me. Otherwise, jump down to the section titled “Just Give Me the Solution!”

Where Did My Storage Go?

Photo by Pixabay on Pexels.com

I discovered I had this issue just recently with my own Nextcloud server, a set-it-and-forget-it instance of Ubuntu Server. After trying to upload more wallpapers to access on other devices, I got indicators that some wallpapers couldn’t sync. Eventually, my server went offline entirely, becoming completely unreachable just a few hours later.

It became clear I needed to intervene and do something to get my server online again, so I forced it offline before going into my Nextcloud directories from my own client-side computer, my Arch desktop. I scanned around and, perplexingly, nothing was remotely close to using up so much storage. If anything, my Nextcloud instance was lighter than ever. What was going on?

Even after starting the server back up and accessing the console directly through root, I saw my server information telling me that most of my storage was still used up.

Trying the usual stuff like apt autoremove wasn’t doing much of anything. An online search suggested that maybe my logs became bloated, but truncating and deleting them solved nothing.

Trying to look into my directories to see which ones took up the most storage, which didn’t solve the issue right away but still pushed me in the right direction, gave me some breadcrumbs to start effectively troubleshooting the issue.

# du -cha --max-depth=1 / | grep -E "M|G"

The output of this command told me that var was my biggest directory by far. I delved a bit deeper with this command by modifying it each time to go past this directory and further in.

# du -cha --max-depth=1 /var | grep -E "M|G"

-- Same command, but this one goes a little deeper into the /var folder itself.

Soon, it looked like the snap directory had been the culprit. It had massively ballooned more than I thought. Perhaps leftover, unused versions of my Nextcloud snap have been sitting there taking up space?

This is where I made a mistake and assumed I had a bunch of outdated versions of the Nextcloud snap hogging up space, so I ran a script to autoremove unused snaps. While I did clear out some unused ones, this ultimately did nothing and I was still at square one.

Going back to the prior commands, I followed the breadcrumbs deeper into my Nextcloud directories, repeatedly appending anything that came after /var/snap. That was until I found the culprit: a files_trashbin cache of some sort in my Nextcloud snap directory:

/var/snap/nextcloud/common/nextcloud/data/JAHyde/files_trashbin`

This file was so much larger than it needed to be, especially for files I would likely never need to recover. Thus, all I needed to do was delete it.

# rm -rf /var/snap/nextcloud/common/nextcloud/data/JAHyde/files_trashbin`

And with that, my problem was finally solved. I reclaimed so much space for my Nextcloud, going from 99% full to just 18%!

Just Give Me the Solution!

  1. Access your server via console or command line.
  2. Check under var/snap/nextcloud/common/nextcloud/data/YOURNAME/ to see if you have a large files_trashbin file eating up your free storage.
  3. Remove said file with rm -rf!

Did This Help You?

Keep in mind, as I’ve said various times on this site, that I’m barely even a sysadmin. I think this quick tip helps solidify that, especially the part about me thinking my logs were the problem.

Still, if this helped you with your Ubuntu server running a Nextcloud snap, I would appreciate hearing from you in the comments below. Additionally, if you stumbled across this and happen to be more of a sysadmin than I am, I wouldn’t mind hearing some of your insights on how I could have handled this better.

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.