How Disk Quotas Work
Disk quotas are an integral part of the NTFS file system. Any time a file (or folder) is created on an NTFS volume, that file or folder is assigned an owner (typically the user who created the file or folder in the first place). Before the file is actually saved, NTFS obtains the user ID of the file owner and stores that information in the file’s Standard Information attribute (which is used when tallying the disk space allocation). NTFS then locates the disk quota entry for that user and determines whether the new allocation of disk space will cause the user to exceed the assigned quota. If it will, NTFS then takes the appropriate steps, which can include logging an entry in the System event log or preventing the user from creating the file or folder. As the file changes size, NTFS updates the disk quota entry to reflect the total disk space used by the user. All this happens behind the scenes, and so quickly that you aren’t even aware of it.
Before you can effectively manage disk quotas it’s important to understand that quotas are not configured on a computer-wide basis. Instead, disk quotas are tied to individual NTFS volumes. Each drive has separate quota settings, and the actions you take on one volume do not affect the other volumes. For example, a computer might have a single hard disk divided into three volumes: drives C, D, and E. Each of these drives will have separate quota settings. You can enable disk quotas on drives C and D, yet disable them on drive E. Likewise, you can grant users 50 megabytes of disk space on drive C, and 100 megabytes of disk space on drive D.
In other words, when managing disk quotas the actions you take on one volume do not affect the other volumes in any way. If you allocate User A 50 megabytes of disk space on drive C, this does not also give User A 50 megabytes of disk space on drives D and E. If you disable disk quotas on drive D, the quotas remain enabled on drives C and E. And if you – well, you get the idea. Keep in mind, too, that disk quotas are also configured on a per-user basis, something we’ll discuss in more detail later in this article.
In addition to allocating disk space you can also specify a quota warning level, the amount of disk space use that triggers an alert (an event recorded in the System event log informing you that a user is nearing the quota). You can also determine the action the system takes if a user exceeds the quota:
Take no action at all.
Record an event in the System event log.
Deny the user the right to store additional data until he or she has removed enough files to get back under the quota limit.
WMI includes two classes used for managing disk quotas on NTFS drives. The Win32_QuotaSetting class is used to configure quota settings for each drive; this includes such things as whether or not quotas are enabled on the drive and the default quota and warning limits applied to new users. Meanwhile, the Win32_DiskQuota class is designed to manage individual quota entries: it is used to enumerate, create, modify, and delete quota entries for individual users. Using just these two classes you can perform pretty much any disk quota management task you can think of.