How to speed up directory listing on high-inode partitions?
I have almost 7,000 files in a single directory which makes loading that particular directory a tedious and time-consuming one. Is there any way to list and perform operations on files in that directory faster rather than distributing the files into multiple sub-folders(which makes it even more difficult)?
I'm using ext4. But also received the same from efs filesystems.
inode
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
I have almost 7,000 files in a single directory which makes loading that particular directory a tedious and time-consuming one. Is there any way to list and perform operations on files in that directory faster rather than distributing the files into multiple sub-folders(which makes it even more difficult)?
I'm using ext4. But also received the same from efs filesystems.
inode
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
It's better to you make filter, you have some way, find, globbing and so on , But at first you explain exactly your task.
– PersianGulf
Mar 7 '15 at 20:22
1
Could you clarify what you mean by "loading"? Simplyls, or displaying the contents in a file manager (which one?), or something else? On my system listing 7,000 files withlson anext4filesystem is pretty much instantaneous, as is displaying the directory in Thunar.
– Stephen Kitt
Mar 7 '15 at 20:56
@SnazzySanoj please answer comments, by amending your question.
– ctrl-alt-delor
Mar 7 '15 at 22:30
1
A lot of systems aliaslsto something that makes itlstatevery file. --color and -F do this. If you don't needlsto decorate the output, remove these aliases. Listing a 7000 file directory shouldn't be slow.
– Mark Plotnick
Mar 7 '15 at 23:48
add a comment |
I have almost 7,000 files in a single directory which makes loading that particular directory a tedious and time-consuming one. Is there any way to list and perform operations on files in that directory faster rather than distributing the files into multiple sub-folders(which makes it even more difficult)?
I'm using ext4. But also received the same from efs filesystems.
inode
I have almost 7,000 files in a single directory which makes loading that particular directory a tedious and time-consuming one. Is there any way to list and perform operations on files in that directory faster rather than distributing the files into multiple sub-folders(which makes it even more difficult)?
I'm using ext4. But also received the same from efs filesystems.
inode
inode
edited Mar 7 '15 at 22:30
ctrl-alt-delor
12k42360
12k42360
asked Mar 7 '15 at 20:18
Snazzy SanojSnazzy Sanoj
1195
1195
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 1 hour ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
1
It's better to you make filter, you have some way, find, globbing and so on , But at first you explain exactly your task.
– PersianGulf
Mar 7 '15 at 20:22
1
Could you clarify what you mean by "loading"? Simplyls, or displaying the contents in a file manager (which one?), or something else? On my system listing 7,000 files withlson anext4filesystem is pretty much instantaneous, as is displaying the directory in Thunar.
– Stephen Kitt
Mar 7 '15 at 20:56
@SnazzySanoj please answer comments, by amending your question.
– ctrl-alt-delor
Mar 7 '15 at 22:30
1
A lot of systems aliaslsto something that makes itlstatevery file. --color and -F do this. If you don't needlsto decorate the output, remove these aliases. Listing a 7000 file directory shouldn't be slow.
– Mark Plotnick
Mar 7 '15 at 23:48
add a comment |
1
It's better to you make filter, you have some way, find, globbing and so on , But at first you explain exactly your task.
– PersianGulf
Mar 7 '15 at 20:22
1
Could you clarify what you mean by "loading"? Simplyls, or displaying the contents in a file manager (which one?), or something else? On my system listing 7,000 files withlson anext4filesystem is pretty much instantaneous, as is displaying the directory in Thunar.
– Stephen Kitt
Mar 7 '15 at 20:56
@SnazzySanoj please answer comments, by amending your question.
– ctrl-alt-delor
Mar 7 '15 at 22:30
1
A lot of systems aliaslsto something that makes itlstatevery file. --color and -F do this. If you don't needlsto decorate the output, remove these aliases. Listing a 7000 file directory shouldn't be slow.
– Mark Plotnick
Mar 7 '15 at 23:48
1
1
It's better to you make filter, you have some way, find, globbing and so on , But at first you explain exactly your task.
– PersianGulf
Mar 7 '15 at 20:22
It's better to you make filter, you have some way, find, globbing and so on , But at first you explain exactly your task.
– PersianGulf
Mar 7 '15 at 20:22
1
1
Could you clarify what you mean by "loading"? Simply
ls, or displaying the contents in a file manager (which one?), or something else? On my system listing 7,000 files with ls on an ext4 filesystem is pretty much instantaneous, as is displaying the directory in Thunar.– Stephen Kitt
Mar 7 '15 at 20:56
Could you clarify what you mean by "loading"? Simply
ls, or displaying the contents in a file manager (which one?), or something else? On my system listing 7,000 files with ls on an ext4 filesystem is pretty much instantaneous, as is displaying the directory in Thunar.– Stephen Kitt
Mar 7 '15 at 20:56
@SnazzySanoj please answer comments, by amending your question.
– ctrl-alt-delor
Mar 7 '15 at 22:30
@SnazzySanoj please answer comments, by amending your question.
– ctrl-alt-delor
Mar 7 '15 at 22:30
1
1
A lot of systems alias
ls to something that makes it lstat every file. --color and -F do this. If you don't need ls to decorate the output, remove these aliases. Listing a 7000 file directory shouldn't be slow.– Mark Plotnick
Mar 7 '15 at 23:48
A lot of systems alias
ls to something that makes it lstat every file. --color and -F do this. If you don't need ls to decorate the output, remove these aliases. Listing a 7000 file directory shouldn't be slow.– Mark Plotnick
Mar 7 '15 at 23:48
add a comment |
1 Answer
1
active
oldest
votes
A large directory can be problematic for a number of reasons other than simply listing of files. For one thing, the time it takes to open a file in that directory will increase because the directory has to be read until the file is found. On many filesystems including ext*, directory entries not organized nor optimized for retrieval efficiency.
Answering your specific question, I think that you'll find using ls takes awhile due to the sorting involved. A solution is to run ls unsorted (if there is such an option in your distribution of ls). Specifically, I might ls unsorted to a file and the sort it. I then have the file to refer to without having to do another ls for a bit.
Another similar method is to use the find command and listout the directory contents into a file (which will be unsorted) and then go from there.
Thus my suggestion would be based on accessibility, effeciency and easily finding files, to use multiple sub-directories.
"A directory is not organized to speed up retrievals of specific entries": that completely depends on the filesystem in use, and many commonly-used filesystem types do optimize directory indices for just this ability.
– Celada
Mar 8 '15 at 5:09
OK, I qualified my response. Could you provide the commonly used filesystems that do what you state for the record?
– mdpc
Mar 8 '15 at 5:42
1
XFS automatically, ext4 (probably ext3 as well?) with the "dir_index" option enabled (which is part of the default options) (see mkfs.ext4 manpage), and I didn't bother to look up references but probably most of the other modern filesystem types as well: Btrfs, ZFS, JFS, all support efficient indexing for large directories.
– Celada
Mar 8 '15 at 7:19
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%2f188793%2fhow-to-speed-up-directory-listing-on-high-inode-partitions%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
A large directory can be problematic for a number of reasons other than simply listing of files. For one thing, the time it takes to open a file in that directory will increase because the directory has to be read until the file is found. On many filesystems including ext*, directory entries not organized nor optimized for retrieval efficiency.
Answering your specific question, I think that you'll find using ls takes awhile due to the sorting involved. A solution is to run ls unsorted (if there is such an option in your distribution of ls). Specifically, I might ls unsorted to a file and the sort it. I then have the file to refer to without having to do another ls for a bit.
Another similar method is to use the find command and listout the directory contents into a file (which will be unsorted) and then go from there.
Thus my suggestion would be based on accessibility, effeciency and easily finding files, to use multiple sub-directories.
"A directory is not organized to speed up retrievals of specific entries": that completely depends on the filesystem in use, and many commonly-used filesystem types do optimize directory indices for just this ability.
– Celada
Mar 8 '15 at 5:09
OK, I qualified my response. Could you provide the commonly used filesystems that do what you state for the record?
– mdpc
Mar 8 '15 at 5:42
1
XFS automatically, ext4 (probably ext3 as well?) with the "dir_index" option enabled (which is part of the default options) (see mkfs.ext4 manpage), and I didn't bother to look up references but probably most of the other modern filesystem types as well: Btrfs, ZFS, JFS, all support efficient indexing for large directories.
– Celada
Mar 8 '15 at 7:19
add a comment |
A large directory can be problematic for a number of reasons other than simply listing of files. For one thing, the time it takes to open a file in that directory will increase because the directory has to be read until the file is found. On many filesystems including ext*, directory entries not organized nor optimized for retrieval efficiency.
Answering your specific question, I think that you'll find using ls takes awhile due to the sorting involved. A solution is to run ls unsorted (if there is such an option in your distribution of ls). Specifically, I might ls unsorted to a file and the sort it. I then have the file to refer to without having to do another ls for a bit.
Another similar method is to use the find command and listout the directory contents into a file (which will be unsorted) and then go from there.
Thus my suggestion would be based on accessibility, effeciency and easily finding files, to use multiple sub-directories.
"A directory is not organized to speed up retrievals of specific entries": that completely depends on the filesystem in use, and many commonly-used filesystem types do optimize directory indices for just this ability.
– Celada
Mar 8 '15 at 5:09
OK, I qualified my response. Could you provide the commonly used filesystems that do what you state for the record?
– mdpc
Mar 8 '15 at 5:42
1
XFS automatically, ext4 (probably ext3 as well?) with the "dir_index" option enabled (which is part of the default options) (see mkfs.ext4 manpage), and I didn't bother to look up references but probably most of the other modern filesystem types as well: Btrfs, ZFS, JFS, all support efficient indexing for large directories.
– Celada
Mar 8 '15 at 7:19
add a comment |
A large directory can be problematic for a number of reasons other than simply listing of files. For one thing, the time it takes to open a file in that directory will increase because the directory has to be read until the file is found. On many filesystems including ext*, directory entries not organized nor optimized for retrieval efficiency.
Answering your specific question, I think that you'll find using ls takes awhile due to the sorting involved. A solution is to run ls unsorted (if there is such an option in your distribution of ls). Specifically, I might ls unsorted to a file and the sort it. I then have the file to refer to without having to do another ls for a bit.
Another similar method is to use the find command and listout the directory contents into a file (which will be unsorted) and then go from there.
Thus my suggestion would be based on accessibility, effeciency and easily finding files, to use multiple sub-directories.
A large directory can be problematic for a number of reasons other than simply listing of files. For one thing, the time it takes to open a file in that directory will increase because the directory has to be read until the file is found. On many filesystems including ext*, directory entries not organized nor optimized for retrieval efficiency.
Answering your specific question, I think that you'll find using ls takes awhile due to the sorting involved. A solution is to run ls unsorted (if there is such an option in your distribution of ls). Specifically, I might ls unsorted to a file and the sort it. I then have the file to refer to without having to do another ls for a bit.
Another similar method is to use the find command and listout the directory contents into a file (which will be unsorted) and then go from there.
Thus my suggestion would be based on accessibility, effeciency and easily finding files, to use multiple sub-directories.
edited Mar 8 '15 at 5:41
answered Mar 8 '15 at 3:12
mdpcmdpc
5,05621838
5,05621838
"A directory is not organized to speed up retrievals of specific entries": that completely depends on the filesystem in use, and many commonly-used filesystem types do optimize directory indices for just this ability.
– Celada
Mar 8 '15 at 5:09
OK, I qualified my response. Could you provide the commonly used filesystems that do what you state for the record?
– mdpc
Mar 8 '15 at 5:42
1
XFS automatically, ext4 (probably ext3 as well?) with the "dir_index" option enabled (which is part of the default options) (see mkfs.ext4 manpage), and I didn't bother to look up references but probably most of the other modern filesystem types as well: Btrfs, ZFS, JFS, all support efficient indexing for large directories.
– Celada
Mar 8 '15 at 7:19
add a comment |
"A directory is not organized to speed up retrievals of specific entries": that completely depends on the filesystem in use, and many commonly-used filesystem types do optimize directory indices for just this ability.
– Celada
Mar 8 '15 at 5:09
OK, I qualified my response. Could you provide the commonly used filesystems that do what you state for the record?
– mdpc
Mar 8 '15 at 5:42
1
XFS automatically, ext4 (probably ext3 as well?) with the "dir_index" option enabled (which is part of the default options) (see mkfs.ext4 manpage), and I didn't bother to look up references but probably most of the other modern filesystem types as well: Btrfs, ZFS, JFS, all support efficient indexing for large directories.
– Celada
Mar 8 '15 at 7:19
"A directory is not organized to speed up retrievals of specific entries": that completely depends on the filesystem in use, and many commonly-used filesystem types do optimize directory indices for just this ability.
– Celada
Mar 8 '15 at 5:09
"A directory is not organized to speed up retrievals of specific entries": that completely depends on the filesystem in use, and many commonly-used filesystem types do optimize directory indices for just this ability.
– Celada
Mar 8 '15 at 5:09
OK, I qualified my response. Could you provide the commonly used filesystems that do what you state for the record?
– mdpc
Mar 8 '15 at 5:42
OK, I qualified my response. Could you provide the commonly used filesystems that do what you state for the record?
– mdpc
Mar 8 '15 at 5:42
1
1
XFS automatically, ext4 (probably ext3 as well?) with the "dir_index" option enabled (which is part of the default options) (see mkfs.ext4 manpage), and I didn't bother to look up references but probably most of the other modern filesystem types as well: Btrfs, ZFS, JFS, all support efficient indexing for large directories.
– Celada
Mar 8 '15 at 7:19
XFS automatically, ext4 (probably ext3 as well?) with the "dir_index" option enabled (which is part of the default options) (see mkfs.ext4 manpage), and I didn't bother to look up references but probably most of the other modern filesystem types as well: Btrfs, ZFS, JFS, all support efficient indexing for large directories.
– Celada
Mar 8 '15 at 7:19
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%2f188793%2fhow-to-speed-up-directory-listing-on-high-inode-partitions%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
1
It's better to you make filter, you have some way, find, globbing and so on , But at first you explain exactly your task.
– PersianGulf
Mar 7 '15 at 20:22
1
Could you clarify what you mean by "loading"? Simply
ls, or displaying the contents in a file manager (which one?), or something else? On my system listing 7,000 files withlson anext4filesystem is pretty much instantaneous, as is displaying the directory in Thunar.– Stephen Kitt
Mar 7 '15 at 20:56
@SnazzySanoj please answer comments, by amending your question.
– ctrl-alt-delor
Mar 7 '15 at 22:30
1
A lot of systems alias
lsto something that makes itlstatevery file. --color and -F do this. If you don't needlsto decorate the output, remove these aliases. Listing a 7000 file directory shouldn't be slow.– Mark Plotnick
Mar 7 '15 at 23:48