4

Ubuntu 18.04 - Installed Zsh and Oh-My-Zsh from here.

Given the following

echo '#!/bin/bash\n\nls ~;' >> myscript.sh
chmod 755 ./myscript.sh
./myscript.sh

Executed in my home folder, all goes as expected and it lists files in my home folder

output omitted for brevity -- it worked and listed files as the script intended

Executed in a secondary drive I get the output listed below (my fstab config is listed lower in this question).

╭─user@host /media/user/raw/scripts
╰─$ echo '#!/bin/bash\n\nls ~;' >> myscript.sh
╭─user@host /media/user/raw/scripts  
╰─$ chmod 755 ./myscript.sh
╭─user@host /media/user/raw/scripts  
╰─$ ./myscript.sh 
zsh: permission denied: ./myscript.sh

My /etc/fstab

╭─user@host /media/user/raw/scripts  
╰─$ cat /etc/fstab                                                                130 ↵
# /etc/fstab: static file system information.
#
# Use 'blkid' to print the universally unique identifier for a
# device; this may be used with UUID= as a more robust way to name devices
# that works even if disks are added and removed. See fstab(5).
#
# <file system> <mount point>   <type>  <options>       <dump>  <pass>
# / was on /dev/sdb2 during installation
UUID=<<some_uuid>> /               ext4    errors=remount-ro 0       1
# /boot/efi was on /dev/sdb1 during installation
UUID=<<some_uuid>>  /boot/efi       vfat    umask=0077      0       1
/swapfile                                 none            swap    sw              0       0
/dev/disk/by-uuid/<<some_uuid>> /media/user/raw auto user,rw,nofail,x-gvfs-show 0 0

Since this executes fine in my home folder and not on this mounted drive, I'm thinking the issue is somewhere within the fstab configuration. Any ideas?

2

1 Answer 1

8

You are implicitly specifying noexec, which means that no files on the device will be executable.

Here's man mount:

user

Allow an ordinary user to mount the filesystem. The name of the mounting user is written to the mtab file (or to the private libmount file in /run/mount on systems without a regular mtab) so that this same user can unmount the filesystem again. This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid).

The same paragraph also suggests the fix: use the user,exec to re-enable execution in a user mountable fs.

3
  • You're right. That was the problem. I read the man page too, but stopped at "Allow an ordinary user to mount the filesystem", not realizing user was a macro option. Thanks for your help @that other guy!
    – rogodeter
    Commented Jul 8, 2018 at 17:49
  • Can you provide any more detail? I can't execute in a mounted drive, but I don't understand how to go about changing the user,exec flags... Commented Apr 10, 2022 at 21:40
  • OP had declared the mount and options in /etc/fstab so that's where they'd change it Commented Apr 10, 2022 at 22:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.