Author Topic: ทำ quota ของ user ใน freebsd  (Read 5721 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
ทำ quota ของ user ใน freebsd
« on: มกราคม 23, 2011, 01:01:46 AM »
1 Compile a New Kernel

First you have to compile/install a kernel that supports quota (not enabled by default) (more
information about compiling a new kernel can be found here:
http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/kernelconfig-building.html).

cd /usr/src/sys/i386/conf
cp GENERIC MYKERNEL

Edit the file MYKERNEL and add the line

options QUOTA

Then run the following commands:

/usr/sbin/config MYKERNEL
cd ../compile/MYKERNEL

(For FreeBSD version prior to 5.0, use instead:

cd ../../compile/MYKERNEL )

make depend
make
make install


2 Enable Quota

Edit the file /etc/fstab and look for the entry, in which the directory /home is mentioned, e.g.

/dev/ad0s1d /home ufs rw 2 2

Add the words userquota and groupquota as follows:

/dev/ad0s1d /home ufs rw,userquota,groupquota 2 2

To enable quota at boot time you have to add the following lines to /etc/rc.conf:

quota_enable="YES"
check_quotas="YES"

Reboot the system:

shutdown -r now

After the reboot run the following commands:

quotacheck -a
quotaon -a

เราสามารถกำหนด quota ได้โดย

#edquota golf
Quotas for user golf:
/home: blocks in use: 62, limits (soft = 0, hard = 0)
inodes in use: 25, limits (soft = 0, hard = 0)


Change tthis lines as displayed below to set up the limits:

Quotas for user golf:
/home: blocks in use: 62, limits (soft = 1024, hard = 204
inodes in use: 25, limits (soft = 0, hard = 0)

เรากำหนด quota ของ user=golf ไว้แค่ 1M ครับแล้วไม่เกิน 2M

* ภายในไฟล์
o blocks คือ พื้นที่(ขนาดไฟล์) ที่ใช้ไป
o soft คือ Soft Limit เป็น quota ขั้นต่ำ อนุญาตให้ user ใช้พื้นที่เกิน quota นี้ได้
แต่ไม่เกิน grace วัน
o hard คือ Hard Limit เป็น quota สูงสุด ไม่อนุญาตให้ user ใช้พื้นที่เกิน quota นี้ (เกิน
soft ได้ แต่ห้ามเกิน hard)
o inodes คือ จำนวนไฟล์ ที่ใช้ไป โดยมี soft และ hard เช่นเดียวกับ blocks
o grace คือ จำนวนวันที่สามารถใช้พื้นที่เกิน soft limit ได้

หมายเหตุ: หน่วยของพื้นที่ที่ใช้คือ Kilobyte (KB)

* เปิดการใช้งาน User Quota

* แสดงรายละเอียด quota ของทุกๆ user

repquota -a