touch: setting times of 'xxx' No such file or directory

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 5
  • Red Hat Enterprise Linux 6
  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • EXT Filesystems

Issue

  • Unable to create a new file getting getting below error message:
'touch: setting times of `xxx': No such file or directory'

Resolution

  • Verify special filesystem flags set on files and directories that are not visible in normal ls -l output.
  • Run filesystem check if needed, this should resolve your issue
# e2fsck -fy /dev/vgname/lvname

NOTE - Before running filesystem check please have a valid data backup of affected filesystem

Diagnostic Steps

  • Check for any EXT related error messages -
kernel: EXT4-fs error (device dm-100): mb_free_blocks: double-free of inode 0's block 42203(bit 9435 in group 1)
kernel: EXT4-fs (dm-100): warning: checktime reached, running e2fsck is recommended
  • Check for filesystem-level protection flags like immutable bit.
# lsattr -d /path/to/file-or-directory
  • Collect the dumpe2fs output and check the state of the filesystem.
# dumpe2fs /dev/vgname/lvname
  • Collect strace output to check where the call gets failed -
# strace -fxvttT -o /tmp/strace_touch.txt touch test &> /tmp/touch.out
13393 21:18:11.916805 open("test", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = -1 EINVAL (Invalid argument) <0.000073>
13393 21:18:11.916922 utimensat(AT_FDCWD, "test", NULL, 0) = -1 ENOENT (No such file or directory) <0.000017>
13393 21:18:11.916998 open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3 <0.000021>
13393 21:18:11.917059 fstat(3, {st_dev=makedev(253, 54), st_ino=1179961, st_mode=S_IFREG|0644, st_nlink=1, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=2512, st_atime=2017/04/30-08:48:46, st_mtime=2017/01/26-09:43:26, st_ctime=2017/04/29-08:48:28}) = 0 <0.000014>
13393 21:18:11.917119 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f684ce77000 <0.000017>
13393 21:18:11.917165 read(3, "# Locale name alias data base.\n#"..., 4096) = 2512 <0.000021>
13393 21:18:11.917247 read(3, "", 4096) = 0 <0.000014>
13393 21:18:11.917291 close(3)          = 0 <0.000015>
13393 21:18:11.917334 munmap(0x7f684ce77000, 4096) = 0 <0.000022>
13393 21:18:11.917424 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000019>
13393 21:18:11.917486 open("/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000017>
13393 21:18:11.917535 open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000020>
13393 21:18:11.917589 open("/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000018>
13393 21:18:11.917638 open("/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000017>
13393 21:18:11.917685 open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3 <0.000019>
13393 21:18:11.917734 fstat(3, {st_dev=makedev(253, 54), st_ino=1312336, st_mode=S_IFREG|0644, st_nlink=2, st_uid=0, st_gid=0, st_blksize=4096, st_blocks=8, st_size=435, st_atime=2017/04/30-08:52:47, st_mtime=2017/02/06-11:24:06, st_ctime=2017/04/29-08:48:42}) = 0 <0.000014>
13393 21:18:11.917793 mmap(NULL, 435, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f684ce77000 <0.000017>
13393 21:18:11.917840 close(3)          = 0 <0.000014>
13393 21:18:11.917938 write(2, "touch: ", 7) = 7 <0.000034>
13393 21:18:11.918005 write(2, "setting times of `test'", 23) = 23 <0.000018>
13393 21:18:11.918067 open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000018>
13393 21:18:11.918116 open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000017>
13393 21:18:11.918164 open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000018>
13393 21:18:11.918213 open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000016>
13393 21:18:11.918260 open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000017>
13393 21:18:11.918307 open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory) <0.000018>
13393 21:18:11.918362 write(2, ": No such file or directory", 27) = 27 <0.000018>
13393 21:18:11.918411 write(2, "\n", 1) = 1 <0.000017>
13393 21:18:11.918461 close(1)          = 0 <0.000013>
13393 21:18:11.918504 close(2)          = 0 <0.000014>
13393 21:18:11.918553 exit_group(1)     = ?
13393 21:18:11.918682 +++ exited with 1 +++

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments