size of directory reported by ls
I understand the size reported by ls
corresponds with number of inodes inside the directory, not their actual size.
I have noticed peculiar behavior, when displaying directory size with ls
. Here is how to quickly reproduce it:
first create empty directory, the size reported by ls
is 4096 (as expected)
mkdir test
ll -d test/
drwx------ 2 root root 4,096 2015-Dec-29 22:22:36 test/
create 10,000 files inside. Size reported is now 167,936
touch test/{1..9999}
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:24 test/
remove all files. Size should decrease back to 4096
rm test/*
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:59 test/
But the size is still reported as 167,936.
why?
can somebody explain this?
directory ls inode
|
show 1 more comment
I understand the size reported by ls
corresponds with number of inodes inside the directory, not their actual size.
I have noticed peculiar behavior, when displaying directory size with ls
. Here is how to quickly reproduce it:
first create empty directory, the size reported by ls
is 4096 (as expected)
mkdir test
ll -d test/
drwx------ 2 root root 4,096 2015-Dec-29 22:22:36 test/
create 10,000 files inside. Size reported is now 167,936
touch test/{1..9999}
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:24 test/
remove all files. Size should decrease back to 4096
rm test/*
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:59 test/
But the size is still reported as 167,936.
why?
can somebody explain this?
directory ls inode
@Gilles - I am not asking "what does size of directory mean in ls". I already know that, as I state in the preamble of my question. Your link does not help answer my question.
– Martin Vegter
Dec 30 '15 at 0:58
See my answer in the "duplicate" link as I cannot reply to this question anymore.
– schily
Dec 30 '15 at 11:36
@MartinVegter Read the answers. They do answer that part of the question as well.
– Gilles
Dec 30 '15 at 13:29
Not sure why this is marked as a dupe. One answer might be similar, but the question is quite different. Nominating for reopening. In fact, this other question proposes this question a dupe of it, instead of the parent dupe, suggesting that they are truly different.
– Sparhawk
yesterday
The answers to the dup also answer this question.
– roaima
yesterday
|
show 1 more comment
I understand the size reported by ls
corresponds with number of inodes inside the directory, not their actual size.
I have noticed peculiar behavior, when displaying directory size with ls
. Here is how to quickly reproduce it:
first create empty directory, the size reported by ls
is 4096 (as expected)
mkdir test
ll -d test/
drwx------ 2 root root 4,096 2015-Dec-29 22:22:36 test/
create 10,000 files inside. Size reported is now 167,936
touch test/{1..9999}
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:24 test/
remove all files. Size should decrease back to 4096
rm test/*
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:59 test/
But the size is still reported as 167,936.
why?
can somebody explain this?
directory ls inode
I understand the size reported by ls
corresponds with number of inodes inside the directory, not their actual size.
I have noticed peculiar behavior, when displaying directory size with ls
. Here is how to quickly reproduce it:
first create empty directory, the size reported by ls
is 4096 (as expected)
mkdir test
ll -d test/
drwx------ 2 root root 4,096 2015-Dec-29 22:22:36 test/
create 10,000 files inside. Size reported is now 167,936
touch test/{1..9999}
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:24 test/
remove all files. Size should decrease back to 4096
rm test/*
ll -d test/
drwx------ 2 root root 167,936 2015-Dec-29 22:23:59 test/
But the size is still reported as 167,936.
why?
can somebody explain this?
directory ls inode
directory ls inode
asked Dec 29 '15 at 21:30
Martin VegterMartin Vegter
11834122235
11834122235
@Gilles - I am not asking "what does size of directory mean in ls". I already know that, as I state in the preamble of my question. Your link does not help answer my question.
– Martin Vegter
Dec 30 '15 at 0:58
See my answer in the "duplicate" link as I cannot reply to this question anymore.
– schily
Dec 30 '15 at 11:36
@MartinVegter Read the answers. They do answer that part of the question as well.
– Gilles
Dec 30 '15 at 13:29
Not sure why this is marked as a dupe. One answer might be similar, but the question is quite different. Nominating for reopening. In fact, this other question proposes this question a dupe of it, instead of the parent dupe, suggesting that they are truly different.
– Sparhawk
yesterday
The answers to the dup also answer this question.
– roaima
yesterday
|
show 1 more comment
@Gilles - I am not asking "what does size of directory mean in ls". I already know that, as I state in the preamble of my question. Your link does not help answer my question.
– Martin Vegter
Dec 30 '15 at 0:58
See my answer in the "duplicate" link as I cannot reply to this question anymore.
– schily
Dec 30 '15 at 11:36
@MartinVegter Read the answers. They do answer that part of the question as well.
– Gilles
Dec 30 '15 at 13:29
Not sure why this is marked as a dupe. One answer might be similar, but the question is quite different. Nominating for reopening. In fact, this other question proposes this question a dupe of it, instead of the parent dupe, suggesting that they are truly different.
– Sparhawk
yesterday
The answers to the dup also answer this question.
– roaima
yesterday
@Gilles - I am not asking "what does size of directory mean in ls". I already know that, as I state in the preamble of my question. Your link does not help answer my question.
– Martin Vegter
Dec 30 '15 at 0:58
@Gilles - I am not asking "what does size of directory mean in ls". I already know that, as I state in the preamble of my question. Your link does not help answer my question.
– Martin Vegter
Dec 30 '15 at 0:58
See my answer in the "duplicate" link as I cannot reply to this question anymore.
– schily
Dec 30 '15 at 11:36
See my answer in the "duplicate" link as I cannot reply to this question anymore.
– schily
Dec 30 '15 at 11:36
@MartinVegter Read the answers. They do answer that part of the question as well.
– Gilles
Dec 30 '15 at 13:29
@MartinVegter Read the answers. They do answer that part of the question as well.
– Gilles
Dec 30 '15 at 13:29
Not sure why this is marked as a dupe. One answer might be similar, but the question is quite different. Nominating for reopening. In fact, this other question proposes this question a dupe of it, instead of the parent dupe, suggesting that they are truly different.
– Sparhawk
yesterday
Not sure why this is marked as a dupe. One answer might be similar, but the question is quite different. Nominating for reopening. In fact, this other question proposes this question a dupe of it, instead of the parent dupe, suggesting that they are truly different.
– Sparhawk
yesterday
The answers to the dup also answer this question.
– roaima
yesterday
The answers to the dup also answer this question.
– roaima
yesterday
|
show 1 more comment
1 Answer
1
active
oldest
votes
Generally, directory files are not cleaned up - their space usually is small enough (compared to their contents) that it's not effective to do this (particularly when they might grow again). Finding an authoritative answer for this might be hard... Forum comments are easy:
- Shrink/reset directory size?
Linux directories do not shrink automatically also gives some insight.
You might want to edit this question or link back to your newer answer on my question. In this question,Generally, directory files are not cleaned up
since according to the quote on linked thread in the newer answer this behavior is specific to ext3/ext4 filesystems but works in others like xfs.
– Sergiy Kolodyazhnyy
4 mins ago
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f252238%2fsize-of-directory-reported-by-ls%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Generally, directory files are not cleaned up - their space usually is small enough (compared to their contents) that it's not effective to do this (particularly when they might grow again). Finding an authoritative answer for this might be hard... Forum comments are easy:
- Shrink/reset directory size?
Linux directories do not shrink automatically also gives some insight.
You might want to edit this question or link back to your newer answer on my question. In this question,Generally, directory files are not cleaned up
since according to the quote on linked thread in the newer answer this behavior is specific to ext3/ext4 filesystems but works in others like xfs.
– Sergiy Kolodyazhnyy
4 mins ago
add a comment |
Generally, directory files are not cleaned up - their space usually is small enough (compared to their contents) that it's not effective to do this (particularly when they might grow again). Finding an authoritative answer for this might be hard... Forum comments are easy:
- Shrink/reset directory size?
Linux directories do not shrink automatically also gives some insight.
You might want to edit this question or link back to your newer answer on my question. In this question,Generally, directory files are not cleaned up
since according to the quote on linked thread in the newer answer this behavior is specific to ext3/ext4 filesystems but works in others like xfs.
– Sergiy Kolodyazhnyy
4 mins ago
add a comment |
Generally, directory files are not cleaned up - their space usually is small enough (compared to their contents) that it's not effective to do this (particularly when they might grow again). Finding an authoritative answer for this might be hard... Forum comments are easy:
- Shrink/reset directory size?
Linux directories do not shrink automatically also gives some insight.
Generally, directory files are not cleaned up - their space usually is small enough (compared to their contents) that it's not effective to do this (particularly when they might grow again). Finding an authoritative answer for this might be hard... Forum comments are easy:
- Shrink/reset directory size?
Linux directories do not shrink automatically also gives some insight.
edited Apr 13 '17 at 12:13
Community♦
1
1
answered Dec 29 '15 at 21:37
Thomas DickeyThomas Dickey
52.4k595166
52.4k595166
You might want to edit this question or link back to your newer answer on my question. In this question,Generally, directory files are not cleaned up
since according to the quote on linked thread in the newer answer this behavior is specific to ext3/ext4 filesystems but works in others like xfs.
– Sergiy Kolodyazhnyy
4 mins ago
add a comment |
You might want to edit this question or link back to your newer answer on my question. In this question,Generally, directory files are not cleaned up
since according to the quote on linked thread in the newer answer this behavior is specific to ext3/ext4 filesystems but works in others like xfs.
– Sergiy Kolodyazhnyy
4 mins ago
You might want to edit this question or link back to your newer answer on my question. In this question,
Generally, directory files are not cleaned up
since according to the quote on linked thread in the newer answer this behavior is specific to ext3/ext4 filesystems but works in others like xfs.– Sergiy Kolodyazhnyy
4 mins ago
You might want to edit this question or link back to your newer answer on my question. In this question,
Generally, directory files are not cleaned up
since according to the quote on linked thread in the newer answer this behavior is specific to ext3/ext4 filesystems but works in others like xfs.– Sergiy Kolodyazhnyy
4 mins ago
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f252238%2fsize-of-directory-reported-by-ls%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@Gilles - I am not asking "what does size of directory mean in ls". I already know that, as I state in the preamble of my question. Your link does not help answer my question.
– Martin Vegter
Dec 30 '15 at 0:58
See my answer in the "duplicate" link as I cannot reply to this question anymore.
– schily
Dec 30 '15 at 11:36
@MartinVegter Read the answers. They do answer that part of the question as well.
– Gilles
Dec 30 '15 at 13:29
Not sure why this is marked as a dupe. One answer might be similar, but the question is quite different. Nominating for reopening. In fact, this other question proposes this question a dupe of it, instead of the parent dupe, suggesting that they are truly different.
– Sparhawk
yesterday
The answers to the dup also answer this question.
– roaima
yesterday