2

My application need to save some files from /home/pi/dir to /media/usb which is my USB stick 32 GB vfat formatted.

When I try: mv /home/pi/dir/* /media/usb/dir/ it gives me this error :

cp: cannot create regular file ‘file’: Invalid argument " .

I tried mounting the USB Stick either manual, either with fstab, with the following lines added (of course, one at a time and the end of file) :

  • /dev/sda1 /media/usb vfat umask=000 0 0
  • /dev/sda1 /media/usb vfat rw 0 3
  • /dev/sda1 /media/usb vfat defaults,uid=65534,gid=65534,dmask=000,fmask=111 0 0
  • UUID=AD4D-8211 /media/usb vfat auto,users,rw,uid=pi,gid=pi 0 0

Neither works for me.

I have success with another ext4 formatted USB Stick with fstab edited: - /dev/sda1 /media/usb ext4 rw 0 3

After many hours of research I return to the conclusion (Transmission: permission denied on USB disk) that vfat do not support the per-user/group permissions and the problem is is FAT filesystem.

I need to save some output from an application to a USB stick and from there the user should read it on Android device. And ... because Android doesn't know to read by default ext4 formatted USB memory, I must accomplish vfat portability.

What am I doing wrong to copy or move some file from Raspberry Pi 2 to USB Stick (FAT32) ?

RPImaniac
  • 190
  • 1
  • 3
  • 17
musr
  • 21
  • 1
  • 7

1 Answers1

0

Yes, that could be a partial answer but this is my solution to avoid cp: cannot create regular file ‘file’: Invalid argument " .

This FAT32 (vfat) partition, that is a standard format partition for at least USB/SD memory card, is so annoying but the subject is still ambiguous to me.

After some research I conclude that the problem is that linux cannot set permissions to vfat !

But ... there is a solution ... or at least for me this one worked for me.

Still, the USB memory was mounted before but that I found to be the piece that solved my little puzzle.

I edited the fstab config with /dev/sda1 /media/usb vfat uid=1000,gid=1000,umask=000 0 0 but worked with either /dev/sda1 /media/usb vfat uid=1000,gid=100,rw,umask=002 1 0 .

Now, this one could be silly but i was delighted (:

This time I made some changes in my bash script that change the output file name. I was interested to make the output file name to show date and time.

So, let's say that the file name was 24-03-16@10:30:56.log when I tried to cp/mv /home/pi/dir/* /media/usb/dir/ the above error came. I even tried with a specific file to copy or move but I haven't success. Because of my limitation, I event try to first touch to /media/usb/dir/$(ls /home/pi/dir/ | tail -1 | cut -c1-21) but still no success.

Eventually, on my pipeline I tried to cut something below 21 characters ...about 9 I guess and that was a relief because I could escape from that error.

I changed the output file name to be like 24-03-16@13-05-43.log and it works.

It's hard to digest the fact that changing the : with - let me copy or move files from RPi to FAT32 but it works.

I was inspired in my research from barracudadrive, ubuntu.com/community/Fstab , elinux.org/RPi_Tutorials, raspberrywebserver.com/serveradmin/connect-your-raspberry-pi-to-a-USB-hard-disk.html , raspberrypi-spy.co.uk/2014/05/how-to-mount-a-usb-flash-disk-on-the-raspberry-pi/ , devtidbits.com/2013/03/21/using-usb-external-hard-disk-flash-drives-with-to-your-raspberry-pi/ and other sources.

musr
  • 21
  • 1
  • 7