Linux: Cannot move folders – inter-device move failed, unable to remove target: Is a directory
by Ali on Mar.11, 2009, under Linux
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.
To the extent possible under law, the creator has waived all copyright and related or neighboring rights to this work.
13 Comments for this entry
1 Trackback or Pingback for this entry
-
Issue with "mv: inter-device move failed: "
December 4th, 2010 on 6:54 AM[…] does a copy and delete (just tested both to confirm because this is contrary to the likes of this page. The reason for the error message is probably that /home/gerard/ contains a directory called […]
June 6th, 2009 on 12:30 PM
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.
June 6th, 2009 on 12:34 PM
Exactly! I just ran into this one recently myself!
June 9th, 2009 on 4:28 PM
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.
July 22nd, 2011 on 4:32 PM
Actually sda1 and sda2 implies that both are partitions of the same disk, so that would not cause this problem 🙂
July 29th, 2011 on 10:00 AM
Good point. Changed – thanks.
November 15th, 2011 on 4:30 AM
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.
January 24th, 2012 on 10:56 AM
Make’s sense, although the error message could be a bit more descriptive.
March 10th, 2012 on 4:40 AM
cp,I get it .
May 2nd, 2012 on 4:49 PM
Great explanation. Thanks for sharing.
May 2nd, 2012 on 4:54 PM
You are very Welcome!
June 17th, 2013 on 10:34 AM
@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.
June 21st, 2013 on 12:24 AM
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.
June 22nd, 2013 on 2:26 AM
SAME PROBLEM GENTERTED IN COPY DIR TO /OPT HOW TO SOLVE