How to interpret the size value of "ls -ld" output of EFS mount point

0

EFS ls -ld question

vin_q
asked 3 months ago160 views
2 Answers
0

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,

profile picture
EXPERT
Steve_M
answered 3 months ago
  • 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?

  • Can you pls help me know how to interpret the "6144" value for the size column in ls output for a directory in EFS?

    To all intents and purposes, you can consider that as the default value, just like 4096 in XFS.

    Let's say if it says a bigger number like "1089623875", what would that mean?

    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.

0

To know more about the 6144 value, have a read here: AWS CLI Ref.

profile pictureAWS
answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions