mv cannot move files between Windows mount and linux file system
Moving a file (with mv) within the Windows file system or within the Linux file system works exactly as it should, but moving between the two file systems yields the error:
mv: cannot move 'filename' to a subdirectory of itself, '/destination/filename'
Here is a complete test scenario:
root@localhost:~# cd /mnt/c/Users/Mark/
root@localhost:/mnt/c/Users/Mark# echo test > testfile
root@localhost:/mnt/c/Users/Mark# mkdir windir
root@localhost:/mnt/c/Users/Mark# mv testfile windir/
root@localhost:/mnt/c/Users/Mark# mv windir/testfile .
root@localhost:/mnt/c/Users/Mark# mv testfile /root/
mv: cannot move ‘testfile’ to a subdirectory of itself, ‘/root/testfile’
root@localhost:/mnt/c/Users/Mark# cp testfile /root/
root@localhost:/mnt/c/Users/Mark# rm testfile
root@localhost:/mnt/c/Users/Mark# cd /root
root@localhost:~# mkdir linuxdir
root@localhost:~# mv testfile linuxdir/
root@localhost:~# mv linuxdir/testfile .
root@localhost:~# mv testfile /mnt/c/Users/Mark/
mv: cannot move ‘testfile’ to a subdirectory of itself, ‘/mnt/c/Users/Mark/testfile’
root@localhost:~# cp testfile /mnt/c/Users/Mark/
root@localhost:~# rm testfile
Look at it as different environments. You will never touch /mnt/c/ as you will never mount any files on / /mnt or other letters
Well, they most certainly are different environments, no question, but if I can copy from one to the other, edit Windows files from within the Linux environment, create and remove Windows files from within the Linux environment...kinda seems like move should work too, and yet it fails.
As a side note I believe the assertion that one would never touch /mnt/c/ is incorrect. The whole point of giving Windows developers Bash was so it could work harmoniously with their Windows environment, not as a completely separate system.
Yeah, I can confirm for @mphaney's thought process. You can also touch files in /mnt/c/
Same happens in /root for say, CPAN....it unzips the files in /root/.cpan, then can't move the directory to a build directory under /root/.cpan - insufficient permissions. Yet looking at ls output, things are fine...
Just put actions on /root as UAC actions on that mini kernel. The idea is to put developers in it, nil hackers. If developers got hacked, their choice to put the environment in sensitive areas.
And I know hundreds to hack a developer, trust me, my job
Thanks for reporting this issue. We were returning ENOENT instead of EXDEV for the rename syscall. When that is addressed mv will switch to "copy then remove original" behavior.