SUSE Support

Here When You Need Us

Long delay when doing "ls" on a large NFS mounted directory

This document (7005969) is provided subject to the disclaimer at the end of this document.

Environment

SUSE Linux Enterprise Server 15
SUSE Linux Enterprise Server 12
SUSE Linux Enterprise Server 11
SUSE Linux Enterprise Server 10
SUSE Linux Enterprise Server 9

Situation

When a SUSE NFS client asks for a directory list (ls) of a NFS mount with a large number of files, there may be a long delay before the listing begins to be displayed.

Resolution

The delay is not being caused directly by NFS, it is actually being caused by certain ls options which are "automatically" in place.  In a typical SUSE system, giving the "ls" command actually invokes an alias rather than directly executing the /bin/ls command.  Giving the "alias" command will show (among other things):
 
alias ls='/bin/ls $LS_OPTIONS'
 
The variable $LS_OPTIONS can be revealed with the command:
env | grep LS_OPTIONS
 
Which will show:
LS_OPTIONS -A -N --color=tty -T 0
 
The '--color=tty' part of this causes a large additional need for attributes to be checked, in order to assign / display different colors to different types of files and directories.  This adds overhead which slows down local disk listings only a little, but can slow down NFS listings quite significantly.
 
There are a variety of options to deal with this:
 
1.  If the command /bin/ls is given instead of ls, it will bypass the alias and it's options, and will not experience the delay.
 
2.  LS_OPTIONS can be altered to not seek the color-related attributes.  To alter the 'LS_OPTIONS' for all users, directly and permanently, edit the scripts which control this setting in the shell environments.  The files which do this are:
/etc/bash.bashrc
/etc/csh.cshrc
/etc/ksh.kshrc (although this file is usually just a symbolic link to 'bash.bashrc')
These scripts conditionally turn on the '--color=tty' part of the 'LS_OPTIONS'. For example, in 'bash.bashrc', the following lines can be found:
if test "${LS_COLORS+empty}" = "${LS_COLORS:+empty}" ; then
     LS_OPTIONS=--color=tty
else
     LS_OPTIONS=--color=none
fi
Change the '--color=tty' (2nd line) to --color=none.  After this, any new bash shell opened will not automatically try to display colors in the directory list, and the delay will not occur.
 
3.  Alternatively, to alter this for one user, edit '/home/%user/.bashrc' and add:
export LS_OPTIONS="-A -N -T 0"
(or whatever options are desired for that user).

Additional Information

In cases of huge amount of files e.g. >10k within one directory the "ls" command also tries to sort and get user names resolved which slows down dramatically.

Following 'ls' command will run without sorting and user name resolution producing single column layout:
ls -f1n <directory>

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:7005969
  • Creation Date: 14-May-2010
  • Modified Date:03-Mar-2020
    • SUSE Linux Enterprise Server

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.