[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: taille des répertoire bizarre



Stéphane BERDIN wrote:

> salut, 
> 
> j'ai un souci de taille là !
> voici ma répartition des rép : 
> 
> [root@ariasrv01 /]# df  -h
> Filesystem            Size  Used Avail Use% Mounted on
> /dev/sda5             1.4G  1.4G     0 100% /
> /dev/sda1             7.6M  2.3M  4.8M  33% /boot
> /dev/sda7             6.8G  545M  6.0G   8% /usr
> /dev/sdb1             8.4G  2.4G  5.6G  30% /home
> 
> 
> mon problème, /dev/sda5 alors que j'ai surement pas 1.4 G de pris !
> d'ou ça peux venir ?
> 
> [root@ariasrv01 /]# du * -s
> 
> si on additionne, on arrive jamais à 1.4 G !!
> 
> bizarre non ?
> si qq'un peux m'expliquer ou as une idée, elle est la bienvenue, je sèche un
> peu !

Tu peux avoir des fichiers supprimés du filesystem (ls/du/find ne les
trouveras pas) mais qui sont toujours présent _physiquement_.

Par exemple, un process a ouvert un fichier qui est supprimé par la
suite.  Le filesystem conserve les blocs utilisé par le fichier tand que
le file descriptor est utilisé.

Voici un petit programme qui illustre ce cas:

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>

int main()
{
    char buf[8*1024];
    int fd;

    fd = open ("fantome", O_WRONLY | O_CREAT | O_TRUNC, 0666);
    if (fd == 1) {
	perror ("open");
	exit (1);
    }

    while (write (fd, buf, sizeof (buf)) != -1)
	;

    unlink ("fantome");
    for (;;) { pause(); }
}

Je l'execute dans une petite partition (/boot):

    $ du -h /boot
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1              61M  4.1M   53M   7% /boot
    $ ~/tmp/hog &
    [1] 1865
    $ df -h /boot
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1              61M   58M     0 100% /boot
    $ du -s /boot
    4232    /boot
    $ kill %1
    $ df -h /boot
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/sda1              61M  4.1M   53M   7% /boot

CQFD
-- 
Edouard G. Parmelan
http://egp.free.fr



Reply to: