Configurazione di Quota

Non esiste un singolo file di configurazione di quota, occorre modificare dei file esistenti per attivare il servizio al boot e schedulare il check dei filesytem.
Di seguito sono riportati i file e le eventuali modifiche per attivare quota su una distribuzione basata su RedHat.

Attivazione al boot
L'attivazione puņ avvenire tramite uno script eseguito dopo che i filesystem vengono montati. L'installazione tramite rpm aggiunge una serie di righe di codice nello script /etc/rc.d/rc.sysinit come riportato di seguito:
[root@trinity root]# cat /etc/rc.d/rc.sysinit
[...]
Check del filesystem di root e possibile update dopo un fsck
# Possibly update quotas if fsck was run on /.
grep -E '[[:space:]]+/[[:space:]]+' /etc/fstab | \
    awk '{ print $4 }' | \
    grep -q quota
_ROOT_HAS_QUOTA=$?
if [ X"$_RUN_QUOTACHECK" = X1 -a \
    "$_ROOT_HAS_QUOTA" -a \
    -x /sbin/quotacheck ]; then
        if [ -x /sbin/convertquota ]; then
            if [ -f /quota.user ]; then
                action $"Converting old user quota files: " \
                    /sbin/convertquota -u / && rm -f /quota.user
            fi
            if [ -f /quota.group ]; then
                action $"Converting old group quota files: " \
                    /sbin/convertquota -g / && rm -f /quota.group
            fi
        fi
        action $"Checking root filesystem quotas: " /sbin/quotacheck -nug /
fi
[...]
Check per  altri filesystem
# check remaining quotas other than root
if [ X"$_RUN_QUOTACHECK" = X1 -a -x /sbin/quotacheck ]; then
        if [ -x /sbin/convertquota ]; then
            # try to convert old quotas
            for mountpt in `awk '$4 ~ /quota/{print $2}' /etc/mtab` ; do
                if [ -f "$mountpt/quota.user" ]; then
                    action $"Converting old user quota files: " \
                    /sbin/convertquota -u $mountpt && \
                        rm -f $mountpt/quota.user
                fi
                if [ -f "$mountpt/quota.group" ]; then
                    action $"Converting old group quota files: " \
                    /sbin/convertquota -g $mountpt && \
                        rm -f $mountpt/quota.group
                fi
            done
        fi
        action $"Checking local filesystem quotas: " /sbin/quotacheck -aRnug
fi
                                                                                                                      
if [ -x /sbin/quotaon ]; then
    action $"Enabling local filesystem quotas: " /sbin/quotaon -aug
fi


Configurazione di /etc/fstab
Per abilitare il check per utente o per gruppo nei filesytem montati tramite /etc/fstab occorre aggiungere delle opzioni di mounting:
usrquota per abilitare i check per utente
grpquota per abilitare il check per gruppo.

Esempio di un /etc/fstab configurato per usare quota:
[root@trinity root]# cat /etc/fstab
LABEL=/                 /                       ext3    defaults,usrquota,grpquota        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
/dev/hdc1               /archive                ext3    defaults        1 2
none                    /dev/pts                devpts  gid=5,mode=620  0 0
none                    /proc                   proc    defaults        0 0
none                    /dev/shm                tmpfs   defaults        0 0
/dev/hda2               swap                    swap    defaults        0 0
/dev/cdrom              /mnt/cdrom              iso9660 noauto,owner,kudzu,ro 0 0


Schedulazione dei controlli
Il controllo del file system per verificare se qualche utente ha superato i suoi limiti non avviene in tempo reale ma tramite check periodici che devono essere schedulati tramite crontab, una volta al giorno e possibilmente di notte per evitare problematiche di performance.
Esempio:
[root@trinity root]# cat /etc/crontab
[...]
00 6 * * * root /root/checkquota.sh
[...][root@trinity root]# cat /root/checkquota.sh
#!/bin/sh
# Scripts to check filesystem with quota every week
/sbin/quotacheck -avug

Privacy Policy