问题:突然就不能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
你的 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)
這個版本下的MD5。
不太清楚各個發行版之間的mkdir是不是MD5相同,理論上是應該一樣的。
你可以從另一台機器上拷貝一個mkdir過去試試。
另外,
cat ~/.bashrc |grep mkdir
也可以看看有沒有被起別名。type mkdir and file mkdir, 確保mkdir程式不被竄改
dmesg看有無系統資訊可以看出倪端
確實沒有遇到這種情況,根據提示可排除權限的問題,可以用不同的用戶
which mkdir
一下試試,看有是不是指向同一個目標。這幾個都不能
mkdir
的目錄能看出什麼關係,例如都在同一個分區下?從其它目錄
mv
一本目錄過來,看寫入是否正常?在正常的目錄下
strace mkdir test
,把兩邊的輸出對比看一下重啟
你的資料夾有進入的權限,但沒有
写入
(X),也就是說建立資料夾的權限。