linux运维 - linux 不能mkdir了
迷茫
迷茫 2017-04-17 14:29:19
0
7
602

问题:突然就不能mkdir了,求大神指点下解决思路

[cuixiaohuan lamp]$ mkdir test
mkdir: cannot create directory `test': Invalid argument



分割线:
也没有重启,没有进行任何操作,今天早上突然好了,跪了。
个人感触
  • ext2这种老的文件系统真该舍弃了

  • segment上还是有很多大牛的,希望这个社区越来越好。

环境前简单描述下现状:
最开始在一个特定的目录下mkdir报错误,没有特别在意;今天好几个文件夹都报错,无法mkdir;但是有些文件夹可以mkdir,而且对比了下没有任何区别;
关于环境:

# 机器环境
[cuixiaohuan ~]$ uname -a
Linux cuixiaohuan 2.6.32_1-10-0-0 #1 SMP Fri Feb 1 17:20:11 CST 2013 x86_64 x86_64 x86_64 GNU/Linux

# 文件夹权限
[cuixiaohuan lamp]$ ll
total 5744
drwxrwxrwx  16 work work    4096 Jan 21 14:33 apache2
drwxrwxrwx   5 work work    4096 Jul 19  2013 memcached
drwxrwxrwx  13 work work    4096 Jan  8 10:50 mysql5
drwxrwxrwx   8 work work    4096 Dec  7 17:25 php5

# 关于磁盘和inode是否满了
[cuixiaohuan lamp]$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             8.2G  7.0G  1.2G  86% /
/dev/sda3             1.4T  939G  402G  71% /home
[cuixiaohuan lamp]$ df -i
Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/sda2            1098880  573014  525866   53% /
/dev/sda3            181288960 6331853 174957107    4% /home

# 文件类型
[cuixiaohuan lining]$ mount
/dev/sda2 on / type ext2 (rw)
none on /proc type proc (rw)
none on /sys type sysfs (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda3 on /home type ext2 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
none on /sys/kernel/debug type debugfs (rw)

# mkdir 信息是否被更改(mkdir应该没有被修改,在某些文件夹下可以mkdir,部分文件件下不能,两个文件夹ls -l 没有任何区别)
[cuixiaohuan lamp]$ strace mkdir test
execve("/bin/mkdir", ["mkdir", "test"], [/* 29 vars */]) = 0
uname({sys="Linux", node="cuixiaohuan", ...}) = 0
brk(0)                                  = 0x507000
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e43d9d000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
open("/home/work/code_style/c/psstyle/lib_ps/tls/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/code_style/c/psstyle/lib_ps/tls/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/code_style/c/psstyle/lib_ps/tls/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/code_style/c/psstyle/lib_ps/tls", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/code_style/c/psstyle/lib_ps/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/code_style/c/psstyle/lib_ps/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/code_style/c/psstyle/lib_ps/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/code_style/c/psstyle/lib_ps", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/home/work/thirdparty/mysql5/lib/mysql/tls/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/thirdparty/mysql5/lib/mysql/tls/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/thirdparty/mysql5/lib/mysql/tls/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/thirdparty/mysql5/lib/mysql/tls", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/thirdparty/mysql5/lib/mysql/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/thirdparty/mysql5/lib/mysql/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/thirdparty/mysql5/lib/mysql/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/thirdparty/mysql5/lib/mysql", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("/home/work/util_so/tls/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/util_so/tls/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/util_so/tls/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/util_so/tls", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/util_so/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/util_so/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/util_so/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/util_so", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0
open("/home/work/tools/subversion/lib/tls/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/tools/subversion/lib/tls/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/tools/subversion/lib/tls/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/tools/subversion/lib/tls", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/tools/subversion/lib/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/tools/subversion/lib/x86_64", 0x7fff6a0261d0) = -1 ENOENT (No such file or directory)
open("/home/work/tools/subversion/lib/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
stat("/home/work/tools/subversion/lib", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
open("tls/x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/libselinux.so.1", O_RDONLY)   = -1 ENOENT (No such file or directory)
open("x86_64/libselinux.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
open("libselinux.so.1", O_RDONLY)       = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY)      = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=75153, ...}) = 0
mmap(NULL, 75153, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2e43d8a000
close(3)                                = 0
open("/lib64/libselinux.so.1", O_RDONLY) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\220+\240"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=62504, ...}) = 0
mmap(0x302ba00000, 1111640, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x302ba00000
mprotect(0x302ba0e000, 1054296, PROT_NONE) = 0
mmap(0x302bb0e000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0xe000) = 0x302bb0e000
mmap(0x302bb0f000, 1624, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x302bb0f000
close(3)                                = 0
open("/home/work/code_style/c/psstyle/lib_ps/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/work/thirdparty/mysql5/lib/mysql/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/work/util_so/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/home/work/tools/subversion/lib/libc.so.6", O_RDONLY) = -1 ENOENT (No such file or directory)
open("tls/x86_64/libc.so.6", O_RDONLY)  = -1 ENOENT (No such file or directory)
open("tls/libc.so.6", O_RDONLY)         = -1 ENOENT (No such file or directory)
open("x86_64/libc.so.6", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("libc.so.6", O_RDONLY)             = -1 ENOENT (No such file or directory)
open("/lib64/tls/libc.so.6", O_RDONLY)  = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`\305\361"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1493186, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e43d89000
mmap(0x302af00000, 2310056, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x302af00000
mprotect(0x302b02b000, 1085352, PROT_NONE) = 0
mmap(0x302b12a000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x12a000) = 0x302b12a000
mmap(0x302b130000, 16296, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x302b130000
close(3)                                = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e43d88000
mprotect(0x302b12a000, 12288, PROT_READ) = 0
arch_prctl(ARCH_SET_FS, 0x7f2e43d886e0) = 0
munmap(0x7f2e43d8a000, 75153)           = 0
access("/etc/selinux/", F_OK)           = 0
brk(0)                                  = 0x507000
brk(0x528000)                           = 0x528000
open("/etc/selinux/config", O_RDONLY)   = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=447, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e43d9c000
read(3, "# This file controls the state o"..., 4096) = 447
close(3)                                = 0
munmap(0x7f2e43d9c000, 4096)            = 0
open("/proc/mounts", O_RDONLY)          = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e43d9c000
read(3, "rootfs / rootfs rw 0 0\n/proc /pr"..., 1024) = 1024
read(3, "ne /noah/bin tmpfs rw,relatime,s"..., 1024) = 104
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0x7f2e43d9c000, 4096)            = 0
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=48504432, ...}) = 0
mmap(NULL, 48504432, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f2e40f46000
close(3)                                = 0
umask(0)                                = 02
umask(02)                               = 0
mkdir("test", 0777)                     = -1 EINVAL (Invalid argument)
stat("test", 0x7fff6a026b80)            = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2528, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2e43d9c000
read(3, "# Locale name alias data base.\n#"..., 4096) = 2528
read(3, "", 4096)                       = 0
close(3)                                = 0
munmap(0x7f2e43d9c000, 4096)            = 0
open("/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "mkdir: ", 7mkdir: )                  = 7
write(2, "cannot create directory `test\'", 30cannot create directory `test') = 30
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Invalid argument", 18: Invalid argument)      = 18
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?
Process 16261 detached
迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

membalas semua(7)
巴扎黑

你的 ext2 文件系统可能出问题了。你可以备份数据然后 fsck 试试。

另外不要用 ext2 这么古老的文件系统了,用的人太少所以出些奇怪的 bug 很正常。赶紧换了吧,不然就算不遇到 bug,宛然断个电、死个机什么的,说不定你的数据就消失了。还有哦,目录不林随便给 777 权限,很容易被本地提权的。

你有兴趣可以发到内核邮件列表看看。

不排除被入侵的可能。USTC 曾经经历过奇怪的问题,结果发现是被入侵了。

黄舟

不大可能是权限问题(包括缺W、缺X),否则应该是 Permission denied 。

mkdir返回EINVAL是一个在mkdir系统调用(system call)的文档(mkdir(2))中未注明的错误代码。
需要指出的是:只要情况合理,那么系统调用其实可以返回未经文档化的错误代码。这一点被POSIX所允许。
所以这不是一个系统本身的bug,但一定是一个不寻常的,不在mkdir设计者想象当中的意外情况。

我对这种意外的一般猜测是文件系统错误。你的文件系统是什么?如果你能调用到系统日志(syslog),请看一下是否有“mount fs with error”之类的文字出现。

大家讲道理

我的系统版本是:CentOS Linux release 7.2.1511 (Core)

cd /usr/bin
md5sum mkdir
6bdb3cf0e639fe3e440711e2ebbab791  mkdir

这个版本下的MD5。
不太清楚各个发行版之间的mkdir是不是MD5相同,理论上讲是应该一样的。
你可以从另外一个机器上拷贝一个mkdir过去试试。
另外,cat ~/.bashrc |grep mkdir 也可以看看有没有被起别名。

Peter_Zhu

type mkdir and file mkdir, 确保mkdir程序不被篡改

dmesg看有无系统信息可以看出倪端

Peter_Zhu

确实没有遇到这种情况,根据提示可排除权限的问题,可以用不同的用户 which mkdir 一下试试,看有是不是指向同一个目标。

刘奇
  1. 这几个都不能mkdir的目录能看出什么关系,比如都在同一个分区下?

  2. 从其它目录 mv 一个目录过来,看写入是否正常?

  3. 在正常的目录下 strace mkdir test,把两边的输出对比看一下

  4. 重启

洪涛

你的文件夹有进入的权限,但是没有写入(X),也就是说创建文件夹的权限。

Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!