11
Mar/09
15

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.

Creative Commons License
Linux: Cannot move folders – inter-device move failed, unable to remove target: Is a directory by Ali, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License. Terms and conditions beyond the scope of this license may be available at insanelabs.com.

Filed under: Linux
Comments (13) Trackbacks (2)
  1. Fabio Varesano
    12:30 PM on June 6th, 2009
    GranParadiso 3.0.10 GranParadiso 3.0.10 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042810 GranParadiso/3.0.10

    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. Ali
    12:34 PM on June 6th, 2009
    Firefox 3.0.10 Firefox 3.0.10 Windows 7 Windows 7
    Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10 (.NET CLR 3.5.30729)

    Exactly! I just ran into this one recently myself!

  3. Monkey
    4:28 PM on June 9th, 2009
    Firefox 3.0.10 Firefox 3.0.10 Ubuntu 9.04 Ubuntu 9.04
    Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10

    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.

  4. Neox
    4:32 PM on July 22nd, 2011
    Google Chrome 12.0.742.124 Google Chrome 12.0.742.124 GNU/Linux x64 GNU/Linux x64
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.124 Safari/534.30

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

  5. Ali
    10:00 AM on July 29th, 2011
    Firefox 5.0 Firefox 5.0 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0

    Good point. Changed – thanks.

  6. Tomas Lavicky
    4:30 AM on November 15th, 2011
    Chromium 14.0.835.202 Chromium 14.0.835.202 Ubuntu 11.04 x64 Ubuntu 11.04 x64
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.1 (KHTML, like Gecko) Ubuntu/11.04 Chromium/14.0.835.202 Chrome/14.0.835.202 Safari/535.1

    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.

  7. Nathan Friend
    10:56 AM on January 24th, 2012
    Google Chrome 16.0.912.75 Google Chrome 16.0.912.75 Mac OS X 10.7.2 Mac OS X 10.7.2
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_2) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7

    Make’s sense, although the error message could be a bit more descriptive.

  8. gjf
    4:40 AM on March 10th, 2012
    Firefox 8.0 Firefox 8.0 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20100101 Firefox/8.0

    cp,I get it .

  9. Max
    4:49 PM on May 2nd, 2012
    Firefox 12.0 Firefox 12.0 Mac OS X 10.6 Mac OS X 10.6
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:12.0) Gecko/20100101 Firefox/12.0

    Great explanation. Thanks for sharing.

  10. Ali
    4:54 PM on May 2nd, 2012
    Firefox 12.0 Firefox 12.0 Windows 7 x64 Edition Windows 7 x64 Edition
    Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20100101 Firefox/12.0

    You are very Welcome!

  11. Martin
    10:34 AM on June 17th, 2013
    Chromium 25.0.1364.160 Chromium 25.0.1364.160 Ubuntu x64 Ubuntu x64
    Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.22 (KHTML, like Gecko) Ubuntu Chromium/25.0.1364.160 Chrome/25.0.1364.160 Safari/537.22

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

  12. newbie
    12:24 AM on June 21st, 2013
    Google Chrome 27.0.1453.110 Google Chrome 27.0.1453.110 Windows 7 Windows 7
    Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.110 Safari/537.36

    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.

  13. SUSHANT
    2:26 AM on June 22nd, 2013
    Firefox 4.0.1 Firefox 4.0.1 GNU/Linux GNU/Linux
    Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20100101 Firefox/4.0.1

    SAME PROBLEM GENTERTED IN COPY DIR TO /OPT HOW TO SOLVE

Leave a comment

*