I want to write an image with raspistill (or video with raspivid) to a folder on an usb drive, but get an error.

I connected my usb drive and found the storage location with sudo blkid: /dev/sda1. To auto mount it at startup I edited the "fstab" file: sudo nano /etc/fstab and added the line /dev/sda1 /mnt vfat defaults 0 0. Just in case I set the proper permissions sudo chmod 775 /mnt. I then rebooted the pi and created a folder sudo mkdir /mnt/images.

Now to create an image I go raspistill -q 90 -t 1000 -o /mnt/images/test.jpg but get the following error:

mmal: main: Error opening output file: /mnt/images/test.jpg~
No output file will be generated

I don't understand what I am doing wrong as writing an image in the home directory works raspistill -q 90 -t 1000 -o test.jpg

  • what do you get if you run "touch /mnt/images/test.jpg"? does the empty file get created successfully?
    – rob
    Commented Nov 13, 2014 at 10:51
  • It says "permission denied". However, I thought I set the right permissions with sudo chmod 775 /mnt?. ps: I am able to copy files to the folder, e.g. cp test.jpg /mnt/images/test.jpg works
    – crazjo
    Commented Nov 13, 2014 at 11:04

1 Answer 1


I suspect your issue is that you are mounting the vfat filesystem so that it is only accessible to the root user.

The vfat filesystem (being a very simple filesystem dating from the ancient days of DOS) has no concept of users and groups, but all files in UNIX systems must have an owner and group. To work around this, the Linux vfat driver defaults to making all directories and files on a mounted vfat filesystem owned by root (with group root). Mode 775 (which you set on the mount-point after mounting the partition) means that it should be writeable by the owner (in this case root) and by members of the group (also root), but not by "others" ... including your unprivileged pi user (which I assume you're logged on as).

Hence, running raspistill -q 90 -t 1000 -o /mnt/images/test.jpg fails, but I'd bet that running sudo raspistill -q 90 -t 1000 -o /mnt/images/test.jpg will work just fine (because root can write to /mnt/images but pi can't). You can also confirm this by running ls -ld /mnt which will probably show something like the following:

drwxrwxr-x 2 root root 4096 Apr 30  2014 /mnt

A better solution that running everything with sudo would be to mount the partition so that all the files and directories on it appear to be owned by the pi user. This can be accomplished quite easily by tweaking your /etc/fstab entry. Just change the defaults item to uid=pi,gid=pi and reboot. In other words, the line should look like this afterward:

/dev/sda1 /mnt vfat uid=pi,gid=pi 0 0

Once you've rebooted you should find that ls -ld /mnt shows something like this instead:

drwxr-xr-x 2 pi pi 4096 Apr 30  2014 /mnt

At this point, your raspistill command should work without sudo.

  • You were exactly right. It indeed worked with sudo and changing the /etc/fstab entry did the trick after reboot. Thanks again!
    – crazjo
    Commented Nov 13, 2014 at 13:15
  • ps: would it be possible to write images to a network (NAS) drive and if so how? I can't find this information anywhere.
    – crazjo
    Commented Nov 13, 2014 at 18:58
  • @JolJols - certainly! If your NAS supports Windows file shares, have a look at this question for information on mounting CIFS shares (CIFS is the protocol used by Windows file sharing). Alternatively if it supports NFS (generally preferable but not as widely supported), take a look at this question
    – Dave Jones
    Commented Nov 13, 2014 at 20:36

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.