Re: mount: Operation not permitted
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Nov 2021 03:28:39 UTC
In message <1f564e86-1441-10b3-06f8-96086d74f4c9@holgerdanske.com>, you wrote: >On 11/29/21 1:33 PM, Ronald F. Guilmette wrote: >> I have a shell script that uses rsync to make backups of all of the >> several partitions on my main drive to a second removable drive. >> The script goes one-by-one through the partitions, mounting each >> corresponding backup partition in turn, running rsync, and then >> umount'ing that backup partition. >> >> Mostly this script works well, but every so often, seemingly at random, the >> mount command for one or more of the backup partitions fails for no apparently >> good reason, and I get the message "mount: Operation not permitted". If I >> retry the same thing a little later it invariably works. >> >> What am I doing wrong and how can I fix it? > > >rsync(1) and mount(8) are designed to work with filesystems, not partitions. Yes, I know that. Excuse me if I have used the terms "partition" interchangeably with "filesystem" in this instance, because in this case there is a one-to-one mapping... each filesystem that I need to mount and/or back up is on one partition. >Assuming your script goes one-by-one through the filesystems, perhaps a >newly mounted filesystem is not quite ready when rsync(1) is invoked. I >would try adding a time delay (e.g. 'sleep 10') before invoking rsync(1). The problem is *not* arising in rsync. As I said, the problem is that sometimes, after one or more partitions/filesystems have already been backed up successfully by my script, the next following mount operation will fail with the rather entirely cryptic message "Operation not permitted". Sigh. I guess that I may have to hack the source code for the mount command myself and get it to add some more context whenever it is about to issue an "Operation not permitted" error message. I'm pretty damn sure that this isn't a permissions problem. Otherwise the error(s) would not simply (and magically) go away when I retry the mount/rsync/umount just a short time later. So "Operation not permitted" is just not a helpful message at all. Regards, rfg P.S. Apparently the text "Operation not permitted" corresponds to EPERM which a syscall to mount(2) can in fact produce, however on the man page for mount(2) in the ERRORS section it just says: [EPERM] The caller is neither the super-user nor the owner of dir. But I am always doing this as root, AND the specific directory paths onto which the script mounts the backup filesystems are all pre-existing/pre-created AND they are all owned by root. (I just now triple checked that.) So none of this really makes such sense.