Instead of checking device ids, try rename first and in case of EXDEV, fallback to copy. From rename(2) on Linux: Linux permits a file system to be mounted at multiple points, but rename() does not work across different mount points, even if the same file system is mounted on both.