1

I need to replace a string in a file located in a CIFS mount (NTFS NAS). It is mounted with

sudo mount -t cifs -o rw,guest,vers=1.0 //192.168.1.1/hdd /hdd

I never faced this problem until a week ago, but I didn't change any mount option


If I run sed -i 's/oldstring/newstring/' /hdd/file I get

sed: preserving permissions for ‘/hdd/sedgtQccm’: Not a directory
sed: cannot rename /hdd/sedgtQccm: File exists

If I run sed 's/oldstring/newstring/' /hdd/file > /hdd/file.tmp && mv /hdd/file.tmp /hdd/file I get

mv: cannot move '/hdd/file.tmp' to '/hdd/file': File exists

If I run sed 's/oldstring/newstring/' /hdd/file > /hdd/file.tmp && rsync /hdd/file.tmp /hdd/file I get

rsync: [receiver] rename "/hdd/file.tmp.GMn4i1" -> "file": File exists (17)
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1287) [sender=3.2.2]

I get these errors if

  • both files are remote
  • file is remote and file.tmp is local

I don't get them if

  • both files are local
  • file is local and file.tmp is remote

It's also worth mentioning that if I download a large file I get

write /hdd/largefilefromweb: interrupted system call

And that if I play my music from there almost hourly I get

Encountered error while transfering /hdd/track.mp3: Read error: Interrupted system call

EDIT: A workaround to the sed, mv and rsync problem is rming the file before performing the second command:

sed 's/oldstring/newstring/' /hdd/file > /hdd/file.tmp && rm /hdd/file && mv /hdd/file.tmp /hdd/file
# instead of
sed 's/oldstring/newstring/' /hdd/file > /hdd/file.tmp && mv /hdd/file.tmp /hdd/file
2

In regards to the "File exists" issue, as mentioned in this serverfault question, I believe this is a regression in recent kernels and downgrading to 5.7.7 avoids the issue for now.

| improve this answer | |
  • I see you mention 5.4.50 as safe fallback, this machine is running on 5.4.51 at the moment, so yes, it could be. I confirm that the problem appears on another machine running 5.7.9; has this issue been reported to upstream? – Polizi8 Jul 20 at 18:38
  • Yes, the issue is reported – nogoma Jul 22 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.