2

I'm trying to rename a file using the regular mv command which has worked countless times before.

$ ls -l |grep "Picture 001"
-rwxrwxrwx 1 rolf rolf 657711 Feb 19 21:42 Picture 001_19.jpg
$ mv "Picture 001_19.jpg" "Picture 001_19_u.jpg"
mv: cannot move 'Picture 001_19.jpg' to a subdirectory of itself, 'Picture 001_19_u.jpg'

Can anyone tell me why mv suddenly refuses to rename this file?
How has mv decided that Picture 001_19_d.jpg is a directory name, and not a file name?

I tried running the same command with argument -T. From the mv manpage:

-T, --no-target-directory
      treat DEST as a normal file

The result are exactly the same.

This is confusing and frustrating!

Is it a bug?

$ mv --version
mv (GNU coreutils) 8.30

Update

It does appear to be a bug

$ echo "blah" > tt
$ mv tt tt1
mv: cannot move 'tt' to a subdirectory of itself, '../tt'
$ mv tt ../
mv: cannot move 'tt' to a subdirectory of itself, '../tt'

The problem happens when I run mv on a mounted external drive, on a writable NTFS partition.

When I copy it to my Desktop folder, which is hosted on an Ext4 partition and I try mv there, then it works without problem.

Update 2

$ sudo apt-show-versions coreutils
[sudo] password for rolf: 
coreutils:amd64/sid 8.30-2 uptodate
coreutils:i386 not installed

Indeed I seem to be running a buggy version (as per this answer).

  • 1
    I'm suspecting file system corruption. Does the problem persist if you run chkdsk (from Windows) to repair the NTFS volume? – Deltik Feb 26 '19 at 17:34
  • I started getting the same message yesterday from backup2l saving to an external drive formatted with ZFS. I don't see how it can be filesystem corruption as ZFS should detect this. – StarNamer Feb 27 '19 at 21:14
  • 1
    It's a bug. I downgraded from coreutils 8.30-2 to 8.30-1 and mv worked fine. Upgraded back to 8.30-2 and it gives the above error. Currently leaving my system on 8.30-1 and will go and see if there's a bug report. – StarNamer Feb 27 '19 at 21:36
  • 1
    @StarNamer: Yep, it's bug #923420. I've written an answer about it. – Deltik Feb 28 '19 at 15:48
1

If you are running Debian sid (unstable), there is a bug with /bin/mv from coreutils version 8.30-2.

This bug only affects Debian.[source]

On 27 February 2019, a Debian developer reported bug #923420:

coreutils: mv broken when file system doesn't support RENAME_NOREPLACE

Breakages like this are to be expected on the bleeding edge rolling release of Debian:

"sid" is subject to massive changes and in-place library updates. This can result in a very "unstable" system which contains packages that cannot be installed due to missing libraries, dependencies that cannot be fulfilled etc. Use it at your own risk!

To work around this bug, you can either:


Here's a demo demonstrating the bug on LXD with a ZFS backend:

deltik@node53 [~]$ lxc launch -s local images:debian/sid demo
Creating demo
Starting demo
root@demo:~# cat /etc/*-release
PRETTY_NAME="Debian GNU/Linux buster/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
root@demo:~# apt-cache policy coreutils
coreutils:
  Installed: 8.30-2
  Candidate: 8.30-2
  Version table:
 *** 8.30-2 500
        500 http://deb.debian.org/debian sid/main amd64 Packages
        100 /var/lib/dpkg/status
root@demo:~# df -hT
Filesystem                Type      Size  Used Avail Use% Mounted on
rpool/lxd/containers/demo zfs       379G  195M  378G   1% /
none                      tmpfs     492K     0  492K   0% /dev
udev                      devtmpfs  7.8G     0  7.8G   0% /dev/tty
tmpfs                     tmpfs     100K     0  100K   0% /dev/lxd
tmpfs                     tmpfs     100K     0  100K   0% /dev/.lxd-mounts
tmpfs                     tmpfs     7.8G     0  7.8G   0% /dev/shm
tmpfs                     tmpfs     7.8G  8.1M  7.8G   1% /run
tmpfs                     tmpfs     5.0M     0  5.0M   0% /run/lock
tmpfs                     tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
root@demo:~# echo "blah" > tt
root@demo:~# mv tt tt1
mv: cannot move 'tt' to a subdirectory of itself, 'tt1'

Additional Resources

  • Downgrading: sudo apt-get install coreutils=8.30-1 --only-upgrade and the bug is gone indeed! Apparently the bug is fixed in 8.30-3 but apparently this version is not available for Debian yet. So I'll be holding this package for now. Thanks a lot for your help. Hopefully the answer can also help someone else. – Rolf Feb 28 '19 at 21:43

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.