Unix & Linux Asked on October 30, 2021
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
I don’t get them if
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 rm
ing 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
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.
Answered by nogoma on October 30, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP