Linux: Cannot move folders – inter-device move failed, unable to remove target: Is a directory

This is somewhat simple as long as we understand the concept. mv or move does not actually move the file/folder to another location within the same device, it merely replaces the pointer in the first sector of your device. The pointer (in inode table) will be moved, but nothing is actually being copied. This will work as long as you stay within the same media/device.

Now, when you try to move files from one device to another (/dev/sda1 to /dev/sdb1) you will run into “inter-device move failed, unable to remove target: Is a directory” error. This happens when mv has to actually move your data to another device, but cannot remove the inode/pointer, because if it did then there will be no data to fall back to, and if it didn’t then mv operation is not really complete because we will end up with data in source. Damned if you do and damned if you don’t, so it’s wise not to do it to begin with!

In such situation cp is best. Copy your data over and then remove your source manually.

CC0 1.0
To the extent possible under law, the creator has waived all copyright and related or neighboring rights to this work.

15 thoughts on “Linux: Cannot move folders – inter-device move failed, unable to remove target: Is a directory

  1. Fabio Varesano says:

    Ohh.. this is really new to me!
    I used Linux every day the last 5 years, I almost have a MS in Computer Science but I never faced this peculiar behavior of mv.

    Life is a never-ending lesson.

    Thanks for sharing this.

  2. Monkey says:

    I have scripts using mv I received that same error and added the -b [backup] flag. Works much better now. I hope this helps someone.

  3. Tomas Lavicky says:

    I’ve met this problem for the first time after 10+ years of everyday using Linux. Strange thing – it appeared on only one of moved directories. “mv -b” works of course but it takes much more time and sources.

  4. Martin says:

    @Neox

    > Actually sda1 and sda2 implies that both are partitions of the same disk, so that would not cause this problem

    You are wrong. sda1 and sda2 would contain different filesystems, to mv would still do an inter-device move.

  5. newbie says:

    Thank you for your explanation, but I don’t follow this: “This happens when mv has to actually move your data to another device, but cannot remove the inode/pointer, because if it did then there will be no data to fall back to, and if it didn’t then mv operation is not really complete because we will end up with data in source.” What confuses me is the sentence “because if it did then there will be no data to fall back to”. Can you make an example in more details? Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *


eight − = 3

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>