- Le plus récent
- Le plus de votes
- La plupart des commentaires
The value of 4096
in ls -ld
doesn't refer to the amount of diskspace consumed by the contents of the directory. For this you are correct that the command to use is du
.
Without wanting to get too technical, a directory is best thought of as a special type of file that doesn't contain any data itself, but contains a list of all the files that live inside the directory.
The default block size on xfs (which is the type of the filesystem on your local disk) is 4096 bytes, so when you mkdir
the filesystem allocates one block (4096 bytes) to the entry for the newly-created directory. And this is what you see in ls -ld
- it doesn't mean the contents of the directory add up to 4096 bytes, but just that the entry for the directory which keeps track of the files that are within it is 4096 bytes.
If you put a lot of files in a directory the size of that entry will dynamically increase to accommodate the extra entries that it needs to keep track of, even though there is no additional space being used by the new data (in this examples here 1000 files each of size 0 bytes):
$ mkdir dir_test
$ ls -ld dir_test
drwxr-xr-x. 2 steve_m users 4096 Feb 9 11:01 dir_test
$ for i in `seq 1 1000`; do > dir_test/${i}; done
$ ls -ld dir_test
drwxr-xr-x. 2 steve_m users 20480 Feb 9 11:02 dir_test
$
It's gone from 4096 to 20480.
Note that if you delete all of these it will stay at the new size, and won't shrink back to what it was before.
$ \rm dir_test/*
$ ls -ld dir_test
drwxr-xr-x. 2 steve_m users 20480 Feb 9 11:02 dir_test
$
Your EFS filesystem is mounted as an NFSv4 device, which is a completely different filesystem type to XFS (and goes over the nwtwork rather than is directly attached) so you can't expect the default values to be the same,
Contenus pertinents
- demandé il y a un an
- demandé il y a 8 mois
- demandé il y a un an
- demandé il y a 2 mois
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
- AWS OFFICIELA mis à jour il y a 2 ans
HI, Thank you for the answer. Can you pls help me know how to interpret the "6144" value for the size column in ls output for a directory in EFS? Let's say if it says a bigger number like "1089623875", what would that mean?
To all intents and purposes, you can consider that as the default value, just like 4096 in XFS.
That would mean there are many objects (thousands, or millions) in that folder, so the filesystem entry for the directory has increased so that it can keep track of the large list of objects inside that folder.