Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm trying to install a portable app onto my USB drive such that it is compatible with both Ubuntu and Windows (specifically, a program called eToys). Support is already built into the app for both operating systems - there's etoys.sh for Ubuntu and etoys.exe for Windows. I decided to install onto a FAT drive since that can be read from both systems. This works fine for Windows, but for some reason I cannot execute etoys.sh on Ubuntu.

The problem is not with the file - when the whole folder is copied to the local hard drive, the app works great in Ubuntu. But when I try to execute it from the USB, it opens the file in a text editor.

I then tried to run it from a terminal, but I got the message Permission denied.

I've had the same problem with other executables as well.

Is there an easy way to execute things from a USB stick?

share|improve this question
1  
Related question here: askubuntu.com/questions/23108/… –  luri Jan 25 '11 at 0:31
add comment

6 Answers

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
    
share|improve this answer
    
Thanks much! The second cheat is certainly an option, and I'll keep that in mind. Alternately, is there another file system I could use that would work with both Windows and Ubuntu and let me execute files? –  Derek Redfern Jan 25 '11 at 2:01
    
You could use ext2 or ext3, but you need to install a small utility on Windows to get it working. –  lmontrieux Jan 25 '11 at 10:52
    
One more question about this - I decided to go with the option of creating a script on the hard drive and it works great. But I also want to have scripts for programs that are not .sh files - for example, Portable Chromium, which is type "executable (application/x-executable)". Using sh doesn't work, and ./Chromium still gives permission denied. Is there another command to use for this? –  Derek Redfern Jan 26 '11 at 16:42
    
Humm, I guess you could just cheat: before executing chromium, you can chmod it to make it executable. Since the chmod command will be called every time, it doesn't matter anymore that the permissions are not carried on the next time you insert the USB drive –  lmontrieux Jan 26 '11 at 16:54
    
I thought you couldn't chmod on FAT at all though since it doesn't support Unix permissions. –  Derek Redfern Jan 26 '11 at 17:08
show 3 more comments

Mounting the device with -o mode= should work

mode=value

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

share|improve this answer
1  
Should I set this in fstab? –  Derek Redfern Jan 26 '11 at 2:24
add comment
up vote 6 down vote accepted

Hey all - Thanks for all of your responses! 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.

share|improve this answer
    
If this is what fixed your problem then mark it as the accepted answer! –  Jorge Castro Feb 2 '11 at 16:49
add comment

Ultimately, the issue seems to be that udisks mounts the filesystem with the showexec option, preventing any file that don't end in .exe, .bat, or .com to be run.

A related question (how to give custom mount options to udisks) can be found here: How to configure to record data to pendrive instantly? Turns out that you can use udev configuration to do that.

Is setting default mount options for udisks really not possible? proposes another solution based on udisks-glue, but it seems less convincing, as it ultimately rely on udisks, so that it seems that you can add options, but not remove them, and in particular showexec is still there).

In any case, I tend to prefer that to patching a binary file.

share|improve this answer
add comment

None of the solutions shown worked as far as I could tell to get a program I wrote as a Linux terminal program to run in my FAT32 partition, but changing the filename of the program to include .exe extension did work (thanks for the tip), all I did was rename filename to filename.exe for the terminal program I was trying to execute on a FAT32 partition, and then un-mount it, re-mount it and set the disk permissions to allow execution, then go to filename.exe and set its permissions and then the check mark would stick rather than turn back to a minus, and when I set the path and entered ./filename.exe at the terminal prompt the program ran as it should and shows the command line including filename.exe as entered, although the Ubuntu file directory shows the file as MSDOS/Windows it does run as a Linux program.

share|improve this answer
add comment

So I found a much simpler (and safer solution).

Use gparted to format the USB FAT32 and then us Partition=>Manage Flags to set the following flags: boot, lba

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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