FAQ SearchLogin
Tuxera Home
View unanswered posts | View active topics It is currently Wed Nov 25, 2020 10:15



Post new topic Reply to topic  [ 7 posts ] 
RPi2: Failed to write lock '/dev/sda1': Permission denied 
Author Message

Joined: Fri Feb 12, 2016 11:21
Posts: 6
Post RPi2: Failed to write lock '/dev/sda1': Permission denied
Hello!
I build last stable release ntfs-3g_ntfsprogs-2015.3.14 for RaspberryPi B+, linux 4.1.17, libfuse (commit c41b1a5e7ef1c530946f7cb77dd982899f7d80db, version 3.0.0_pre0).
Code:
~ # /lib/ld-linux.so.3 /tmp/ntfs-3g
ntfs-3g: No device is specified.

ntfs-3g 2015.3.14 integrated FUSE 27 - Third Generation NTFS Driver
                Configuration type 1, XATTRS are on, POSIX ACLS are off

Copyright (C) 2005-2007 Yura Pakhuchiy
Copyright (C) 2006-2009 Szabolcs Szakacsits
Copyright (C) 2007-2015 Jean-Pierre Andre
Copyright (C) 2009 Erik Larsson

Usage:    ntfs-3g [-o option[,...]] <device|image_file> <mount_point>

Options:  ro (read-only mount), windows_names, uid=, gid=,
          umask=, fmask=, dmask=, streams_interface=.
          Please see the details in the manual (type: man ntfs-3g).

Example: ntfs-3g /dev/sda1 /mnt/windows

News, support and information:  http://tuxera.com

And now I try mount /dev/sda1:
Code:
~ # /lib/ld-linux.so.3 /tmp/ntfs-3g /dev/sda1 /tmp/mpoint/
Failed to write lock '/dev/sda1': Permission denied
Error opening '/dev/sda1': Permission denied
Failed to mount '/dev/sda1': Permission denied
Please check '/dev/sda1' and the ntfs-3g binary permissions,
and the mounting user ID. More explanation is provided at
http://tuxera.com/community/ntfs-3g-faq/#unprivileged

Information about device and mpoint:
Code:
~ # ls -l /dev/sda1
brw-rw----    1 root     root        8,   1 Jan  1 00:05 /dev/sda1
~ # ls -ld /tmp/mpoint/
drwxr-xr-x    2 root     root            40 Jan  1 00:06 /tmp/mpoint

I not understand why reasons for this errors:
Code:
~ # mount /dev/sda1 /tmp/mpoint
~ # cat /proc/mounts
rootfs / rootfs rw 0 0
none /proc proc rw,relatime 0 0
none /sys sysfs rw,relatime 0 0
none /tmp tmpfs rw,relatime 0 0
none /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0
/dev/sda1 /tmp/mpoint ntfs ro,relatime,uid=0,gid=0,fmask=0177,dmask=077,nls=utf8,errors=continue,mft_zone_multiplier=1 0 0
~ # dmesg
..............
[ 2481.300114] ntfs: volume version 3.1.
[ 2481.310894] ntfs: (device sda1): load_system_files(): $LogFile is not clean.  Mounting read-only.  Mount in Windows.

Why I can't mount NTFS partitions via ntfs-3g if I have all rights?
How can I solve this problem?

Thank you and excuse my bad english.


Fri Feb 12, 2016 11:37
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: RPi2: Failed to write lock '/dev/sda1': Permission denied
Hi,

Code:
~ # /lib/ld-linux.so.3 /tmp/ntfs-3g /dev/sda1 /tmp/mpoint/
Failed to write lock '/dev/sda1': Permission denied
Error opening '/dev/sda1': Permission denied
Failed to mount '/dev/sda1': Permission denied

Mounting as root, or inserting an entry in /etc/fstab generally avoid this kind of issues.
Code:
/dev/sda1 /tmp/mpoint ntfs ro,relatime,uid=0,gid=0,fmask=0177,dmask=077,nls=utf8,errors=continue,mft_zone_multiplier=1 0 0

This is probably not ntfs-3g. If you have another ntfs package, you may have to unmount before mounting with ntfs-3g.
Code:
[ 2481.300114] ntfs: volume version 3.1.
[ 2481.310894] ntfs: (device sda1): load_system_files(): $LogFile is not clean.  Mounting read-only.  Mount in Windows.

This is not an error from ntfs-3g. It just means your device is unclean : you probably did not unmount it properly from Windows. Better mount again on Windows and start a chkdsk, then do a safe unmount.

Regards

Jean-Pierre


Fri Feb 12, 2016 14:55
Profile

Joined: Fri Feb 12, 2016 11:21
Posts: 6
Post Re: RPi2: Failed to write lock '/dev/sda1': Permission denied
jpa wrote:
Code:
~ # /lib/ld-linux.so.3 /tmp/ntfs-3g /dev/sda1 /tmp/mpoint/
Failed to write lock '/dev/sda1': Permission denied
Error opening '/dev/sda1': Permission denied
Failed to mount '/dev/sda1': Permission denied

Mounting as root, or inserting an entry in /etc/fstab generally avoid this kind of issues.

Yes, I mount as root.


Fri Feb 12, 2016 16:37
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: RPi2: Failed to write lock '/dev/sda1': Permission denied
Hi,

Quote:
Yes, I mount as root.

Then it is because the device is already mounted by another driver, unmount it first :
Code:
umount /tmp/mpoint


Regards

Jean-Pierre


Fri Feb 12, 2016 17:41
Profile

Joined: Fri Feb 12, 2016 11:21
Posts: 6
Post Re: RPi2: Failed to write lock '/dev/sda1': Permission denied
jpa wrote:
Hi,
Then it is because the device is already mounted by another driver, unmount it first :

No, device is not mount.
Code:
~ # dmesg
...........
[  941.829352] usb 1-1.4: new high-speed USB device number 4 using dwc_otg
[  941.950716] usb 1-1.4: New USB device found, idVendor=14cd, idProduct=1212
[  941.959665] usb 1-1.4: New USB device strings: Mfr=1, Product=3, SerialNumber=2
[  941.968995] usb 1-1.4: Product: Mass Storage Device
[  941.975861] usb 1-1.4: Manufacturer: Generic
[  941.982071] usb 1-1.4: SerialNumber: 121220130416
[  941.994718] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[  942.008869] scsi host0: usb-storage 1-1.4:1.0
[  943.020495] scsi 0:0:0:0: Direct-Access     Mass     Storage Device   1.00 PQ: 0 ANSI: 0 CCS
[  943.043410] sd 0:0:0:0: Attached scsi generic sg0 type 0
[  943.773282] sd 0:0:0:0: [sda] 123795456 512-byte logical blocks: (63.3 GB/59.0 GiB)
[  943.785461] sd 0:0:0:0: [sda] Write Protect is off
[  943.792297] sd 0:0:0:0: [sda] Mode Sense: 03 00 00 00
[  943.792800] sd 0:0:0:0: [sda] No Caching mode page found
[  943.800139] sd 0:0:0:0: [sda] Assuming drive cache: write through
[  943.816765]  sda: sda1
[  943.831120] sd 0:0:0:0: [sda] Attached SCSI removable disk
[  944.835368] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

~ # ls -l /dev/sda*
brw-rw----    1 root     root        8,   0 Jan  1 00:15 /dev/sda
brw-rw----    1 root     root        8,   1 Jan  1 00:15 /dev/sda1

~ # cat /proc/mounts
rootfs / rootfs rw 0 0
none /proc proc rw,relatime 0 0
none /sys sysfs rw,relatime 0 0
none /tmp tmpfs rw,relatime 0 0
none /var/run tmpfs rw,relatime 0 0
none /dev/pts devpts rw,relatime,mode=600,ptmxmode=000 0 0
/dev/mmcblk0p1 /var/data vfat ro,nosuid,nodev,noexec,noatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro 0 0

~ # /lib/ld-linux.so.3 /tmp/ntfs-3g /dev/sda1 /tmp
Failed to write lock '/dev/sda1': Permission denied
Error opening '/dev/sda1': Permission denied
Failed to mount '/dev/sda1': Permission denied
Please check '/dev/sda1' and the ntfs-3g binary permissions,
and the mounting user ID. More explanation is provided at
http://tuxera.com/community/ntfs-3g-faq/#unprivileged


Wed Mar 09, 2016 17:14
Profile

Joined: Fri Feb 12, 2016 11:21
Posts: 6
Post Re: RPi2: Failed to write lock '/dev/sda1': Permission denied
Strace output:
Code:
~ # /lib/ld-linux.so.3 /tmp/strace ntfs-3g /dev/sda1 /tmp
execve("/usr/sbin/ntfs-3g", ["ntfs-3g", "/dev/sda1", "/tmp"], [/* 8 vars */]) = 0
brk(NULL)                               = 0x1b56000
uname({sysname="Linux", nodename="dozor", ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6ff1000
...................
open("/lib/libpthread.so.0", O_RDONLY)  = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0lD\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=88500, ...}) = 0
mmap2(NULL, 127520, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6fae000
mprotect(0xb6fc3000, 28672, PROT_NONE)  = 0
mmap2(0xb6fca000, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x14000) = 0xb6fca000
mmap2(0xb6fcc000, 4640, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6fcc000
close(3)                                = 0
open("/lib/libntfs-3g.so.86", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0\274_\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=1210430, ...}) = 0
mmap2(NULL, 341972, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f5a000
mprotect(0xb6fa5000, 32768, PROT_NONE)  = 0
mmap2(0xb6fad000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x4b000) = 0xb6fad000
close(3)                                = 0
open("/lib/libgcc_s.so.1", O_RDONLY)    = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0H&\0\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0644, st_size=41064, ...}) = 0
mmap2(NULL, 72504, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6f48000
mprotect(0xb6f52000, 28672, PROT_NONE)  = 0
mmap2(0xb6f59000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x9000) = 0xb6f59000
close(3)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0(\0\1\0\0\0pV\1\0004\0\0\0"..., 512) = 512
fstat64(3, {st_mode=S_IFREG|0755, st_size=1197508, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6ff0000
mmap2(NULL, 1201396, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0xb6e22000
mmap2(0xb6f42000, 12288, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x120000) = 0xb6f42000
mmap2(0xb6f45000, 9460, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0xb6f45000
close(3)                                = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fef000
set_tls(0xb6fef4c0, 0xb6ff3904, 0xb6fefb98, 0xb6fef4c0, 0xb6ff3000) = 0
mprotect(0xb6f42000, 8192, PROT_READ)   = 0
mprotect(0xb6fca000, 4096, PROT_READ)   = 0
mprotect(0xb6ff2000, 4096, PROT_READ)   = 0
set_tid_address(0xb6fef068)             = 334
set_robust_list(0xb6fef070, 12)         = 0
futex(0xbeb85e04, FUTEX_WAKE_PRIVATE, 1) = 0
futex(0xbeb85e04, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 1, NULL, b6fcb000) = -1 EAGAIN (Resource temporarily unavailable)
rt_sigaction(SIGRTMIN, {0xb6fb1f9c, [], SA_RESTORER|SA_SIGINFO, 0xb6e4df10}, NULL, 8) = 0
rt_sigaction(SIGRT_1, {0xb6fb1e38, [], SA_RESTORER|SA_RESTART|SA_SIGINFO, 0xb6e4df10}, NULL, 8) = 0
rt_sigprocmask(SIG_UNBLOCK, [RTMIN RT_1], NULL, 8) = 0
ugetrlimit(RLIMIT_STACK, {rlim_cur=8192*1024, rlim_max=RLIM_INFINITY}) = 0
open("/dev/null", O_RDWR|O_LARGEFILE)   = 3
close(3)                                = 0
getegid32()                             = 0
getgid32()                              = 0
getegid32()                             = 0
setresgid32(-1, 0, 0)                   = 0
getegid32()                             = 0
geteuid32()                             = 0
getuid32()                              = 0
geteuid32()                             = 0
setresuid32(-1, 0, 0)                   = 0
geteuid32()                             = 0
brk(NULL)                               = 0x1b56000
brk(0x1b78000)                          = 0x1b78000
lstat64("/dev", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat64("/dev/sda1", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 1), ...}) = 0
getuid32()                              = 0
getgid32()                              = 0
lstat64("/dev", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat64("/dev/sda1", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 1), ...}) = 0
open("/proc/mounts", O_RDONLY)          = 3
futex(0xb6f45bb8, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fee000
read(3, "rootfs / rootfs rw 0 0\nnone /pro"..., 1024) = 364
getcwd("/root", 4096)                   = 6
lstat64("/root/rootfs", 0xbeb85b20)     = -1 ENOENT (No such file or directory)
getcwd("/root", 4096)                   = 6
lstat64("/root/none", 0xbeb85b20)       = -1 ENOENT (No such file or directory)
getcwd("/root", 4096)                   = 6
lstat64("/root/none", 0xbeb85b20)       = -1 ENOENT (No such file or directory)
getcwd("/root", 4096)                   = 6
lstat64("/root/none", 0xbeb85b20)       = -1 ENOENT (No such file or directory)
getcwd("/root", 4096)                   = 6
lstat64("/root/none", 0xbeb85b20)       = -1 ENOENT (No such file or directory)
getcwd("/root", 4096)                   = 6
lstat64("/root/none", 0xbeb85b20)       = -1 ENOENT (No such file or directory)
lstat64("/dev", {st_mode=S_IFDIR|0755, st_size=0, ...}) = 0
lstat64("/dev/mmcblk0p1", {st_mode=S_IFBLK|0660, st_rdev=makedev(179, 1), ...}) = 0
read(3, "", 1024)                       = 0
close(3)                                = 0
munmap(0xb6fee000, 4096)                = 0
stat64("/tmp", {st_mode=S_IFDIR|S_ISVTX|0777, st_size=60, ...}) = 0
open("/proc/filesystems", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6fee000
read(3, "nodev\tsysfs\nnodev\trootfs\nnodev\tr"..., 1024) = 246
close(3)                                = 0
munmap(0xb6fee000, 4096)                = 0
geteuid32()                             = 0
getegid32()                             = 0
stat64("/dev/fuse", {st_mode=S_IFCHR|0660, st_rdev=makedev(10, 229), ...}) = 0
getegid32()                             = 0
getgid32()                              = 0
getegid32()                             = 0
setresgid32(-1, 0, 0)                   = 0
getegid32()                             = 0
geteuid32()                             = 0
getuid32()                              = 0
geteuid32()                             = 0
setresuid32(-1, 0, 0)                   = 0
geteuid32()                             = 0
stat64("/dev/sda1", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 1), ...}) = 0
mmap2(NULL, 135168, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6e01000
stat64("/dev/sda1", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 1), ...}) = 0
open("/dev/sda1", O_RDWR|O_LARGEFILE)   = 3
fcntl64(3, F_SETLK64, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = -1 EACCES (Permission denied)
write(2, "Failed to write lock '/dev/sda1'", 32Failed to write lock '/dev/sda1') = 32
write(2, ": Permission denied\n", 20: Permission denied
)   = 20
close(3)                                = 0
write(2, "Error opening '/dev/sda1'", 25Error opening '/dev/sda1') = 25
write(2, ": Permission denied\n", 20: Permission denied
)   = 20
munmap(0xb6e01000, 135168)              = 0
write(2, "Failed to mount '/dev/sda1'", 27Failed to mount '/dev/sda1') = 27
write(2, ": Permission denied\n", 20: Permission denied
)   = 20
write(2, "Please check '/dev/sda1' and the"..., 173Please check '/dev/sda1' and the ntfs-3g binary permissions,
and the mounting user ID. More explanation is provided at
http://tuxera.com/community/ntfs-3g-faq/#unprivileged
) = 173
exit_group(19)                          = ?
+++ exited with 19 +++


Thu Mar 10, 2016 10:10
Profile
NTFS-3G Lead Developer

Joined: Tue Sep 04, 2007 17:22
Posts: 1286
Post Re: RPi2: Failed to write lock '/dev/sda1': Permission denied
Hi,

Code:
open("/dev/sda1", O_RDWR|O_LARGEFILE)   = 3
fcntl64(3, F_SETLK64, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = -1 EACCES (Permission denied)

This shows that /dev/sda1 could be opened read-write, but could not be locked. Now the man page says :
Quote:
F_SETLK (struct flock *) Acquire a lock (when l_type is F_RDLCK or F_WRLCK) or release a lock (when l_type is F_UNLCK) on the bytes specified by the l_whence, l_start, and l_len fields of lock. If a conflicting lock is held by another process, this call returns -1 and sets errno to EACCES or EAGAIN.

So the EACCES error is an indication that /dev/sda1 was already locked (by another process).

Your logfile shows:
Code:
[  943.831120] sd 0:0:0:0: [sda] Attached SCSI removable disk
[  944.835368] FAT-fs (sda1): Volume was not properly unmounted. Some data may be corrupt. Please run fsck.

And this is an indication that /dev/sda1 has been tried to open as FAT. On your previous log, it was shown as tried to have been opened by a kernel ntfs driver... So what are the outputs of :
Code:
# as root, with the device plugged in :
fdisk -l /dev/sda
head -c 11 /dev/sda1 | od -t x1

Note : in both cases, the device is mentioned as not not having been properly unmounted. You should probably mount it on Windows, and unmount it properly.

Regards

Jean-Pierre

** edit **

I just see that you claim to use libfuse v3 (commit c41b1a5e7ef1c530946f7cb77dd982899f7d80db, version 3.0.0_pre0). The version of ntfs-3g you are using is not compatible with libfuse v3, but you are actually using the integrated fuse library, and not an external one :
Code:
ntfs-3g 2015.3.14 integrated FUSE 27 - Third Generation NTFS Driver
                Configuration type 1, XATTRS are on, POSIX ACLS are off


Thu Mar 10, 2016 19:58
Profile
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Original forum style by Vjacheslav Trushkin.