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
    Please put some effort into making your question readable. Your spelling, grammar, and formatting could all use an overhaul. – Jacobm001 Mar 23 '16 at 17:17
  • wait... Android doesn't read ext4? o.O maybe ext3 would work... – rav_kr Mar 23 '16 at 21:30
  • If I plug my other USB stick (ext4) I can't see what's in directory. I saw that there are some ways to mount ext4 partition, but that need ROOT and I don't want this dependence. – musr Mar 24 '16 at 07:37
  • This is not intended to be an answer. I'm a new user so I can't post comments in stackexchange; I hope that this can help. I only want to say that my Raspberry PI (with jessie) has Transmission downloading torrents files to a VFAT USB Drive that is automatically mounted on startup... I can mv and cp files from /home/pi/ to the usb device, without problems. The USB is mounted this way: /dev/sda1 on /media/pi/6C6F-F92A type vfat (rw,nosuid,nodev,relatime, uid=1000,gid=1000,fmask=0022,dmask=0077,codepage=437,iocharset=ascii,shortname=mixed,showexec,utf8,flush,errors=remount-ro,uhelper=udisks2) No – mguima Mar 24 '16 at 00:58
  • @mguima

    Hi, can you tell me the line you added on fstab or what exactly is your command line for manual mounting your USB drive ? Also, I didn't understand if you did something with pi user because on my RPi 2 ( also jessie ), my pi is a regular user and on /media I just made a directory (usb) and I mounted the /dev/sda1 to /media/usb

    – musr Mar 24 '16 at 10:34

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