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

Re: e2fsck



Bob Hilliard wrote:
>      I have never found any files in lost+found, but ls-l and du
> always show it as 12kb, even in a brand new file system.  What is
> occupying those 12k?

Ok, first some background:

The size of a directory is dependant on how much space has been allocated
for filenames in the directory. If you make a directory, put many many files
in it, and then delete all the files, the directory will still be the same
size it had to be to hold all those filenames. (Remember a directory is
essentially just a file that lists the files that are in it.)

For example, make a directory with 1000 files in it, and then delete them
all:

joey@kite:/tmp>mkdir dir
joey@kite:/tmp>ls -ld dir
drwxrwxr-x   2 joey     joey         1024 Jul  1 18:15 dir/
joey@kite:/tmp>perl -e 'for (1..1000) { open (F,">dir/$_"); close F }' 
joey@kite:/tmp>ls dir |head
1     168   237   306   376   445   514   584   653   722   792   861   930
10    169   238   307   377   446   515   585   654   723   793   862   931
100   17    239   308   378   447   516   586   655   724   794   863   932
1000  170   24    309   379   448   517   587   656   725   795   864   933
101   171   240   31    38    449   518   588   657   726   796   865   934
102   172   241   310   380   45    519   589   658   727   797   866   935
103   173   242   311   381   450   52    59    659   728   798   867   936
104   174   243   312   382   451   520   590   66    729   799   868   937
105   175   244   313   383   452   521   591   660   73    8     869   938
106   176   245   314   384   453   522   592   661   730   80    87    939
joey@kite:/tmp>ls -ld dir
drwxrwxr-x   2 joey     joey        12288 Jul  1 18:15 dir/
joey@kite:/tmp>rm dir/*
joey@kite:/tmp>ls dir |head
joey@kite:/tmp>ls -ld dir  
drwxrwxr-x   2 joey     joey        12288 Jul  1 18:15 dir/

It's still 12k.

Now there's a program called mklost+found, and on it's man page I see the
answer to your question:

DESCRIPTION
       mklost+found is used to create a lost+found  directory  in
       the  current  working directory on a Linux second extended
       file system.
       mklost+found pre-allocates disk blocks to the directory to
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
       make it usable by e2fsck
       ^^^^^^^^^^^^^^^^^^^^^^^^

I think this is so that if e2fsck needs to put a lot of files in lost+found, 
the directory will already be large enough to hold their filenames, so e2fsck
won't need to mess with resizing the directory on the fly when it's in the
middle of fixing a damaged drive.

-- 
see shy jo


--  
Unsubscribe?  mail -s unsubscribe debian-user-request@lists.debian.org < /dev/null


Reply to: