644 lines
11 KiB
HTML
644 lines
11 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Qouta</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.60"><LINK
|
|
REL="HOME"
|
|
TITLE="Securing and Optimizing Linux"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Set Limits using Qouta"
|
|
HREF="quota.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Set Limits using Qouta"
|
|
HREF="quota.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Create of the quota.user and quota.group "
|
|
HREF="chap20sec157.html"></HEAD
|
|
><BODY
|
|
CLASS="section"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Securing and Optimizing Linux: RedHat Edition -A Hands on Guide</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="quota.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 20. Set Limits using Qouta</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="chap20sec157.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H1
|
|
CLASS="section"
|
|
><A
|
|
NAME="AEN10192"
|
|
>20.1. Qouta</A
|
|
></H1
|
|
><DIV
|
|
CLASS="highlights"
|
|
><A
|
|
NAME="AEN10194"
|
|
></A
|
|
><P
|
|
> Quota is a system administration tools for monitoring and limiting users and/or groups disk usage, per file system. Two features of disk storage with quota are available to set limits:
|
|
<P
|
|
></P
|
|
><UL
|
|
><LI
|
|
><P
|
|
> The first is the number of inodes number of files a user or a group of users may possess.
|
|
</P
|
|
></LI
|
|
><LI
|
|
><P
|
|
> The second is the number of disk blocks amount of space in kilobytes that may be allocated to a user or a group of users.
|
|
</P
|
|
></LI
|
|
></UL
|
|
>
|
|
With quota, the users are forced by the system administrator to not consume unlimited disk space on a system. This program is handled on per user, per file system basis and must be set for each file system
|
|
separately.
|
|
</P
|
|
></DIV
|
|
><P
|
|
> The first thing you need to do is ensure that your kernel has been built with Quota support enabled. In the 2.2.14 kernel version you need ensure that you have answered <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>Y</B
|
|
></TT
|
|
> to the following questions:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> <B
|
|
CLASS="command"
|
|
>Filesystems</B
|
|
>
|
|
Quota support (CONFIG_QUOTA) [N/y/?] <TT
|
|
CLASS="userinput"
|
|
><B
|
|
>Y</B
|
|
></TT
|
|
>
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
><DIV
|
|
CLASS="tip"
|
|
><BLOCKQUOTE
|
|
CLASS="tip"
|
|
><P
|
|
><B
|
|
><SPAN
|
|
CLASS="inlinemediaobject"
|
|
><IMG
|
|
SRC="./images/Tip.gif"
|
|
ALT="Tip"
|
|
></IMG
|
|
></SPAN
|
|
>: </B
|
|
>
|
|
If you have followed the Linux Kernel chapter in this book and have recompiled your kernel, the option Quota support shown above is already set.
|
|
</P
|
|
></BLOCKQUOTE
|
|
></DIV
|
|
><DIV
|
|
CLASS="section"
|
|
><H2
|
|
CLASS="section"
|
|
><A
|
|
NAME="AEN10214"
|
|
>20.1.1. Modify the <TT
|
|
CLASS="filename"
|
|
>/etc/fstab</TT
|
|
> file</A
|
|
></H2
|
|
><P
|
|
> The <TT
|
|
CLASS="filename"
|
|
>/etc/fstab</TT
|
|
> file contains information about the various file systems installed on your Linux server. Quota must be enabled in the fstab file before you can use it. Since Quota must be set
|
|
for each file system separately, and because in the fstab file, each file system is described on a separate line, quota must be set on each of the separate lines in the fstab for which you want to enable quota support.
|
|
</P
|
|
><P
|
|
> With the program quota, depending on your intentions, needs, etc, you can enable quota only for <SPAN
|
|
CLASS="token"
|
|
>users</SPAN
|
|
>, <SPAN
|
|
CLASS="token"
|
|
>groups</SPAN
|
|
> or both <SPAN
|
|
CLASS="token"
|
|
>users</SPAN
|
|
> and <SPAN
|
|
CLASS="token"
|
|
>groups</SPAN
|
|
>. For all examples below, we'll
|
|
use the <TT
|
|
CLASS="filename"
|
|
>/home</TT
|
|
> directory on the <TT
|
|
CLASS="filename"
|
|
>/dev/sda6</TT
|
|
> partition and shows you the three possibilities.
|
|
</P
|
|
><TABLE
|
|
CLASS="sidebar"
|
|
BORDER="1"
|
|
CELLPADDING="5"
|
|
><TR
|
|
><TD
|
|
><DIV
|
|
CLASS="sidebar"
|
|
><A
|
|
NAME="AEN10226"
|
|
></A
|
|
><P
|
|
><B
|
|
>Possibility 1</B
|
|
></P
|
|
><P
|
|
> To enable user quota support on a specific file system, edit your fstab file <B
|
|
CLASS="command"
|
|
>vi</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/etc/fstab</TT
|
|
> and add the <TT
|
|
CLASS="literal"
|
|
>usrquota</TT
|
|
> option to the fourth field after
|
|
the word <I
|
|
CLASS="wordasword"
|
|
>defaults</I
|
|
> or any other options you may have set for this specific file system.
|
|
<DIV
|
|
CLASS="example"
|
|
><A
|
|
NAME="AEN10233"
|
|
></A
|
|
><P
|
|
><B
|
|
>Example 20-1. <TT
|
|
CLASS="literal"
|
|
>usrquota</TT
|
|
></B
|
|
></P
|
|
><P
|
|
> change:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/sda6 /home ext2 defaults 1 2 <A
|
|
NAME="dflts1"
|
|
><IMG
|
|
SRC="../images/callouts/1.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(1)"></A
|
|
>
|
|
/dev/sda6 /home ext2 nosuid,nodev 1 2 <A
|
|
NAME="dflts2"
|
|
><IMG
|
|
SRC="../images/callouts/2.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(2)"></A
|
|
>
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
<DIV
|
|
CLASS="calloutlist"
|
|
><DL
|
|
COMPACT="COMPACT"
|
|
><DT
|
|
><A
|
|
HREF="chap20sec156.html#dflts1"
|
|
><IMG
|
|
SRC="../images/callouts/1.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(1)"></A
|
|
></DT
|
|
><DD
|
|
>as an example: the word defaults</DD
|
|
><DT
|
|
><A
|
|
HREF="chap20sec156.html#dflts2"
|
|
><IMG
|
|
SRC="../images/callouts/2.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(2)"></A
|
|
></DT
|
|
><DD
|
|
>as an example: any other options you have set</DD
|
|
></DL
|
|
></DIV
|
|
>
|
|
|
|
|
|
To read:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/sda6 /home ext2 defaults,usrquota 1 2
|
|
/dev/sda6 /home ext2 nosuid,nodev,usrquota 1 2
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
></DIV
|
|
>
|
|
</P
|
|
></DIV
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><TABLE
|
|
CLASS="sidebar"
|
|
BORDER="1"
|
|
CELLPADDING="5"
|
|
><TR
|
|
><TD
|
|
><DIV
|
|
CLASS="sidebar"
|
|
><A
|
|
NAME="AEN10246"
|
|
></A
|
|
><P
|
|
><B
|
|
>Possibility 2</B
|
|
></P
|
|
><P
|
|
> To enable group quota support on a file system, edit your fstab file <B
|
|
CLASS="command"
|
|
>vi</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/etc/fstab</TT
|
|
> and add <TT
|
|
CLASS="literal"
|
|
>grpquota</TT
|
|
> to the fourth field after the
|
|
word <TT
|
|
CLASS="literal"
|
|
>defaults</TT
|
|
> or any other options you may have set for this specific file system.
|
|
<DIV
|
|
CLASS="example"
|
|
><A
|
|
NAME="AEN10253"
|
|
></A
|
|
><P
|
|
><B
|
|
>Example 20-2. <TT
|
|
CLASS="literal"
|
|
>grpquota</TT
|
|
></B
|
|
></P
|
|
><P
|
|
> change:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/sda6 /home ext2 defaults 1 2 <A
|
|
NAME="dflts3"
|
|
><IMG
|
|
SRC="../images/callouts/1.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(1)"></A
|
|
>
|
|
/dev/sda6 /home ext2 nosuid,nodev 1 2 <A
|
|
NAME="dflts4"
|
|
><IMG
|
|
SRC="../images/callouts/2.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(2)"></A
|
|
>
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
<DIV
|
|
CLASS="calloutlist"
|
|
><DL
|
|
COMPACT="COMPACT"
|
|
><DT
|
|
><A
|
|
HREF="chap20sec156.html#dflts3"
|
|
><IMG
|
|
SRC="../images/callouts/1.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(1)"></A
|
|
></DT
|
|
><DD
|
|
>as an example: the word defaults</DD
|
|
><DT
|
|
><A
|
|
HREF="chap20sec156.html#dflts4"
|
|
><IMG
|
|
SRC="../images/callouts/2.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(2)"></A
|
|
></DT
|
|
><DD
|
|
>as an example: any other options you have set</DD
|
|
></DL
|
|
></DIV
|
|
>
|
|
|
|
|
|
|
|
To read:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/sda6 /home ext2 defaults,grpquota 1 2
|
|
/dev/sda6 /home ext2 nosuid,nodev,grpquota 1 2
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
></DIV
|
|
>
|
|
</P
|
|
></DIV
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><TABLE
|
|
CLASS="sidebar"
|
|
BORDER="1"
|
|
CELLPADDING="5"
|
|
><TR
|
|
><TD
|
|
><DIV
|
|
CLASS="sidebar"
|
|
><A
|
|
NAME="AEN10266"
|
|
></A
|
|
><P
|
|
><B
|
|
>Possibility 3</B
|
|
></P
|
|
><P
|
|
> To enable both users quota and group quota support on a file system, edit your fstab file <B
|
|
CLASS="command"
|
|
>vi</B
|
|
> <TT
|
|
CLASS="filename"
|
|
>/etc/fstab</TT
|
|
> and add <TT
|
|
CLASS="literal"
|
|
>usrquota,grpquota</TT
|
|
> to the
|
|
fourth field after the word <TT
|
|
CLASS="literal"
|
|
>defaults</TT
|
|
> or any other options you may have set for this specific file system.
|
|
Change:
|
|
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/sda6 /home ext2 defaults 1 2 <A
|
|
NAME="dflts5"
|
|
><IMG
|
|
SRC="../images/callouts/1.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(1)"></A
|
|
>
|
|
/dev/sda6 /home ext2 nosuid,nodev 1 2 <A
|
|
NAME="dflts6"
|
|
><IMG
|
|
SRC="../images/callouts/2.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(2)"></A
|
|
>
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
<DIV
|
|
CLASS="calloutlist"
|
|
><DL
|
|
COMPACT="COMPACT"
|
|
><DT
|
|
><A
|
|
HREF="chap20sec156.html#dflts5"
|
|
><IMG
|
|
SRC="../images/callouts/1.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(1)"></A
|
|
></DT
|
|
><DD
|
|
>as an example: the word <TT
|
|
CLASS="literal"
|
|
>defaults</TT
|
|
></DD
|
|
><DT
|
|
><A
|
|
HREF="chap20sec156.html#dflts6"
|
|
><IMG
|
|
SRC="../images/callouts/2.gif"
|
|
HSPACE="0"
|
|
VSPACE="0"
|
|
BORDER="0"
|
|
ALT="(2)"></A
|
|
></DT
|
|
><DD
|
|
>as an example: any other options you have set</DD
|
|
></DL
|
|
></DIV
|
|
>
|
|
|
|
|
|
To read:
|
|
<TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="programlisting"
|
|
> /dev/sda6 /home ext2 defaults,usrquota,grpquota 1 2
|
|
/dev/sda6 /home ext2 nosuid,nodev,usrquota,grpquota 1 2
|
|
</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
>
|
|
</P
|
|
></DIV
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="quota.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="chap20sec157.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Set Limits using Qouta</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="quota.html"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Create of the <TT
|
|
CLASS="filename"
|
|
>quota.user</TT
|
|
> and <TT
|
|
CLASS="filename"
|
|
>quota.group</TT
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |