WSL 2 disk image cannot be moved to a different drive · Issue #13269 · docker/for-win (original) (raw)

Actual behavior

WSL 2 disk image cannot be moved to a different drive.

Expected behavior

WSL 2 disk image can be moved to a different drive.

Information

In Settings -> Resources -> Advanced, the disk image location lets you choose where to store the WSL 2 image. I was excited about this since it looked like it would resolve docker/roadmap#239. I tried to move my image from my C drive to my much larger D drive. It appeared to work, but then I noticed the directory I chose on the D drive was still empty.

So I went back in and looked at the setting again. It had reverted back to its original value. I tried changing it again, and it still didn't work. I exited the settings window and re-opened it. The original value was back.

A peek in the log file suggests that the cause is that Docker is attempting to simply rename the file, which does not work if the destination is on a different drive:

[2023-03-01T14:54:44.028780800Z][com.docker.backend.exe][W] failed to rename, use copy: rename <HOME>\AppData\Local\Docker\wsl\data\ext4.vhdx D:\Docker\wsl\DockerDesktopWSL\ext4.vhdx: The system cannot move the file to a different disk drive.

Output of & "C:\Program Files\Docker\Docker\resources\com.docker.diagnose.exe" check

Steps to reproduce the behavior

  1. Have the disk image in a directory on drive C.
  2. Open Settings -> Resources -> Advanced.
  3. Attempt to change the Disk image location to a directory on drive D.