Skip to content
Demo (opens in a new tab)

This guide explains how to set up disk storage limits for one or more apps.

Create the EXT4 file system on the disk:

Terminal window
mkfs.ext4 /dev/sdc

Mount the disk to /mnt/lamp1:

Terminal window
# Create the directory for mounting first
mkdir -p /mnt/lamp1
# Mount the device to the directory
mount /dev/sdc /mnt/lamp1

Add a fstab entry for /dev/sdc so the disk gets mounted when the server boots:

/dev/sdc /mnt/lamp1 ext4 defaults,noatime,nofail 0 2

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/

Terminal window
ls -lah /mnt/lamp1/data/
total 40K
drwxr-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_VERSION
drwxr-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.sh

The lamp1 app now uses the lamp1 Volume with a 10GB storage limit.

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:

  • -s silent (non-interactive) mode
  • mklabel gpt create a new GPT partition table
  • mkpart primary ext4 0% 10GB make one primary partition from the start to the 10 GB mark

Create fstab records for the mounts:

Terminal window
for i in {1..5}; do
echo "/dev/sdc$i /mnt/lamp$i ext4 defaults,noatime,nofail 0 2" >> /etc/fstab
done

External XFS block storage with project quotas

Section titled “External XFS block storage with project quotas”
1:/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/fa43ff2b-c511-4bd8-8c94-79f6910f2aee
  1. Add project names to /etc/projid to map project IDs to project names:

The lamp1 string can be changed freely, but be sure to also edit the following code accordingly.

lamp1:1
  1. Initialize the project directory:
Terminal window
xfs_quota -x -c "project -s lamp1" "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"
  1. Configure quotas for projects with initialized directories:
Terminal window
xfs_quota -x -c "limit -p bsoft=10G bhard=10G lamp1" "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"
  1. Verify quotas:
Terminal window
xfs_quota -x -c 'report -h' "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"

Expected output:

Terminal window
Project quota on /mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7 (/dev/sdc)
Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 0 0 0 00 [------]
lamp1 108K 10G 10G 00 [------]

Change project quotas using the same method as configuration.

Reduce the lamp1 project quota to 5M:

Terminal window
xfs_quota -x -c "limit -p bsoft=5M bhard=5M lamp1" "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"

Confirm with:

Terminal window
xfs_quota -x -c 'report -h' "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"

Expected output:

Terminal window
Project quota on /mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7 (/dev/sdc)
Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 0 0 0 00 [------]
lamp1 108K 5M 5M 00 [------]

Assuming we have set the quota to 5M.

Open the Web Terminal of your app.

Create a 4M big file in /app/data:

Terminal window
fallocate -l 4M /app/data/4M

Check the quota report with:

Terminal window
xfs_quota -x -c 'report -h' "/mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7/"

The output shows limited space remaining:

Terminal window
Project quota on /mnt/volumes/af0b5df5b3254d6db4c3018885cb45d7 (/dev/sdc)
Blocks
Project ID Used Soft Hard Warn/Grace
---------- ---------------------------------
#0 0 0 0 00 [------]
lamp1 4.1M 5M 5M 00 [------]

Try to create another 1M file with:

Terminal window
fallocate -l 1M /app/data/1M

This produces an error:

Terminal window
fallocate: fallocate failed: No space left on device