How do I execute a file from a FAT USB drive?

Because of limitations of the FA32 file system, you can't.

Now, you can cheat:

  1. either call sh etoys.sh instead of ./etoys.sh
  2. if you want, you can even create another script (that would lie on your hard drive, for example) that simply calls your script on the USB drive:

    #!/bin/bash
    sh /media/USB/etoys.sh
    

Mounting the device with -o mode=<value> should work

mode=value

Set the mode of all files to value & 0777 disregarding the original permissions. Add search permission to directories that have read permission. The value is given in octal.


I actually found a great solution at http://ubuntuforums.org/showthread.php?t=1665289 that fixed the problem.

Basically, it says to run the command

sudo sed -i -e 's|showexec|\x00\x00\x00\x00\x00\x00\x00\x00|g' /usr/lib/udisks/udisks-daemon

and that will prevent disks from auto-mounting with the showexec option.

I don't like to answer my own question, but this worked for me and I hope it helps other people too.

for ubuntu 18.04:

sudo sed -i -e 's|showexec|\x00\x00\x00\x00\x00\x00\x00\x00|g' /usr/lib/udisks2/udisksd