quota problem - repquota does't match du -sh

Discussion in 'General' started by SupuS, Jun 20, 2008.

  1. SupuS

    SupuS HowtoForge Supporter

    quota problem - repquota does't match du -sh [SOLVED]

    Hi All

    With one web I have strange problem. It is almost over limit but du -sh returns different value:

    User quota (web has this user only):

    Code:
    repquota -avug |grep zs25adminuser
    zs25adminuser  --  996532       0       0           8856     0     0
    zs25adminuser  --       0       0       0              0     0     0
    
    Group quota:

    Code:
    repquota -avug |grep web25
    web25     --  996532 1126400 1127424           8856     0     0
    web25     --       0 1126400 1127424              0     0     0
    
    su (as root):

    Code:
    du -sh /var/www/web25
    693M    /var/www/web25
    I tried search all files belongs to this user and group by:

    Code:
    find / -group web25
    find / -user zs25adminuser
    but all files are in /var/www/web25.

    I cannot find any reason for this behavior.

    Thanks for any suggestion
    SupuS
     
    Last edited: Nov 16, 2008
  2. till

    till Super Moderator

    Are you really sure that all files are in /var/www/web25 ? Please double check that no files or folders are in /tmp and /var/spool/mail
     
  3. SupuS

    SupuS HowtoForge Supporter

    Hi till

    Yes I'am .. I checked tmp before post .. here is du of tmp and mail:

    tmp:
    Code:
    du -sh /tmp/
    58M     /tmp
    mail (it is link /var/spool/mail -> ../mail)
    Code:
    du -sh /var/mail
    740K    /var/mail
    Whole tmp has 58M and no files owned by web25 or zs25* :(
     
  4. SupuS

    SupuS HowtoForge Supporter

    Same problem again

    I found exactly same problem on another ispconfig server:

    Code:
    # repquota -avugs |grep web34
    web34     --    949M   1000M   1001M          31676     0     0
    web34     --       0   1000M   1001M              0     0     0
    
    Code:
    # du -sh /var/www/web34
    835M    /var/www/web34
    
    I found some empty files in /tmp and /var/mail but its deleting didn't help.

    Any idea please?

    SupuS
     
  5. SupuS

    SupuS HowtoForge Supporter

    Again with same problem :) Now I found very interesting behaviour. Listing of my quota files says that quota.user has 111 GB.

    Code:
    # ls -lth /quota.*
    -rw------- 1 root root 111G Nov 13 14:54 /quota.user
    -rw------- 1 root root 2.5M Nov 13 14:54 /quota.group
    -rw------- 1 root root 2.5M Jul 23 13:19 /quota.group.new
    -rw------- 1 root root 2.5M Jul 23 13:19 /quota.user.new
    
    But whole used disc space is 31 GB only:

    Code:
    # df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda4             127G   31G   90G  26% /
    
    I cannot delete guota.user file. I get this error:

    Code:
    # rm -rf /quota.group
    rm: cannot remove `/quota.group': Operation not permitted
    
    quotacheck -avugm or quotacheck -avugmc doesn't help.

    And after all .. running of repquota -avugs |grep webXX is really slow.

    Any idea please?
     
  6. SupuS

    SupuS HowtoForge Supporter

    So here is what I did to fix incredible big quota.user file:

    Stop the quotas:

    Code:
    /etc/init.d/quota stop
    or

    Code:
    quotaoff -a
    Delete quota files.

    Create new quota files, build new one and turning quota on:

    Code:
    touch /quota.user /quota.group
    chmod 600 /quota.*
    quotacheck -avugm
    quotaon -avug
    
    Now my quota files has proper size:

    Code:
    # ls -lth /quota.*
    -rw------- 1 root root 2.5M Nov 14 21:35 /quota.group
    -rw------- 1 root root 2.5M Nov 14 21:35 /quota.user
    
    Unfortunately quotas of all users seems to be gone so I have to rebuild them by manual changing quota in ispconfig. May be is better way to rebuild it .. I don't know it :)

    For now everything seems quite well. Even differences between quotacheck and du -sh changed:

    Code:
    # du -sh /var/www/web16
    859M    /var/www/web16
    
    # repquota -avugs |grep web16
    web16     --    726M    800M    801M           5986     0     0
    web16     --       0    800M    801M              0     0     0
    
    .. not as I expected but better than before .. :)

    may be somebody know what happend ..

    SupuS
     
  7. SupuS

    SupuS HowtoForge Supporter

    I finally solved problem with "unmatch quotas and du -su".

    For reset quotas I used command:

    Code:
    quotacheck -avugmc
    
    But it reseted all quotas for all webs. Now I created little script for update all quotas. Falko or Till check it please for bugs. It works for me.

    Here is the script (part of writeconf.php)

    PHP:
    <?php

    set_time_limit
    (0);
    // ĂberprĂźfung, ob parallel noch ein anderer ProzeĂ läuft
    if(is_file("/root/ispconfig/.ispconfig_lock")){
      
    clearstatcache();
      for(
    $i=0;$i<120;$i++){ // max. 120 Sek. warten, dann weitermachen
        
    if(is_file("/root/ispconfig/.ispconfig_lock")){
          
    sleep(1);
          
    clearstatcache();
        }
      }
    }

    @
    touch("/root/ispconfig/.ispconfig_lock");

    include(
    "/root/ispconfig/scripts/lib/config.inc.php");
    include(
    "/root/ispconfig/scripts/lib/config.lib.php");
    include(
    "/root/ispconfig/scripts/lib/server.inc.php");

    $isp_web = new isp_web;

    echo 
    "start\n";

    /////////////// Web- u. Userdaten aus DB holen ////////////////
    $w_ds $mod->db->queryAllRecords("SELECT * FROM isp_isp_web");
    if(!empty(
    $w_ds)){
      foreach(
    $w_ds as $w_d){
        
    $mod->system->data["isp_isp_web"][$w_d["doc_id"]] = $w_d;
      }
    }

    $u_ds $mod->db->queryAllRecords("SELECT * FROM isp_isp_user");
    if(!empty(
    $u_ds)){
      foreach(
    $u_ds as $u_d){
        
    $mod->system->data["isp_isp_user"][$u_d["doc_id"]] = $u_d;
      }
    }

    $mod->system->data["isp_server_ip"] = $mod->db->queryAllRecords("SELECT * FROM isp_server_ip WHERE server_id = '".$mod->system->server_id."' AND server_ip != ''");
    ////////////////////////////////////////////////////////////////

    /* here I changed isp_isp_web.status = 'u' to isp_isp_web.status = '' so all webs will be updated */

    $web_update $mod->db->queryAllRecords("SELECT * from isp_isp_web, isp_nodes where isp_isp_web.doc_id = isp_nodes.doc_id and isp_nodes.doctype_id = '".$isp_web->web_doctype_id."' and isp_isp_web.status = '' and isp_isp_web.server_id = '".$mod->system->server_id."' and isp_nodes.status = '1'");
    $web_update_ssl_action 0;
    if(!empty(
    $web_update)){
      foreach(
    $web_update as $web) {
        
    $doc_id $web["doc_id"];
        
    $doctype_id $web["doctype_id"];
        
    $isp_web->web_update($doc_id,$doctype_id,$mod->system->server_id);
        echo 
    "UPDATE: ".$doc_id."\n";
        if(
    $web["ssl_action"] != ''$web_update_ssl_action += 1;
      }
    }

    // Webs und User endgĂźltig lĂśschen
    $isp_web->web_user_clean();

    echo 
    "ende\n";

    // lock-Datei lĂśschen
    @unlink("/root/ispconfig/.ispconfig_lock");

    ?>
    If somebody wants to use it please backup first and be carefully. It works for me but I didn't tested it very well yet.

    For run this script simply save it and run by:

    Code:
    /root/ispconfig/php/php /path/to/new/script.php
    
    Hope it helps somebody :)
     
  8. till

    till Super Moderator

    An easier solution might have been, to execute this sql statement in the ispconfig DB:

    update isp_isp_user set status = 'u' where status = '';

    then change a setting in one of the users in the interface and click on save, so all users get updated.
     
  9. SupuS

    SupuS HowtoForge Supporter

    I though about your solution before I created script too .. but it doesn't work for me .. probably my fault .. thanks :)
     

Share This Page