Per-app storage limit
Section titled “Per-app storage limit”Overview
Section titled “Overview”This guide explains how to set up disk storage limits for one or more apps.
External EXT4 block storage
Section titled “External EXT4 block storage”Disk that has 10 GB storage
Section titled “Disk that has 10 GB storage”Creating the filesystem
Section titled “Creating the filesystem”Create the EXT4 file system on the disk:
mkfs.ext4 /dev/sdcMounting the disk
Section titled “Mounting the disk”Mount the disk to /mnt/lamp1:
# Create the directory for mounting firstmkdir -p /mnt/lamp1# Mount the device to the directorymount /dev/sdc /mnt/lamp1Add a fstab entry for /dev/sdc so the disk gets mounted when the server boots:
/dev/sdc /mnt/lamp1 ext4 defaults,noatime,nofail 0 2Configuration
Section titled “Configuration”Now add this disk as a Volume - Filesystem Mountpoint.
Fill the fields:
- Name:
lamp1 - Mount Type:
Filesystem Mountpoint - Local Directory:
/mnt/lamp1
Press “Save”.
Now configure the lamp1 app’s Storage Data Directory to use the created volume lamp1 and set “Subdirectory” to data and press Move Data.
The system will now move the app data from /home/yellowtent/appsdata/$APPID to /mnt/lamp1/data.
After the process completes, confirm the data is present in /mnt/lamp1/data with ls -lah /mnt/lamp1/data/
ls -lah /mnt/lamp1/data/total 40Kdrwxr-xr-x 4 www-data www-data 4.0K Nov 7 10:34 .drwxr-xr-x 4 root root 4.0K Nov 7 10:34 ..drwxr-xr-x 2 www-data www-data 4.0K Nov 7 10:04 apache-rw-r--r-- 1 www-data www-data 2.3K Nov 7 10:34 credentials.txt-rw-r--r-- 1 www-data www-data 157 Nov 7 10:04 php.ini-rw-r--r-- 1 www-data www-data 44 Nov 7 10:04 .phpmyadminauth-rw-r--r-- 1 www-data www-data 343 Nov 7 10:04 phpmyadmin_login.txt-rw-r--r-- 1 www-data www-data 100 Nov 7 10:04 PHP_VERSIONdrwxr-xr-x 2 www-data www-data 4.0K Nov 7 10:04 public-rw-r--r-- 1 www-data www-data 50 Nov 7 10:04 run.shThe lamp1 app now uses the lamp1 Volume with a 10GB storage limit.
Disk that has 50 GB storage
Section titled “Disk that has 50 GB storage”For disks with 50GB or more storage, create partitions to achieve a 10GB limit for lamp1.
Formatting the disk an creating the first partition
Section titled “Formatting the disk an creating the first partition”Explanation:
-ssilent (non-interactive) modemklabel gptcreate a new GPT partition tablemkpart primary ext4 0% 10GBmake one primary partition from the start to the 10 GB mark
Create fstab records for the mounts:
for i in {1..5}; do echo "/dev/sdc$i /mnt/lamp$i ext4 defaults,noatime,nofail 0 2" >> /etc/fstabdoneExternal XFS block storage with project quotas
Section titled “External XFS block storage with project quotas”Creating the filesystem
Section titled “Creating the filesystem” wipefs -a /dev/sdc mkfs.xfs -f /dev/sdc ```:::
### Configuration
1. Configure a [Volume - XFS](../volumes.md#xfs), select the device `/dev/sdc` and give the Volume a name.2. Configure the app to use the created XFS Volume and use an identifying name (e.g., the APP ID from the URL `fa43ff2b-c511-4bd8-8c94-79f6910f2aee`) as the `Subdirectory` name.
Data moves to `/mnt/volumes/$VOLUMEID/fa43ff2b-c511-4bd8-8c94-79f6910f2aee/`:
```bashls -lah /mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/fa43ff2b-c511-4bd8-8c94-79f6910f2aee/total 24Kdrwxr-xr-x 5 www-data www-data 167 Nov 7 23:23 .drwxrwxrwx 3 root root 50 Nov 7 23:23 ..drwxr-xr-x 2 www-data www-data 46 Nov 7 23:12 apache-rw-r--r-- 1 www-data www-data 2.3K Nov 7 23:23 credentials.txtdrwxr-xr-x 3 www-data www-data 17 Nov 7 12:06 mnt-rw-r--r-- 1 www-data www-data 157 Nov 7 23:12 php.ini-rw-r--r-- 1 www-data www-data 44 Nov 7 23:12 .phpmyadminauth-rw-r--r-- 1 www-data www-data 343 Nov 7 23:12 phpmyadmin_login.txt-rw-r--r-- 1 www-data www-data 100 Nov 7 23:12 PHP_VERSIONdrwxr-xr-x 2 www-data www-data 40 Nov 7 23:12 public-rw-r--r-- 1 www-data www-data 50 Nov 7 23:12 run.sh- Create the
/etc/projectsand/etc/projidfiles:
touch /etc/projects /etc/projid- Add the project-controlled directories to
/etc/projects:
In the following code block the number 1 is the ID, the character : separates and after that comes the path to the folder.
You can choose the ID freely, but be sure to also edit the following code accordingly.
1:/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/fa43ff2b-c511-4bd8-8c94-79f6910f2aee- Add project names to
/etc/projidto map project IDs to project names:
In the following code block the string lamp1 is a project name, the character : separates and after that comes the project ID from the /etc/projects file.
The lamp1 string can be changed freely, but be sure to also edit the following code accordingly.
lamp1:1- Initialize the project directory:
xfs_quota -x -c "project -s lamp1" "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"- Configure quotas for projects with initialized directories:
xfs_quota -x -c "limit -p bsoft=10G bhard=10G lamp1" "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"- Verify quotas:
xfs_quota -x -c 'report -h' "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"Expected output:
Project quota on /mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7 (/dev/sdc) BlocksProject ID Used Soft Hard Warn/Grace---------- ---------------------------------#0 0 0 0 00 [------]lamp1 108K 10G 10G 00 [------]Changing the project quota
Section titled “Changing the project quota”Change project quotas using the same method as configuration.
Reduce the lamp1 project quota to 5M:
xfs_quota -x -c "limit -p bsoft=5M bhard=5M lamp1" "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"Confirm with:
xfs_quota -x -c 'report -h' "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"Expected output:
Project quota on /mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7 (/dev/sdc) BlocksProject ID Used Soft Hard Warn/Grace---------- ---------------------------------#0 0 0 0 00 [------]lamp1 108K 5M 5M 00 [------]Confirming the quota works
Section titled “Confirming the quota works”Assuming we have set the quota to 5M.
Open the Web Terminal of your app.
Create a 4M big file in /app/data:
fallocate -l 4M /app/data/4MCheck the quota report with:
xfs_quota -x -c 'report -h' "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"The output shows limited space remaining:
Project quota on /mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7 (/dev/sdc) BlocksProject ID Used Soft Hard Warn/Grace---------- ---------------------------------#0 0 0 0 00 [------]lamp1 4.1M 5M 5M 00 [------]Try to create another 1M file with:
fallocate -l 1M /app/data/1MThis produces an error:
fallocate: fallocate failed: No space left on deviceThe quota works.