Skip to content

Move-Item does not work across mounts on Linux #13039

@ghost

Description

Summary

Just started using PowerShell core on Linux and its fantastic so far! I can across an interesting bug regarding the Move-Item cmdlet. If I'm on the same mount point, it works as expected but if I'm moving items from one Mount to another it errors with a cross device link error.

Copy-Item is able to copy across devices as a work around. See below for details.

Hopefully this can get fixed in the 7.1 release.

Steps to reproduce

# Note: Source and destinations must be on different mounts shown by the "df" command.
$Source=/tmp/files/*
$Destination=/etc/files/
Move-Item $Source $Destination

Expected behavior

Files are removed from the source and exist at the destiation.

Actual behavior

Red Error Message:
    Move-Item: Invalid cross-device link

Environment data

$PSVersionTable:

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Linux 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Other System Information:
Operating System: CentOS Linux release 7.8.2003 (Core)
UNAME: Linux op2-snf-ldev4.cgifederal.com 3.10.0-1127.13.1.el7.x86_64 #1 SMP Tue Jun 23 15:46:38 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux


System Mounts:
Filesystem                                Type     1K-blocks     Used Available Use% Mounted on
devtmpfs                                 devtmpfs   3987736        0   3987736   0% /dev
tmpfs                                       tmpfs      4004528        0   4004528   0% /dev/shm
tmpfs                                       tmpfs      4004528     9768   3994760   1% /run
tmpfs                                       tmpfs      4004528        0   4004528   0% /sys/fs/cgroup
/dev/mapper/centos_root       xfs        5232640   181832   5050808   4% /
/dev/mapper/centos_usr         xfs        8378368  4752188   3626180  57% /usr
/dev/sda1                                xfs        1038336   298172    740164  29% /boot
/dev/mapper/centos_tmp        xfs        8378368   183096   8195272   3% /tmp
/dev/mapper/centos_home     xfs      157209600   185644 157023956   1% /home
/dev/mapper/centos_var         xfs        8378368  3279240   5099128  40% /var
/dev/mapper/centos_opt         xfs      209612800 16759668 192853132   8% /opt
/dev/mapper/centos_var--lib  xfs        8378368   428752   7949616   6% /var/lib
tmpfs                                       tmpfs       800908       12    800896   1% /run/user/42
tmpfs                                       tmpfs       800908        0    800908   0% /run/user/1391052081

Note that LVM is used on this system, not sure if that's causing cross-device linking issues or not.

Current Work Around

I am able to Copy-Item and then Remove-Item. This only impacts Move-Item for some reason.

Copy-Item $Source $Destination -Recurse
Remove-Item $Source

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-BugIssue has been identified as a bug in the productWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions