for-win icon indicating copy to clipboard operation
for-win copied to clipboard

WSL 2 disk image cannot be moved to a different drive

Open rdicroce opened this issue 3 years ago • 15 comments

  • [x] I have tried with the latest version of Docker Desktop
  • [ ] I have tried disabling enabled experimental features
  • [x] I have uploaded Diagnostics
  • Diagnostics ID: BE7C0EE9-BDCD-4944-9FE7-288AF3A9CF9D/20230301151135

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

  • Windows Version: 10 Pro 22H2
  • Docker Desktop Version: 4.17.0
  • WSL2 or Hyper-V backend? WSL2
  • Are you running inside a virtualized Windows e.g. on a cloud server or a VM: No

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 https://github.com/docker/roadmap/issues/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.

rdicroce avatar Mar 01 '23 15:03 rdicroce

Same issue as above. "Settings > Resources > Advanced - Disk image location" resets back to default after it's changed and doesn't actually change the image location.

Also on Windows 10, Docker Desktop 4.17.0 (99724), WSL2

GitHubGuy89 avatar Mar 12 '23 13:03 GitHubGuy89

Same issue Windows 10

crisguille avatar Mar 12 '23 23:03 crisguille

Also same issue, in settings I change it and it looks fine. but never uses the listed path. Ive tried the whole Shutdown WSL and unregister then reimport. still doesnt stick.

Updated: actually it did work changes from unregistering and reimporting, it just still cant show any update in the UI.

LastAi avatar Mar 16 '23 00:03 LastAi

The same issue: Windows Version: 10 Pro 22H2 19045.2728 Docker Desktop Version: 4.17.0

PunKHS avatar Mar 16 '23 21:03 PunKHS

Same here Windows 10 Entreprise 22H2 19045.2788 Docker Desktop Version: 4.17.1

tazorax avatar Apr 03 '23 12:04 tazorax

Same here with: Docker Desktop 4.18.0 Windows 10 Enterprise 22H2 19045.2728

Log file excerpt: `[2023-04-05T19:31:41.917478800Z][com.docker.backend.exe][I] moving WSL data disk from "" to "D:\ddd\DockerDesktopWSL" [2023-04-05T19:31:41.921106100Z][com.docker.backend.exe][W] failed to rename, use copy: rename \AppData\Local\Docker\wsl\data\ext4.vhdx D:\ddd\DockerDesktopWSL\ext4.vhdx: The system cannot move the file to a different disk drive. [2023-04-05T19:31:41.925097900Z][com.docker.backend.exe][I] setting auto start false [2023-04-05T19:31:41.928441000Z][com.docker.backend.exe][I] settings write: {"acceptCanaryUpdates":false,"activeOrganizationName":"","allowExperimentalFeatures":true,"analyticsEnabled":false,"autoDownloadUpdates":false,"autoStart":false,"containerTerminal":"integrated","cpus":4,"credentialHelper":"docker-credential-wincred.exe","customWslDistroDir":"","dataFolder":"C:\ProgramData\DockerDesktop\vm-data","deprecatedCgroupv1":false,"disableHardwareAcceleration":false,"disableTips":true,"disableUpdate":false,"diskSizeMiB":65536,"diskTRIM":true,"displayRestartDialog":true,"displaySwitchWinLinContainers":false,"displayed18362Deprecation":false,"displayedElectronPopup":[],"displayedWelcomeSurvey":true,"dockerBinInstallPath":"system","enableDefaultDockerSocket":true,"enableIntegrationWithDefaultWslDistro":true,"enableSegmentDebug":false,"enhancedContainerIsolation":false,"exposeDockerAPIOnTCP2375":false,"extensionsEnabled":true,"filesharingDirectories":[],"integratedWslDistros":[],"kubernetesEnabled":false,"kubernetesInitialInstallPerformed":true,"lastLoginDate":0,"latestBannerKey":"","licenseTermsVersion":2,"lifecycleTimeoutSeconds":600,"memoryMiB":2048,"noWindowsContainers":false,"onlyMarketplaceExtensions":false,"openUIOnStartupDisabled":true,"overrideProxyExclude":"","overrideProxyHttp":"","overrideProxyHttps":"","proxyHttpMode":"s...m","requireVmnetd":false,"settingsVersion":26,"showArtifactoryTab":true,"showExtensionsSystemContainers":false,"showKubernetesSystemContainers":true,"showMacInstall":false,"skipUpdateToWSLPrompt":true,"skipWSLMountPerfWarning":false,"socksProxyPort":0,"swapMiB":1024,"swarmFederationExplicitlyLoggedOut":false,"themeSource":"system","tipLastId":"float64","tipLastViewedTime":1670936105433,"updateAvailableTime":0,"updateHostsFile":false,"updateInstallTime":0,"useBackgroundIndexing":false,"useContainerdSnapshotter":false,"useCredentialHelper":true,"useGrpcfuse":true,"useNightlyBuildUpdates":false,"useVirtualizationFramework":false,"useVirtualizationFrameworkRosetta":false,"useVirtualizationFrameworkVirtioFS":false,"useVpnkit":true,"useWindowsContainers":false,"vpnKitMaxPortIdleTime":"float64","vpnKitTransparentProxy":true,"vpnkitCIDR":"1...4","wslEnableGrpcfuse":false,"wslEngineEnabled":true} [2023-04-05T19:31:41.931394200Z][com.docker.backend.exe][E] restarting VM with callback: callback on restart: 1 error occurred: * failed to move WSL data disk: writing file: cannot write data to tempfile "D:\ddd\DockerDesktopWSL\ext4.vhdx544156813": read \AppData\Local\Docker\wsl\data\ext4.vhdx: file already closed

[common/cmd/com.docker.backend/internal/handlers.(*AppHandler).DoApply.func1() [ common/cmd/com.docker.backend/internal/handlers/app.go:150 +0xf6 [common/cmd/com.docker.backend/internal/handlers.(*AppHandler).DoApply [ common/cmd/com.docker.backend/internal/handlers/app.go:148 +0x4aa`

Thx

fbence avatar Apr 05 '23 20:04 fbence

Hi folks, thanks for raising and apologies that this isn't working. We'll look at this during planning early next week and I'll provide an update shortly thereafter.

christophermclellan avatar Apr 21 '23 15:04 christophermclellan

This is infuriating. The app is hardcoded to look in an arbitrary folder rather than the folder I provide. Screenshot 2023-05-03 053645

LevyBytes avatar May 03 '23 12:05 LevyBytes

Hi, There was indeed a bug when moving the WSL data folder to another disk, thanks for the detailed report. This has been fixed and should be published in next release.

elapuyade avatar May 11 '23 13:05 elapuyade

Closing this issue because a fix has been released in Docker Desktop 4.20. See the release notes for more details.

lorenrh avatar May 30 '23 16:05 lorenrh

Cannot change the data location to another disk.

Docker version 4.34.2 (the latest as of Sept. 21, 2024)

Docker Desktop - Settings not applied An error occurred while applying the "Disk image location" setting. The previous value has been restored.

failed to move WSL disk: moving disk file: rename C:\Users\XXXXXX\AppData\Local\Docker\wsl\disk\docker_data.vhdx D:\docker_storage\DockerDesktopWSL\disk\docker_data.vhdx: The process cannot access the file because it is being used by another process.

Diagnostics ID:

BCFA9071-6E10-4653-8ABC-9EA2CD6F7A30/20240921165450

Edition Windows 10 Pro Version 22H2 Installed on ‎6/‎29/‎2024 OS build 19045.4894 Experience Windows Feature Experience Pack 1000.19060.1000.0

SergueyT avatar Sep 21 '24 17:09 SergueyT

Cannot change the data location to another disk.

Docker version 4.34.2 (the latest as of Sept. 21, 2024)

Docker Desktop - Settings not applied An error occurred while applying the "Disk image location" setting. The previous value has been restored.

failed to move WSL disk: moving disk file: rename C:\Users\XXXXXX\AppData\Local\Docker\wsl\disk\docker_data.vhdx D:\docker_storage\DockerDesktopWSL\disk\docker_data.vhdx: The process cannot access the file because it is being used by another process.

Diagnostics ID:

BCFA9071-6E10-4653-8ABC-9EA2CD6F7A30/20240921165450

Edition Windows 10 Pro Version 22H2 Installed on ‎6/‎29/‎2024 OS build 19045.4894 Experience Windows Feature Experience Pack 1000.19060.1000.0

Same issue, same env.

Irunfold avatar Oct 17 '24 13:10 Irunfold

Hi!

Having the same issue. So, please, reopen and fix the issue. OS: Windows 11 Pro. Build 26100.2894 Docker Desktop version: 4.37.1

Steps:

  • open Docker Desktop UI
  • open Settings > Resources
  • click Browse and select new location on the disk D for disk image
  • click Apply & restart
  • receive notification that it may take time, agree to move
  • no restart happens, button changes to Apply
  • press Apply, the same notification about moving appears
  • agree second time, after few seconds an error appears:

Image

Glad to provide more details if required.

BLukash avatar Jan 29 '25 10:01 BLukash

Still cannot move. This is such a basic must have thing and which is not working.

Docker Version: Docker version 28.1.1, build 4eba377

Windows 11.

C:\Users\xyz>wsl -l -v
  NAME              STATE           VERSION
* Ubuntu-24.04      Stopped         2
  docker-desktop    Stopped         2

Additonally, I cannot see the docker-desktop-data

sahilr2050 avatar May 12 '25 06:05 sahilr2050

same here. docker desktop for windows v4.52.0

eric-gitta-moore avatar Nov 24 '25 17:11 eric-gitta-moore