Создание каталога на cifs mount возвращает ошибку, но каталог действительно создан
Я подключил внешний диск, подключенный к маршрутизатору ASUS, который реализует сервер Samba. Все работает просто отлично, кроме одной раздражающей вещи: создание каталога с помощью mkdir возвращает сообщение об ошибке, даже если каталог действительно создан.
Соответствующая строка в /etc/fstab
выглядит так:
//192.168.1.1/data /media/external/data cifs username=data,password=data,vers=2.0,uid=1000,gid=1000 0 0
При монтировании диска все ок. (Каталог stackoverflow
находится на внешнем диске.)
daniel@nuc:/media/external$ ll
total 12
drwxr-xr-x 5 root root 4096 mar 23 21:05 ./
drwxr-xr-x 4 root root 4096 mar 10 15:25 ../
drwxr-xr-x 2 daniel daniel 4096 mar 24 10:50 data/
daniel@nuc:/media/external$ sudo mount -a
daniel@nuc:/media/external$ cd data
daniel@nuc:/media/external/data$ ll
total 4
drwxr-xr-x 2 daniel daniel 0 mar 24 10:54 ./
drwxr-xr-x 5 root root 4096 mar 23 21:05 ../
drwxr-xr-x 2 daniel daniel 0 mar 14 23:07 stackoverflow/
daniel@nuc:/media/external/data$
При создании каталога test
, сообщение об ошибке отображается.
daniel@nuc:/media/external/data$ mkdir test
mkdir: cannot create directory ‘test’: Not a directory
Тем не менее, каталог создан!
daniel@nuc:/media/external/data$ ll
total 4
drwxr-xr-x 2 daniel daniel 0 mar 24 11:01 ./
drwxr-xr-x 5 root root 4096 mar 23 21:05 ../
drwxr-xr-x 2 daniel daniel 0 mar 14 23:07 stackoverflow/
drwxr-xr-x 2 daniel daniel 0 mar 24 11:01 test/
При удалении каталога и воссоздании его с -p
флаг, сообщение об ошибке не отображается.
daniel@nuc:/media/external/data$ rmdir test
daniel@nuc:/media/external/data$ ll
total 4
drwxr-xr-x 2 daniel daniel 0 mar 24 11:01 ./
drwxr-xr-x 5 root root 4096 mar 23 21:05 ../
drwxr-xr-x 2 daniel daniel 0 mar 14 23:07 stackoverflow/
daniel@nuc:/media/external/data$ mkdir -p test
daniel@nuc:/media/external/data$ ll
total 4
drwxr-xr-x 2 daniel daniel 0 mar 24 11:01 ./
drwxr-xr-x 5 root root 4096 mar 23 21:05 ../
drwxr-xr-x 2 daniel daniel 0 mar 14 23:07 stackoverflow/
drwxr-xr-x 2 daniel daniel 0 mar 24 11:01 test/
daniel@nuc:/media/external/data$
Это заставляет меня задуматься, если проблема в том, что mkdir по какой-то причине "не видит" смонтированный каталог и выдает сообщение об ошибке, как если бы вы попытались создать подкаталог в несуществующем каталоге.
Но почему это? Что я могу сделать, чтобы это исправить?
(Я добавлю, что при монтаже с vers=1.0
, ошибка mkdir не показывает. Тем не мение, file_mode
а также dir_mode
затем, кажется, игнорируются, и мне нужно, чтобы они были установлены в 0700
в другом приложении.)
Обновление: когда диск подключен к USB-порту компьютера и смонтированы NTFS, все работает хорошо.
Обновление: вывод из strace mkdir test
execve("/bin/mkdir", ["mkdir", "test"], 0x7ffdb3669768 /* 67 vars */) = 0
brk(NULL) = 0x561761838000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=158495, ...}) = 0
mmap(NULL, 158495, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f782b715000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\20b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=154832, ...}) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f782b713000
mmap(NULL, 2259152, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f782b2ed000
mprotect(0x7f782b312000, 2093056, PROT_NONE) = 0
mmap(0x7f782b511000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x24000) = 0x7f782b511000
mmap(0x7f782b513000, 6352, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f782b513000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\3\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\260\34\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=2030544, ...}) = 0
mmap(NULL, 4131552, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f782aefc000
mprotect(0x7f782b0e3000, 2097152, PROT_NONE) = 0
mmap(0x7f782b2e3000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1e7000) = 0x7f782b2e3000
mmap(0x7f782b2e9000, 15072, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f782b2e9000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0 \25\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=464824, ...}) = 0
mmap(NULL, 2560264, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f782ac8a000
mprotect(0x7f782acfa000, 2097152, PROT_NONE) = 0
mmap(0x7f782aefa000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x70000) = 0x7f782aefa000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0P\16\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0644, st_size=14560, ...}) = 0
mmap(NULL, 2109712, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f782aa86000
mprotect(0x7f782aa89000, 2093056, PROT_NONE) = 0
mmap(0x7f782ac88000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x2000) = 0x7f782ac88000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0000b\0\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=144976, ...}) = 0
mmap(NULL, 2221184, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f782a867000
mprotect(0x7f782a881000, 2093056, PROT_NONE) = 0
mmap(0x7f782aa80000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x19000) = 0x7f782aa80000
mmap(0x7f782aa82000, 13440, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f782aa82000
close(3) = 0
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f782b711000
arch_prctl(ARCH_SET_FS, 0x7f782b712040) = 0
mprotect(0x7f782b2e3000, 16384, PROT_READ) = 0
mprotect(0x7f782aa80000, 4096, PROT_READ) = 0
mprotect(0x7f782ac88000, 4096, PROT_READ) = 0
mprotect(0x7f782aefa000, 4096, PROT_READ) = 0
mprotect(0x7f782b511000, 4096, PROT_READ) = 0
mprotect(0x56175ffd9000, 4096, PROT_READ) = 0
mprotect(0x7f782b73c000, 4096, PROT_READ) = 0
munmap(0x7f782b715000, 158495) = 0
set_tid_address(0x7f782b712310) = 7736
set_robust_list(0x7f782b712320, 24) = 0
rt_sigaction(SIGRTMIN, {sa_handler=0x7f782a86ccb0, sa_mask=[], sa_flags=SA_RESTORER|SA_SIGINFO, sa_restorer=0x7f782a879890}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {sa_handler=0x7f782a86cd50, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_SIGINFO, sa_restorer=0x7f782a879890}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
prlimit64(0, RLIMIT_STACK, NULL, {rlim_cur=8192*1024, rlim_max=RLIM64_INFINITY}) = 0
statfs("/sys/fs/selinux", 0x7fff4f557960) = -1 ENOENT (No such file or directory)
statfs("/selinux", 0x7fff4f557960) = -1 ENOENT (No such file or directory)
brk(NULL) = 0x561761838000
brk(0x561761859000) = 0x561761859000
openat(AT_FDCWD, "/proc/filesystems", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tr"..., 1024) = 420
read(3, "", 1024) = 0
close(3) = 0
access("/etc/selinux/config", F_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=11861168, ...}) = 0
mmap(NULL, 11861168, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f7829d17000
close(3) = 0
mkdir("test", 0777) = -1 ENOTDIR (Not a directory)
openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2995, ...}) = 0
read(3, "# Locale name alias data base.\n#"..., 4096) = 2995
read(3, "", 4096) = 0
close(3) = 0
openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.utf8/LC_MESSAGES/coreutils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/coreutils.mo", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=578, ...}) = 0
mmap(NULL, 578, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f782b73b000
close(3) = 0
openat(AT_FDCWD, "/usr/lib/x86_64-linux-gnu/charset.alias", O_RDONLY|O_NOFOLLOW) = -1 ENOENT (No such file or directory)
write(2, "mkdir: ", 7mkdir: ) = 7
write(2, "cannot create directory \342\200\230test\342"..., 34cannot create directory ‘test’) = 34
openat(AT_FDCWD, "/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/usr/share/locale-langpack/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": Not a directory", 17: Not a directory) = 17
write(2, "\n", 1
) = 1
close(1) = 0
close(2) = 0
exit_group(1) = ?
+++ exited with 1 +++
Обновление по запросу smb.conf
файл с роутера ASUS (несколько прибрано, соответствующие части сохранены):
[global]
workgroup = WORKGROUP
netbios name = RT-AC68U-AC48
server string = RT-AC68U-AC48
unix charset = UTF8
display charset = UTF8
load printers = no
printing = bsd
printcap name = /dev/null
log file = /var/log.samba
log level = 0
max log size = 5
security = USER
guest ok = no
map to guest = Bad User
encrypt passwords = yes
pam password change = no
null passwords = yes
force directory mode = 0777
force create mode = 0777
max connections = 5
socket options = IPTOS_LOWDELAY TCP_NODELAY SO_KEEPALIVE
obey pam restrictions = no
disable spoolss = yes
host msdfs = no
strict allocate = no
wide links = no
bind interfaces only = yes
interfaces = lo br0 192.168.1.1/255.255.255.0
use sendfile = yes
map archive = no
map hidden = no
map read only = no
map system = no
store dos attributes = yes
dos filemode = yes
oplocks = yes
level2 oplocks = yes
kernel oplocks = no
enable core files = no
deadtime = 30
load printers = no
printable = no
max protocol = SMB2
min protocol = SMB2
smb encrypt = disabled
min receivefile size = 16384
passdb backend = smbpasswd
smb passwd file = /etc/samba/smbpasswd
[data]
comment = Seagate_3TB's data in Seagate Backup+ Desk
path = /tmp/mnt/Seagate_3TB/data
dos filetimes = yes
fake directory create times = yes
valid users = data, backup
invalid users = backup
read list = data
write list = data
Создание каталога, когда ssh'd на маршрутизаторе работает должным образом (возможно, не очень удивительно):
daniel@RT-AC68U-AC48:/tmp/mnt/Seagate_3TB/data# ll
drwxrwxrwx 1 daniel root 0 Mar 15 00:07 stackoverflow/
daniel@RT-AC68U-AC48:/tmp/mnt/Seagate_3TB/data# mkdir test
daniel@RT-AC68U-AC48:/tmp/mnt/Seagate_3TB/data# ll
drwxrwxrwx 1 daniel root 0 Mar 15 00:07 stackoverflow/
drwxrwxrwx 1 daniel root 0 Apr 3 21:46 test/
1 ответ
Это может быть умирающий жесткий диск /SSD, который mkdir
не может написать.
Так как это внешний диск. Включена ли блокировка чтения-записи?
Его можно монтировать только для чтения вместо чтения + записи.
Использование: sudo mount -o remount,rw /partition/identifier /mount/point
перемонтировать как читать + писать. Источник: /questions/181394/kak-peremontirovat-fajlovuyu-sistemu-v-rezhim-chteniya-zapisi/181411#181411.