Implementing Windows Server 2008 File System Quotas

File system Quotas are used to restrict the amount of space users can consume or to report on the space consumed by them. They are useful for reporting on those users or folders that are consuming large amounts of disk space on a file server. Ben Lye shows that File system quotas are quick and easy to set up, with three different methods available for configuring them

Disk quotas have been available in Windows since Windows 2000 was released, and could be used by administrators to limit the amount of space users could use on an NTFS volume.  Disk quotas are based on file ownership rather than folder structure and because of this they are not particularly useful in all situations.  For example, if your server had a single storage volume and you need to apply quotas to different folders on the volume then disk quotas will not help.

File system quotas, which were first introduced in Windows Server 2003 R2, and are a part of the File Server role in Windows Server 2008 (and Windows Server 2008 R2), offer many benefits over disk quotas.  With file system quotas we can set quotas for specific folders on the volume, we can use templates to ensure consistent application of quotas, and we can set quotas which are automatically applied to all sub-folders of a folder.

Additionally, file system quotas are useful not just for limiting the amount of space users can consume, but also for reporting on space used – quotas can be set with so-called “soft” limits which are used for monitoring rather than enforcing limits.  This functionality can be extremely useful for quickly determining which users or folders are consuming large amounts of disk space on a file server.

Quota thresholds can be configured so that users or administrators receive notifications when quotas have been reached or are about to be reached.  Multiple thresholds can be configured for individual quotas, and actions can include sending e-mail messages, logging to the Windows event log, running commands or scripts, or generating storage reports.

In Windows Server 2008 file system quotas are managed with the File Server Resource Manager (FSRM) console (which is installed as a role service in the File Services role), the command line utility dirquota, or with Windows PowerShell using a COM API.

870-BL1.JPG

Figure 1: Windows Server 2008 File Server Resource Manager

There are two kinds of quota available – hard quotas which set a limit and enforce it, and soft quotas which set a limit but only report on it.  Soft quotas are useful for monitoring disk space use.  Quotas are commonly applied using quota templates, which are a mechanism for easily applying the same quota settings to one or more folders.  Quota Templates are the recommended way to configure quotas and FSRM includes some example templates which cover a range of scenarios, including using both hard and soft quota types.

Before we start to configure quotas which will generate e-mail messages, the quota File Server Resource Manager needs to be configured with an SMTP server, and optionally, the default administrator recipients, and the default “from” address.

Like all aspects of quota management, the FSRM settings can be applied using three different tools and you can choose the method appropriate to your needs.

To configure FSRM using the FSRM console:

  1. Launch the File Server Resource Manager
  2. Select the root node, labelled “File Server Resource Manager”
  3. In the Action Pane click “Configure Options…”
  4. Enter an SMTP server and if desired configure the other settings

    870-BL2.JPG

  5. Click the “OK” button

To configure FSRM using the command line:

  1. Open an elevated command prompt window
  2. Enter the command “dirquota admin options /From:quota-admin@example.com /AdminEmails:quota-admin@example.com /SMTP:smtp.example.com”

870-BL3.JPG

To configure FSRM using Windows PowerShell:

  1. Open Windows PowerShell
  2. Enter these commands (or save them as a script and run it):

870-BL3.JPG

Quota Example – Home directories with a 5GB limit

A common use of file system quotas is to put limits on the size of user’s personal storage space (folders which are often referred to as home directories) on a file server.  The requirements of this scenario are to limit the space each user can use to 5GB, alert administrators when 90% of the quota has been reached, and automatically apply quotas to new home directories.  The solution requires the implementation of new quota template and an auto apply quota.

Step 1: Create the new quota template

The first step is to create a new template, which we will use later to apply the quota to the file system.  Using a template means we can easily make changes to all folders where we have applied the template quota settings.  The template can be created using the FSRM, the dirquota command line tool, or PowerShell, meaning you can choose the tool with which you feel comfortable with and that fits most of your scenarios.

To create the new quota template using the FSRM:

  1. Launch the File Server Resource Manager
  2. Expand “Quota Management” -> “Quota Templates”
  3. In the Action Pane click “Create Quota Template”
  4. Enter the template name and set the space limit

    870-BL5.JPG

    Note: To set a soft quota (for monitoring only) check the “Soft Quota” radio button

  5. Click the “Add” button to add a notification threshold
  6. Set the notification percentage to 90, check the “Send e-mail to the following administrators”, and enter an appropriate destination e-mail address. You can also customise the message text.

    870-BL6.JPG

  7. Click the “OK” button twice

To create the new quota template using the dirquota command line utility:

  1. Open an elevated command prompt (or Windows PowerShell) window
  2. Create a text file called notification.txt containing the text of the notification message (an example of this text message can be downloaded from this article)
  3. Enter this command:

870-BL7.JPG

Note: To set a soft quota (for monitoring only) change “/Type:Hard” to “/Type:Hard”

To create the new quota using Windows PowerShell:

  1. Open Windows PowerShell
  2. Enter these commands (or save them as a script and run it):

Note: To set a soft quota (for monitoring only) change “$template.QuotaFlags = $template.QuotaFlags -bor 0x100” to “$template.QuotaFlags = $template.QuotaFlags -bxor 0x100” to disable the hard limit flag.

870-BL8.JPG

Step 2: Create the Quota

The next step is to use the new quota template to apply the quota to the file system.

In this example we’ll say that the home directories are all subfolders of C:\Home.  Because we want any new home folders to automatically have the quota applied we need to create an Auto apply Quota.  Auto apply quotas are applied to all existing subfolders and any future folders.

To create the quota using the FSRM:

  1. Launch the File Server Resource Manager
  2. Expand “Quota Management” -> “Quotas”
  3. In the Action Pane click “Create Quota”
  4. Enter the quota path and choose the appropriate template

    870-BL9.JPG

  5. Click the “Create” button

To create the quota using the dirquota command line tool:

  1. Open an elevated command prompt window
  2. Create a text file called notification.txt containing the text of the notification message (an example of this text message can be downloaded from this article)
  3. Enter the command “dirquota autoquota add /Path:C:\Home /SourceTemplate:”Default Home Directory (5GB Limit)””

870-BL10.JPG

To create the quota using Windows PowerShell:

  1. Open Windows PowerShell
  2. Enter these commands (or save them as a script and run it):

870-BL11.JPG

Quota Exceptions / Folder-Specific Quotas

Naturally there will be occasions when a folder needs to be excluded from a template or auto apply quota.  In these situations you can easily add a specific quota for that folder to either increase the limit or to disable the quota entirely.

To create the quota exception using the FSRM:

  1. Launch the File Server Resource Manager
  2. Expand “Quota Management” -> “Quotas”
  3. Select the folder you wish to make the exception for
  4. In the Action Pane click “Edit Quota Properties…”
  5. Enter new limit for the quota

    870-BL12.JPG

  6. Click “OK”

Note: Check the “Disable quota” box to disable the quota

To create the quota exception using the dirquota command line tool:

  1. Open an elevated command prompt window
  2. Enter the command …
    “dirquota quota add /Path:C:\Home\John_Smith /SourceTemplate:”Default Home Directory (5GB Limit)” /Limit:10GB /Overwrite”

870-BL13.JPG

Note: To disable the quota append the command with “/status:disabled”.

To create the quota exception using Windows PowerShell:

  1. Open Windows PowerShell
  2. Enter these commands (or save them as a script and run it):

870-BL14.JPG

Note: To disable the quota, insert the line “$quota.QuotaFlags = $quota.QuotaFlags -bor 0x200” before saving the quota

How Quotas Affect Clients

When a client maps a network drive to a folder which has a hard quota applied the size of the volume and the amount of available disk space shown is equal to the quota settings.

870-BL15.JPG

Figure: Mapped drive showing hard quota limit as volume size

When a hard quota is met or exceeded clients will receive a message telling them that the volume is out of disk space.

870-BL16.JPG

Figure: Insufficient disk space message

Viewing Quotas

Administrators can view hard and soft quotas using FSRM, and viewing quotas this way can be a quick method for finding large folders or large consumers of space.

870-BL17.JPG

Figure: Quotas in File Server Resource Manager

File system quotas are quick and easy to set up, with three different and flexible methods available for configuring them.  Properly applied they can be a good tool to help ensure efficient use of storage resources, a convenient countermeasure against storage waste, and a useful tool for reporting on storage utilisation.  There is an IO performance penalty for using quotas, but the benefits will probably outweigh the small performance cost.

How you log in to Simple Talk has changed

We now use Redgate ID (RGID). If you already have an RGID, we’ll try to match it to your account. If not, we’ll create one for you and connect it.

This won’t sign you up to anything or add you to any mailing lists. You can see our full privacy policy here.

Continue

Simple Talk now uses Redgate ID

If you already have a Redgate ID (RGID), sign in using your existing RGID credentials. If not, you can create one on the next screen.

This won’t sign you up to anything or add you to any mailing lists. You can see our full privacy policy here.

Continue