1

When I run ls command for some directories, it may take about 1.5 seconds to complete even if directory has just a few files, but for most of directories it's very fast. It seems that it's slow for directories which I didn't access for a long time, but maybe it's not related. When I repeat this command for same directory it always run fast. This command is slow only for directories on /home mount point, for all other partition on same volume it's fast.

E.g. my ~/backups dir contains just 3 files, here is output for 2 runs:

$ time ls ~/backups
# file list
real    0m1.635s
user    0m0.001s
sys 0m0.000s

$ time ls ~/backups
# file list
real    0m0.001s
user    0m0.001s
sys 0m0.000s

My /home is formatted in ext4 fs, it's a lvm2 partition encrypted with LUKS, the volume is a HDD "WDC WD10SPZX-75Z".

fstab line for /home is:

/dev/mapper/home /home ext4 defaults,noatime 0 0

Is it possible to improve IO performance in my case?

UPDATE: it's not only ls command, but all io operations, e.g. touch command is also slow when I try to modify directories which I didn't access for a long time.

UPDATE2: the output of lsblk for sda drive:

NAME           MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda              8:0    0 931.5G  0 disk
├─HDD-root     254:3    0    32G  0 lvm
├─HDD-var      254:4    0   256G  0 lvm
│ └─var        254:8    0   256G  0 crypt /var
└─HDD-home     254:5    0   512G  0 lvm
  └─home       254:7    0   512G  0 crypt /home

output of findmnt:

TARGET                          SOURCE               FSTYPE      OPTIONS
/                               /dev/mapper/root     ext4        rw,relatime,commit=600
├─/proc                         proc                 proc        rw,nosuid,nodev,noexec,relatime
│ └─/proc/sys/fs/binfmt_misc    binfmt_misc          binfmt_misc rw,nosuid,nodev,noexec,relatime
├─/dev                          udev                 devtmpfs    rw,nosuid,relatime,size=10240k,nr_inodes=2013980,mode=755
│ ... (some /dev related mount points)
├─/sys                          sysfs                sysfs       rw,nosuid,nodev,noexec,relatime
│ ... (a lot of /sys and cgroups mount points)
├─/run                          tmpfs                tmpfs       rw,nodev,relatime,size=1612028k,mode=755
│ └─/run/user/1000              none                 tmpfs       rw,relatime,mode=700,uid=1000
├─/home                         /dev/mapper/home     ext4        rw,noatime,commit=600
│ └─/home/projects              /dev/mapper/projects ext4        rw,relatime,discard,commit=600
├─/var                          /dev/mapper/var      ext4        rw,relatime,commit=600
└─/tmp                          tmpfs                tmpfs       rw,nosuid,nodev,noatime,size=4194304k
  • How is the health of your HDD? Have you ran any SMART tests? – Jakub Lucký Mar 17 at 8:43
  • @JakubLucký yes, I used smartmontools, it completes without error. Also, another volume-group on same HDD is working fine. – g4s8 Mar 17 at 9:12
  • Could it be due to LUKS? please add the output of lsblk and findmnt – Emmanuel Rosa Mar 17 at 10:43
  • Does the hard drive spin down too soon maybe, and then requiring some time to spin up again? – Kusalananda Mar 17 at 10:48
  • @EmmanuelRosa done, please see "UPDATE2" section in question – g4s8 Mar 17 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.