Support Questions

Find answers, ask questions, and share your expertise

Unable to over write file with cp command through NFS Gateway into HDFS.


I am trying to over write the file with cp command and it failed with below error.

cp: cannot create regular file "filename" : Invalid argument

i checked the error log and got the below error.

ERROR nfs3.RpcProgramNfs3 ( - Setting file size is not supported when setattr, fileId: 18463

Can some one Help me with it.

Thanks in Advance.



Hi, cp is working with the option "-f". But when i try with python it is failing with below error.

IOError: [Errno 22] invalid mode ('wb+') or filename: '/file_path/testWrite.txt'

Can some one help with it.


Hi Paramesh,what is the python code you are using.


Hi Selavan,

First of all thanks for your reply. I used below code with the python write mode of w,w+ and wb+.

open_file = open("/hdfs_nfs/hdfs_Data/sampledata/testWrite.txt", 'wb+')
open_file.write("This is just a sample data")

The file "testWrite.txt" is getting created in given path (HDFS Mount point) when I run this for first time.

I am getting below error, when I execute above code from second time onwards.

IOError: [Errno 22] invalid mode ('wb+') or filename: '/hdfs_nfs/hdfs_Data/sampledata/testWrite.txt'


@Paramesh malla, Is testWrite.txt file present on HDFS while running test code second time ? If yes, please delete /hdfs_nfs/hdfs_data/sampledata/testWrite.txt and rerun.

HDFS only supports append, so if you intend to append data after file creation, use 'a' option.

with open(filename,'a')as f:

Super Guru
@Paramesh malla

You need to overwrite file with python(like cp -f) in order to get it working.

Please refer below link:

Hope this helps.


Hi Kuldeep,

Thanks for the reply. I tried the method that was mentioned on above given link. still it is not working.

I am getting below error.

Traceback (most recent call last):
  File "", line 7, in <module>
IOError: [Errno 22] Invalid argument.
Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.