Setting Disk Quotas
To set quotas for limiting user storage space, it is necessary to recompile the kernel.
New players might benefit from some familiarity with this process before screwing around with their system's kernel.
Firstly, make a new kernel config file by copying the original. In this example, I copy GENERIC to a new file called QUOTKERN:
cd /usr/src/sys/i386/conf
Directory missing? The kernel source has not been installed. To install the kernel source run:
sysinstall
Select configure | distributions | src | sys..
Follow the prompts to install the kernel source - basically keep hitting OK.
Creating a New Kernel
So, again..
cd /usr/src/sys/i386/conf
cp GENERIC QUOTKERN
Edit the new kernel file:
vi QUOTKERN
Scroll to the bottom of the options section in the new kernel config file and add the following line:
options QUOTA
Yep. Just that. Don't get too carried away. And don't ask for help either. What are you, a pansy? This is CERT 4 material after all and you're a Big Boy now, with Big Trousers to fill. What, you think REAL UNIX ADMINISTRATORS ask for help!? Of course they don't, they just sit there flogging themselves until they figure it out. Just save those changes to the file and exit, while you still can..
Edit rc.conf:
vi /etc/rc.conf
Add lines..
enable_quotas="YES"
check_quotas="NO"
The check_quotas option is turned off because if enabled, quotacheck tends to make the system boot like a dog turd on tranquillizers.
Edit fstab:
vi /etc/fstab
Enable the disk quotas on a per-slice basis. To do this, add ",userquota" to the /home slice (or the partition to enable quotas on)
e.g..
# Device Mountpoint FStype Options Dump Pass#
/dev/ad0s1b none swap sw 0 0
/dev/ad0s1a / ufs rw 1 1
/dev/ad0s1d /home ufs rw 2 2
/dev/acd0 /cdrom cd9660 ro,noauto 0 0
to
/dev/ad0s1d /home ufs rw,userquota 2 2
Next recompile the kernel:
cd /usr/src/sys/i386/conf
/usr/sbin/config QUOTKERN
cd ../compile/QUOTKERN
make depend
make
make install
Reboot the server after taking a nice long coffee break waiting for the kernel to recompile. While Brad and I were waiting, we entertained ourselves watching Simon scewing up his kernel settings..
Configuring the Quotas
In the normal course of operations you should not be required to run the quotacheck, quotaon, or quotaoff commands manually. However I found that the quota thing doesn't seem to work until you set up at least one user account with a quota and tyhen reboot the system..
To verify enabled quotas, type:
quota -v
This shows a summary of disk usage and current quotas. Note that by default, the logged on user sees their
own quota settings only. It would be handy if root could view everybody's usage stats wouldn't it. Still, this isn't Windows 2000..
To piss off a rather nerdy user, called Dan:
edquota -u dan
Congratulate yourself on taking the trouble to learn vi here, as this command will crank up a vi editor session where the user's file quota can be set:
Quotas for user test:
/home: kbytes in use: 10, limits (soft = 50, hard = 75)
inodes in use: 7, limits (soft = 50, hard = 60)
Modify the soft = setting to the warning limit in KB and modify the hard = setting the the absolute maximum the user will be allowed to store, again in KB.
Leave the rest of the file untouched. The kbytes in use: part will change itself automatically, according to what's happening. Don't do what our man, Brad did and try and change it, daft bugger..
Test that quotas are working by logging in as the user and trying to copy scads of files to the user's home drive (i.e. /home/dan). The 'quota limit exceeded' messages should pop up, with a slap on the wrist for trying to upload too much stuff..
- A.
|
|
|