How do I prune my Lemmy instance?

What type of hardware are you using: Virtual machine
What YunoHost version are you running: 12.0.16
What app is this about: Lemmy 0.19.8~ynh1

Describe your issue

My Lemmy instance has grown and is taking up a lot of space. Diagnostics is giving me a warning. What is a safe way for me to pare it down and keep it from bloating up again? I am the only user.

Share relevant logs or error messages

Storage / (on device /dev/mapper/system-root) has only 17 GiB (4%) space remaining (out of 465 GiB). Be careful.

1 Like

There is not guide for YunoHost, nor I have found any clear information on either Lemmy or its media backend Pict-rs. I’m not even sure the feature exists. :confused:

I always install ncdu right after setting up a server.
This is not specific to any app.
Run sudo ncdu / -x to understand what is taking so much space.
Then you can run sudo yunohost tools basic-space-cleanup that will free up some space. Though it will delete old logs, so in case logs are important, make a local copy of them. @tituspijean may be we can add “–keep-logs” as an argument. We don’t have a dedicated app for analysing the logs.

Your suggestion to run sudo yunohost tools basic-space-cleanup shaved off almost 20GiB, so that’s a help. And thanks for recommending ncdu. It tells me that the big hog is /home/yunohost.app/lemmy/magick, which contains 44,259 files taking 405GiB in total. These files don’t have extensions or discernible filenames; “magick-o6aN5V0h1tB0T_WDGtaIDxgTIeuP0CbC” is one example. I have no idea why they are here taking up so much space. Any ideas?

OK, it seems that imagemagick leaves leftovers that don’t get cleaned. Here is an issue discussing it.

I don’t have lemmy, so try changing the values he talks about and report here, may be yunohost package needs some improvements

That GitHub issue suggests that the problem is caused by pict-rs getting killed and not cleaning up its temp files properly. Here’s the latest log of my lemmy-pict-rs service, which seems to show lots of it getting shut down and restarting. Maybe that hints at root cause. I could live with this if I had a good way to clean out these temp files from time to time. Would it be as simple as sudo rm magick*?

It would be helpful to understand why it is getting killed. And yes, this is what is said in the github issue, just delete the temp files. I’ve also found this https://lemmy.world/post/3892318
Does your server have enough ram/swap? Can you monitor your server using htop/btop to see how it is doing. Check system logs if you find why it is getting killed.

Apparently, I can’t just delete the files. First, I had to change to root user just to get into /home/yunohost.app/lemmy/magick because sudo cd wouldn’t work. Then I tried rm *, but it failed with the bash error “Argument list too long”. Maybe there are too many files. Should I try deleting the folder? Pict-rs will create a new magick folder with the correct permissions the next time it needs to create temporary magick files, right? This did the trick.

My system has 15.6GiB of RAM installed. The VM on which I run Yunohost is configured to use up to half of that. According to diagnosis…

  • The system still has 5.1 GiB (65%) RAM available out of 7.8 GiB.
  • The system has 976 MiB of swap!

So, I think I’m good there.

So why did get killed sudo dmesg -T| grep -E -i -B100 'killed process'

No output to that command. For what it’s worth, the lemmy-pict-rs service appears to have been running continuously for approximately 12 hours.