On 2/22/2017 10:40 AM, Gordon Messmer wrote:> On 02/22/2017 06:34 AM, Jason Welsh wrote: >> How does the directory *itself* have a size of 2.8 megs? > > > If you write a large number of directory entries in a directory, the > directory will grow in order to provide storage for those directory > entries. You can imagine a directory as a text file containing all of > the file names in the directory, with references to the location of > those files, if that helps you understand why the directory itself > will grow.on many modern file systems, larger directories are stored as some sort of B-Tree or hash tree, so there's quite a lot of indexing data in there along with the actual directory entries. -- john r pierce, recycling bits in santa cruz
On 23/02/17 06:04, John R Pierce wrote:> on many modern file systems, larger directories are stored as some > sort of B-Tree or hash tree, so there's quite a lot of indexing data > in there along with the actual directory entriesSo I gather this depends on the file system. On my ext4 file system, I have a directory that has >2TB and the directory entry itself only shows: $ ls -ld Stuff drwxrwxr-x 146 akk akk 36864 Feb 21 21:18 Stuff/ $ du -bs Stuff 2093651427987 Stuff Not sure what to take away from that!
On Thu, 23 Feb 2017 07:27:05 +1100 Anthony K <akcentos at anroet.com> wrote:> On 23/02/17 06:04, John R Pierce wrote: > > on many modern file systems, larger directories are stored as some > > sort of B-Tree or hash tree, so there's quite a lot of indexing > > data in there along with the actual directory entries > So I gather this depends on the file system. > > On my ext4 file system, I have a directory that has >2TB and the > directory entry itself only shows: > > $ ls -ld Stuff > drwxrwxr-x 146 akk akk 36864 Feb 21 21:18 Stuff/ > > $ du -bs Stuff > 2093651427987 Stuff > > Not sure what to take away from that!certainly sounds like (-) bs d> > > _______________________________________________ > CentOS mailing list > CentOS at centos.org > https://lists.centos.org/mailman/listinfo/centos-- In modern fantasy (literary or governmental), killing people is the usual solution to the so-called war between good and evil. My books are not conceived in terms of such a war, and offer no simple answers to simplistic questions. ----- Ursula Le Guin
On 2/22/2017 12:27 PM, Anthony K wrote:> On my ext4 file system, I have a directory that has >2TB and the > directory entry itself only shows: > > $ ls -ld Stuff > drwxrwxr-x 146 akk akk 36864 Feb 21 21:18 Stuff/ > > $ du -bs Stuff > 2093651427987 Stuffls -ld is showing the size of the actual directory, NOT the size of the files stored within and under it. du -s adds up the size on disk of all the stuff IN the directory. note also that size on disk even for a single file can be larger than the size of the file as files are allocated in blocks. -- john r pierce, recycling bits in santa cruz
On 02/22/2017 12:27 PM, Anthony K wrote:> On 23/02/17 06:04, John R Pierce wrote: >> on many modern file systems, larger directories are stored as some >> sort of B-Tree or hash tree, so there's quite a lot of indexing data >> in there along with the actual directory entries > So I gather this depends on the file system.The structure will vary slightly, but you can reasonably expect that a directory will act like a file, expanding in size to accommodate its directory entries.> On my ext4 file system, I have a directory that has >2TB and the > directory entry itself only shows: > > $ ls -ld Stuff > drwxrwxr-x 146 akk akk 36864 Feb 21 21:18 Stuff/It might help to understand what a directory entry is. See "man 3 readdir". A directory entry is generally what you see if you run "ls -i" in a directory. It is an inode number, and a name associated with that inode number. The size of the directory typically represents the largest that individual directory has had to be in order to contain the list of inodes and names immediately within it. The directory's size is not influenced by the size of files within it, nor by the contents of sub-directories. Does that clarify why there's no relationship between the size of the "Stuff" directory reported by "ls -ld", and the size of its contents reported by "du"?