- Use Disk Quotas in Dedicated Linux Servers
- How to Use Disk Quotas in Dedicated Linux Servers With cPanel
- How to Use Disk Quotas in Dedicated Linux Servers with Plesk
Plesk is among the most popular platforms developers and website admins use to manage their server resources. Disk quotas are an essential aspect of managing resources on dedicated Linux servers. They allow admins to limit the amount of disk space each user can use, ensuring the server remains stable and secure.
If you're using Plesk, a popular control panel for Linux and Windows servers, you can easily set up dedicated server disk quotas for your users. This article looks at how to use disk quotas in dedicated Linux servers with Plesk. It covers the basics of disk quotas and their different types and guides you through the steps to set them up disk quotas on your dedicated server.
What Does Disk Quota Do?
As mentioned, disk quota or Linux server disk quotas is a protocol that allows server admins to limit the amount of disk space that a user or group of users can use on a filesystem. The limits can be critical in shared hosting environments or servers with multiple users, where disk space may be limited or expensive. It is sometimes used even with dedicated server hosting.
Users' disk usage is monitored when a dedicated server disk quota is enabled. When they reach their allotted quota, they're prevented from writing additional files to the server. This prevents users from consuming too much disk space, ensuring enough space for other users and applications on the server. In addition, disk quotas can prevent unexpected downtime or data loss caused by filesystems becoming full.
Disk quota is significant on servers where users can upload or create their content, such as web hosting servers, shared file servers, or email servers. Without such limitations, a single user or group of users could easily consume all available disk space, leading to downtime, performance issues, or even data loss in the worst-case scenario.
What Are the Two Types of Disk Quotas?
The two major types of Disk Quotas are usage or block quota and inode or file quota. Let’s explain each of these in detail.
Usage or block quota
Usage quota refers to a dedicated server disk quota system that limits the amount of disk space a user or group can use regarding the number of blocks they can write to the filesystem. For those who may not know, a block is the smallest unit of disk space allocated to a file, and block-level quotas apply to the entire disk block, regardless of the file size. Block-level quotas consider the size of the files written to the filesystem and are typically more accurate in limiting disk space usage.
Inode or file quota
The inode or file quota refers to the disk quota system limiting the number of files a user or group can create or store in a particular directory or on the entire filesystem. File-level quotas are not based on the size of the files but instead on the number of files. This means that even small files contribute to the quota limit, which may not accurately reflect actual disk space usage.
Using Disk Quotas on Plesk Servers
Plesk servers come in a variety of underlying operating systems like: Windows, CentOS, and Ubuntu VPSs, as well as dedicated servers. These systems address disk quotas in different ways. However, they all use the same tools within the Plesk interface. Plesk servers can assign quotas on an individual domain basis or through the Service Plans & Subscriptions system. Below are both of these methods.
Plesk Initial Quota Setup in CentOS 7
As with any server, initialize the quota setup so disk quotas can be tracked. How this is done depends on the underlying operating system. This article includes instructions for initializing our Fully Managed CentOS 7 Plesk servers.
The following outline shows the initial setup of quotas on our Fully Managed Plesk Onyx 17 servers, running the CentOS 7 Linux distribution. These servers do not have quotas enabled by default.
Login to our server via SSH.
Determine the DEVICENAME of the drive that requires quotas. This is done by running the below command.
Example Output: ~ $ /usr/local/psa/admin/sbin/usermng --isquotable usermng: Userquota is not enabled on device: /dev/vda3 usermng: Userquota is not enabled on device: /dev/vda3 1
The DEVICENAME for use later is /dev/vda3.
Use the DEVICENAME to identify the UUID for this device. This is done by passing the DEVICENAME along to the following command.
Example Output: ~ $ blkid /dev/vda3 /dev/vda3: UUID="7d7a2cb2-4ef6-42e2-998a-86d6373f5cd1" TYPE="ext4" PARTLABEL="primary" PARTUUID="da626122-0dbe-461e-93af-a7ae3f43f2e4"
Note the UUID of DEVICENAME is 7d7a2cb2-4ef6-42e2-998a-86d6373f5cd1.
At this stage, you have identified the drive by both DEVICENAME and UUID. Next, open the /etc/fstab config file in our preferred editor. Then, identify the lines in the config containing either your UUID or DEVICENAME.
Example by UUID: ~ $ cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Apr 4 14:11:03 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=7d7a2cb2-4ef6-42e2-998a-86d6373f5cd1 / ext4 defaults 1 1 UUID=54cda6e8-74f4-40a9-a79a-e288ed321a3e swap swap defaults 0 0
Example by DEVICENAME: ~ $ cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Apr 4 14:11:03 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/vda3 / ext4 defaults 1 1 /dev/vaa2 swap swap defaults 0 0
Modify the identified line(s) by appending a usrquota flag onto their defaults flag. Make sure each flag is separated by a single comma, like in the example.
Example by UUID: ~ $ cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Apr 4 14:11:03 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # UUID=7d7a2cb2-4ef6-42e2-998a-86d6373f5cd1 / ext4 defaults,usrquota 1 1 UUID=54cda6e8-74f4-40a9-a79a-e288ed321a3e swap swap defaults 0 0
Example by DEVICENAME: ~ $ cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Apr 4 14:11:03 2017 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/vda3 / ext4 defaults,usrquota 1 1 /dev/vaa2 swap swap defaults 0 0
Save our changes to the /etc/fstab config file.
Remount the file system to make it aware of the changes.
mount -o remount /
Example Output: ~ $ mount -o remount /
Install the quota system package. Use the YUM package manager as in the example.
yum install quota -y
Example Output: ~ $ yum install quota -y Dependencies Resolved ============================================================= Package Arch Version Repository Size ============================================================= Reinstalling: quota x86_64 1:4.01-14.el7 system-base 179 k Transaction Summary ============================================================= Reinstall 1 Package Total download size: 179 k Installed size: 887 k Downloading packages: quota-4.01-14.el7.x86_64.rpm | 179 kB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:quota-4.01-14.el7.x86_64 1/1 Verifying : 1:quota-4.01-14.el7.x86_64 1/1 Installed: quota.x86_64 1:4.01-14.el7 Complete!
Next, prepare quota files. This is done by running the following command.
/sbin/quotacheck -cfmvF vfsv0 /
Example Output: ~ $ /sbin/quotacheck -cfmvF vfsv0 / quotacheck: Your kernel probably supports journaled quota but you are not using it. Consider switching to journaled quota to avoid running quotacheck after an unclean shutdown. quotacheck: Scanning /dev/vda3 [/] done quotacheck: Old group file name could not been determined. Usage will not be subtracted. quotacheck: Checked 22834 directories and 123065 files
Turn on the quota system.
Example Output: ~ $ quotaon /dev/vda3
The Plesk interface will not see quotas enabled until you refresh Plesk components. This can be done simply by restarting the Plesk service.
Example Output: ~ $ /etc/init.d/psa restart
Disk Quotas should now be available throughout the Plesk interface.
Plesk Service Plans & Subscriptions
Plesk provides quota management through Service Plans & Subscriptions. These features allow the creation of predefined Plans to control a site’s limitations, including disk quotas. Plans can be added, removed, edited, or deleted. Start by logging into Plesk and creating a Service Plan.
Creating a Service Plan in Plesk
- Click Service Plans.
- Stay on the Hosting Plans tab
- Click the Add a Plan button
- Wait for the follow-up page to load.
- Give the Service Plan a name
- Stay on the Resources tab
- Set Disk space as needed
Assign Sites to Service Plan Subscriptions
- Click on Subscriptions.
- Enable check for the needed site.
- Click the Change Plan button.
- Wait for the follow-up page to load.
- Select the service plan from the dropdown.
Plesk Planless Quotas
Service Plans & Subscriptions are not mandatory for disk quotas. Assign quotas on select domains, circumventing the need for a Service Plan. This may be preferred on smaller servers hosting only a few sites versus configuring Service Plans for only a few users.
Planless Quotas in Plesk
- Click on Domains.
- Click the name of the domain to change.
- Wait for the Domain page to finish loading.
- Click on Web Hosting Access.
- Wait for the Web Hosting Access page to finish loading.
- Set Hard quota on disk space as needed.
What Do You Do When You Have Reached Your Disk Quota?
If you are a user or among users within a group that has reached its disk quota limit, you can no longer write files to the server. To fix this issue, here are some options you can try out.
- Identify the files and folders (directories) that occupy most of the server space. You will likely notice unnecessary files and directories that occupy your space.
- Remove all the unnecessary files or directories that are consuming your server space. Use the rm command to delete files and the rmdir command to delete directories.
- Consider compressing files or directories to save some server space. Use tools like gzip or tar to compress files or directories.
If the above steps don’t create enough space, consider contacting your hosting provider or admin to allocate more storage by increasing your disk quota.
How Do I Reduce Disk Quota?
To reduce the dedicated server disk quotas of a particular user, follow the steps below
- Log in to your Linux server as the root user.
- Identify the user whose disk quota you want to reduce by running the quota command followed by their username.
- You should then determine the type of disk quota used for the user.
- If it is a block quota, run the edquota command followed by the username. This command opens the text editor allowing you to edit the quota limit.
- Save the changes made and close the text editor.
In summary, dedicated server disk quotas are essential for managing disk usage on dedicated Linux servers with Plesk. By setting limits on the amount of disk space that users or groups can use, disk quotas help prevent the server from running out of disk space and ensure that all users have fair access to resources. As a server admin, monitoring disk usage and adjusting disk quotas is essential to ensure the server is running as intended.
- Using MySQL Command Line to Create a User
- How to Use Disk Quotas in Dedicated Linux Servers With cPanel
- Remove a MySQL User on Linux via Command Line
- Remove Permissions for a MySQL User on Linux via Command Line
- Grant Permissions to a MySQL User on Linux via Command Line
- Delete a MySQL or MariaDB Database via Command Line
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.