Limit GB ghost instances for self-hosted

Good evening everyone.

I have set up a home server with ubuntu 22.04 and am setting up various instances of ghost on custom domains for various people.

However, I needed to limit the GB that the various admins of the ghost instances installed on my system could use.

How can I set a limit in terms of GB or MB so that at a certain point the upload is blocked? This would be very useful as it would save my storage space a lot.


I’d look into partitioning that server into separate droplets/containers/virtual servers.

Two decades ago (gasp, yes, it was), I had a small flock of real servers running virtual servers with this software: Overview - Linux-VServer. (This was back before every host in existence sold VPS hosting.) It was great because everyone I hosted had the ability to do whatever they needed to do as ‘root’ in their own vservers, but I could put limits on usage so they couldn’t run amok.

YMMV (it HAS been two decades), and it’s very possible there are better options now than there were then!

You can use Quota on Ubuntu. It’s built into the kernel.

sudo apt install --yes quota

Then amend the fstab to include quotas on the filesystem (you can do this for /), and finally assign quotas to users.

1 Like

I ran a web-hosting company and this how we managed per-customer disk space limits-- each customer had a unique unix user that we assigned a quota to.

With Ghost, it normally runs all the instances as a ghost user, so you’ll have to figure out how to customize that user, hopefully in a way that doesn’t break during upgrades or maintenance.

1 Like

Another idea is to partition your disk. Create a partition for each user. Then mount those partitions where the ghost storage for each user is stored.

If you are using BTRFS, you can use sub-volumes for this, and BTRFS natively supports quotos for sub-volumes.

I thought of a similar solution. But before implementing it, I would have liked to see if there was any different solution.

I also thought when the folder reaches a certain weight in GB the front end was disabled leaving only the back end in order to make room. But I don’t know how far it can be done.

Hi everyone. I wanted to write here again because after some time I managed to resolve this situation without using the quota methods for each user.

What I did was simple, and I’m writing this for anyone who has this problem like me.

I created a script on the server where the various instances of ghost run that I called “”

Inside it I have inserted the various paths that I want to control and the space in MB that I want to give them as a limit. All closed in an array.

The script then checks whether the space has been exceeded for that folder. If it has been exceeded it makes all files in that folder read-only. In this way the upload to the site will never be successful and the internal error message will appear, but if the space has not been exceeded it will return the folder to its original permissions.

At this point, however, the script will not start automatically. To do this we should insert a scheduled action with crontab.

In the terminal, just type:

crontab -e

And at the end of the document we add this line:

*/2 * * * * sudo /var/www/

Now the script will check at 2 minute intervals whether the limit has been exceeded. If so it will make the folders all read-only, otherwise it will return them to write and read.
Now we need to make sure that the sudo command is executed without the crontab asking for the sudo password every time. So we enter this command:

sudo visudo

Then we go to the end of the line and insert this line:

yourusername ALL=(ALL) NOPASSWD: /var/www/

/var/www/ is the path where the .sh file was placed, but it can be placed anywhere.
Now the script will do everything automatically.
If we want to change the user size at some point, just open the file with Mousepad or another editor, and change the number next to the website folder. The script will recheck and set all folders to write and read again

If you want the script code you can contact me and I will provide it to you.

Thanks for sharing that.

For anyone building a new server to host Ghost from scratch that wants quota support, I would recommend using quota tools that are already built and tested.

A lot of the original Unix/Linux servers were multi-user systems and quota software was one of the earliest tools built for it.

If you ever used a web-hosting service that advertised that you got a fixed amount of space, they were probably using quota tools like this in the background.