Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does rename() return false despite moving a file successully to an NFS mounted disk?

I'm getting an Invalid argument warning when moving a file from a local disk to an NFS mounted disk. The file is moved successfully despite the error message:

Warning: rename(/tmp/image.jpg,/mnt/remote.server-disk1/image.jpg): Invalid argument

The mounted disk:

$ df
remote.server:/disk1 917G  269M  871G   1% /mnt/remote.server-disk1

The exported disk on the remote server:

$ cat /etc/exports
/disk1 remote.server(rw,sync,root_squash,secure,crossmnt,anonuid=504,anongid=504)

The file on the local disk before rename():

$ stat /tmp/image.jpg
File: `image.jpg'
Size: 2105          Blocks: 8          IO Block: 4096   regular file
Device: 803h/2051d  Inode: 33556339    Links: 1
Access: (0777/-rwxrwxrwx)  Uid: (  501/  apache)   Gid: (  501/  apache)
...

The file on the remote disk after rename():

$ stat /disk1/image.jpg
File: `image.jpg'
Size: 2105          Blocks: 8          IO Block: 4096   regular file
Device: 821h/2081d  Inode: 34603214    Links: 1
Access: (0777/-rwxrwxrwx)  Uid: (  501/  apache)   Gid: (  501/  apache)
...

Any ideas? Thanks

like image 899
Tom Avatar asked Nov 10 '13 20:11

Tom


1 Answers

In Unix you can't rename or move between filesystems, Instead you must copy the file from one source location to the destination location, then delete the source. This will explain the error message you're getting. However, it seems unclear as why it still does the move. This could be related to permissions or the NFS mounted disk is locally cached.

like image 193
But I'm Not A Wrapper Class Avatar answered Sep 30 '22 02:09

But I'm Not A Wrapper Class