WSL icon indicating copy to clipboard operation
WSL copied to clipboard

mv cannot move files between Windows mount and linux file system

Open mphaney opened this issue 10 years ago • 7 comments

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

mphaney avatar Apr 07 '16 16:04 mphaney

Look at it as different environments. You will never touch /mnt/c/ as you will never mount any files on / /mnt or other letters

jolibert avatar Apr 07 '16 17:04 jolibert

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.

mphaney avatar Apr 07 '16 17:04 mphaney

Yeah, I can confirm for @mphaney's thought process. You can also touch files in /mnt/c/

crutchcorn avatar Apr 07 '16 19:04 crutchcorn

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...

jbaribeault avatar Apr 07 '16 20:04 jbaribeault

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.

jolibert avatar Apr 07 '16 21:04 jolibert

And I know hundreds to hack a developer, trust me, my job

jolibert avatar Apr 07 '16 21:04 jolibert

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.

dethoma avatar Apr 08 '16 01:04 dethoma