The first thing we need to do is ensure that the filesystem that contains the users is configured to run quotas. This is a simple task and is achieved by mounting the required filesystem with the “quota” option enabled. We also need to create a file, named quotas, in the top level (mount point) of each filesystem. This file provides a location for the system to store quota information for that particular filesystem.
All our users are located on one filesystem—/export/home—therefore, we only need to configure this for quotas. To do this, we modify the “mount” options in the /etc/vfstab file. Ours is shown below after modification. Although we have used the “rq” option, we could just have easily used “rw,quota.”
hydrogen# cat /etc/vfstab #device device mount FS fsck mount mount #to mount to fsck point type pass at boot options # fd - /dev/fd fd - no - /proc - proc proc - no - /dev/dsk/c0t0d0s0 /dev/rdsk/c0t0d0s0 / ufs 1 no – /dev/dsk/c0t0d0s1 - - swap - no – /dev/dsk/c0t0d0s4 /dev/rdsk/c0t0d0s4 /var ufs 1 no - /dev/dsk/c0t0d0s5 /dev/rdsk/c0t0d0s5 /opt ufs 1 no - /dev/dsk/c0t0d0s6 /dev/rdsk/c0t0d0s6 /usr ufs 1 no - /dev/dsk/c0t0d0s7 /dev/rdsk/c0t0d0s7 /export/home ufs 1 no rq swap - /tmp tmpfs - yes – hydrogen#
Before we activate the vfstab changes, we'll create the quotas file and set the correct permissions on it to make sure users can't read it and determine everyone else's quotas. Again, since we have only enabled quotas on one filesystem, we only need to create the one file as shown below:
hydrogen# touch /export/home/quotas hydrogen# chmod 600 /export/home/quotas hydrogen#
Quotas are enabled at boot time through the start-up script named MOUNTFSYS. The code extract below shows the lines that are used to carry this out:
hydrogen# more /etc/init.d/MOUNTFSYS <lines removed for clarity> if cut -f 4 /etc/mnttab | egrep '^quota|,quota' >/dev/null 2>&1; then echo 'Checking UFS quotas: c' /usr/sbin/quotacheck -a –p echo 'done.' /usr/sbin/quotaon –a fi <lines removed for clarity> hydrogen#
We can see from this that MOUNTFSYS searches /etc/mnttab for any entries that have mount options of quota set, which is why we need to update /etc/vfstab. To do this, we can either reboot the system or remount the device. In our case, we will remount the device, which means we are bypassing the MOUNTFSYS script. So, we'll have to manually turn quotas on and run quotacheck to determine the current user quotas:
hydrogen# umount /export/home hydrogen# mount /export/home hydrogen# quotaon -a hydrogen# quotacheck –av *** Checking quotas for /dev/rdsk/c0t0d0s7 (/export/home) hydrogen#
If we take a look at our mnttab, we can see that /export/home has now been mounted with the correct quota options:
hydrogen# cat /etc/mnttab /proc /proc proc rw,suid,dev=2940000 969653177 /dev/dsk/c0t0d0s0 / ufs rw,suid,dev=1980000 969653177 /dev/dsk/c0t0d0s4 /var ufs rw,suid,dev=1980003 969653177 /dev/dsk/c0t0d0s5 /opt ufs rw,suid,dev=1980006 969653177 /dev/dsk/c0t0d0s6 /usr ufs rw,suid,dev=1980009 969653177 /dev/dsk/c0t0d0s7 /export/home ufs rw,suid,dev=1980012,quota 969653177 fd /dev/fd fd rw,suid,dev=2a00000 969653177 swap /tmp tmpfs rw,dev=1 969653178 hydrogen#
To verify that quotas are configured correctly, we could run repquota. Although it won't display any user information (as we haven't entered any yet), it will still output the header information, which indicates that everything is working correctly:
hydrogen# repquota -a /dev/dsk/c0t0d0s7 (/export/home): Block limits File limits User used soft hard timeleft used soft hard timeleft hydrogen#