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

cannot change image directory

Open leechor opened this issue 3 years ago • 20 comments

log: [2023-04-12T06:31:37.910746600Z][com.docker.backend.exe][I] moving WSL data disk from "" to "F:\docker_image\DockerDesktopWSL" [2023-04-12T06:31:37.911796400Z][com.docker.backend.exe][W] failed to rename, use copy: rename \AppData\Local\Docker\wsl\data\ext4.vhdx F:\docker_image\DockerDesktopWSL\ext4.vhdx: The system cannot move the file to a different disk drive.

ID: 7C66B47D-65C9-48CF-BE6C-D939969BF436/20230412063341

leechor avatar Apr 12 '23 06:04 leechor

I just experienced the same problem.

MentalFS avatar Jun 10 '24 22:06 MentalFS

Me too. In my case E: drive point to a C: drive directory. It seems not to be a permission problem because DockerDesktopWSL and its subdirectory were created. To solve i set the C: drive directory, but i need to know why i can't use E: drive

m-zanetti avatar Jun 12 '24 05:06 m-zanetti

It's nice to see Docker Desktop has native support now. However, not being able to move it to another disk defeats the purpose for me completely! And with the workaround not working I can basically no longer use DD on my machine as I don't have enough disk space on my system drive ...

black-snow avatar Jun 14 '24 20:06 black-snow

It's nice to see Docker Desktop has native support now. However, not being able to move it to another disk defeats the purpose for me completely! And with the workaround not working I can basically no longer use DD on my machine as I don't have enough disk space on my system drive ...

@black-snow if you have a new installation try this:

  1. Create the directory where to move disk images for example D:\my_custom\path\
  2. Quit DockerDestkop
  3. Go to %APPDATA%\Docker (typically, C:\Users<username>\AppData\Roaming\Docker) and open settings.json with your favorite editor.
  4. Find an entry called customWslDistroDir or create a new one if that doesn't exist.
  5. Enter the path that you have created at point 1, note the double slashes (\): "customWslDistroDir": "D:\\my_custom\\path",
  6. Remove the docker-desktop distribution (note well: docker-desktop, and not docker-desktop-data) with. At the next startup, it will be recreated at the new path you've specified in the settings.json at the previous step: wsl.exe --unregister docker-desktop
  7. Shut down wsl with wsl.exe --shutdown (note that this will also stop any other WSL distribution you might have) 8.. Start Docker Desktop again

m-zanetti avatar Jun 14 '24 22:06 m-zanetti

@MentalFS @black-snow @m-zanetti would you please be able to provide more details (and ideally a diagnostics ID) of the error you get when trying to move your WSL distributions via the UI? It'd be great if you could try that out from 4.31.1.

I was about to get working on this bug, only to realize that a fix to support moving WSL2 distributions to other drives had been merged a while back; but, given your comments, there are probally still issues.

For example, I did move my distros from my default location on C:\ to a D:\ drive with no issues from the UI of 4.31.1.

Any help to reproduce your problems so they can be properly addressed will help.

andrea-reale avatar Jun 17 '24 15:06 andrea-reale

Docker Desktop version: 4.31.1

image

[2024-06-17T19:23:07.702752500Z][com.docker.backend.exe.app] stopping wsl2
[2024-06-17T19:23:08.762055100Z][com.docker.backend.exe.app] moving WSL data from "" to "W:\\Docker\\Data\\DockerDesktopWSL"
[2024-06-17T19:23:08.762055100Z][com.docker.backend.exe.app] no data distro to move at "C:\\Users\\xxx\\AppData\\Local\\Docker\\wsl\\data\\ext4.vhdx"
[2024-06-17T19:23:08.762055100Z][com.docker.backend.exe.ipc] 7b64cae1-wsl-settings -> \\.\pipe\dockerBackendApiServer BackendAPI
[2024-06-17T19:23:08.762055100Z][com.docker.backend.exe.ipc] (21725ec7) 7b64cae1-wsl-settings C->S BackendAPI POST /notify/messagebox/display: {"buttons":[{"label":"Close","url":""}],"description":"An error occurred while migrating the Docker Desktop WSL data disk to its new location:\n\nmoving disk file: rename \u003cHOME\u003e\\AppData\\Local\\Docker\\wsl\\disk\\docker_data.vhdx W:\\Docker\\Data\\DockerDesktopWSL\\disk\\docker_data.vhdx: The system cannot move the file to a different disk drive.\n\nDisk image location will be reverted to its original setting.","kind":"error","optoutID":"","title":"Error migrating WSL disk"}
[2024-06-17T19:23:08.762558400Z][com.docker.backend.exe.ipc] (21725ec7) d72349ea-BackendAPI S<-C 7b64cae1-wsl-settings POST /notify/messagebox/display
[2024-06-17T19:23:08.762558400Z][com.docker.backend.exe.ipc] (21725ec7) d72349ea-BackendAPI S<-C 7b64cae1-wsl-settings bind: {"buttons":[{"label":"Close","url":""}],"description":"An error occurred while migrating the Docker Desktop WSL data disk to its new location:\n\nmoving disk file: rename \u003cHOME\u003e\\AppData\\Local\\Docker\\wsl\\disk\\docker_data.vhdx W:\\Docker\\Data\\DockerDesktopWSL\\disk\\docker_data.vhdx: The system cannot move the file to a different disk drive.\n\nDisk image location will be reverted to its original setting.","kind":"error","optoutID":"","title":"Error migrating WSL disk"}
[2024-06-17T19:23:08.986957800Z][com.docker.backend.exe.ipc] 09c7176b-PauseHDL /pause/events <-- 2024-06-17T21:23:08.986957800+02:00 (64163502) ipc connecting:
[2024-06-17T19:23:08.986957800Z][com.docker.backend.exe.procd] received state {IsPaused:false PauseText:Docker Desktop is running PauseError: DockerAPI:running Docker:stopped Idle:running State:stopped Mode:linux SessionID:a7365da2-2224-46f7-895a-ad4c377f2c59}
[2024-06-17T19:23:11.288675200Z][com.docker.backend.exe.segment] flushing 3 messages

MentalFS avatar Jun 17 '24 19:06 MentalFS

grafik

It created 35 GB of stuff in ther target dir, though.

/mnt/d/docker$ tree -afh
[ 512]  .
├── [ 512]  ./data
│   ├── [ 512]  ./data/DockerDesktopWSL
│   │   └── [ 512]  ./data/DockerDesktopWSL/DockerDesktopWSL
│   │       └── [ 512]  ./data/DockerDesktopWSL/DockerDesktopWSL/disk
│   └── [ 23G]  ./data/ext4.vhdx
└── [ 12G]  ./docker-desktop-data.tar

5 directories, 2 files

This is what it dumped. DID: 12A70E18-D373-471A-AE18-86FEAB88283D/20240617222052

black-snow avatar Jun 17 '24 22:06 black-snow

Thanks folks for confiming and providing some more detail.

I've confimed that while moving the docker-data-distribution through the UI across drives is currently supported, moving the data disk isn't yet. We'll work on a fix, and thanks for your patience.

andrea-reale avatar Jun 18 '24 07:06 andrea-reale

Same problem. Docker version: 4.31.1 微信图片_20240625193342

WanianXO avatar Jun 25 '24 11:06 WanianXO

It's nice to see Docker Desktop has native support now. However, not being able to move it to another disk defeats the purpose for me completely! And with the workaround not working I can basically no longer use DD on my machine as I don't have enough disk space on my system drive ...

@black-snow if you have a new installation try this:

  1. Create the directory where to move disk images for example D:\my_custom\path\
  2. Quit DockerDestkop
  3. Go to %APPDATA%\Docker (typically, C:\Users\AppData\Roaming\Docker) and open settings.json with your favorite editor.
  4. Find an entry called customWslDistroDir or create a new one if that doesn't exist.
  5. Enter the path that you have created at point 1, note the double slashes (): "customWslDistroDir": "D:\\my_custom\\path",
  6. Remove the docker-desktop distribution (note well: docker-desktop, and not docker-desktop-data) with. At the next startup, it will be recreated at the new path you've specified in the settings.json at the previous step: wsl.exe --unregister docker-desktop
  7. Shut down wsl with wsl.exe --shutdown (note that this will also stop any other WSL distribution you might have) 8.. Start Docker Desktop again

Thanks a lot! The only post that solved my problem of more than 10 websites. So detailed and useful.

frankran avatar Jun 27 '24 11:06 frankran

It's nice to see Docker Desktop has native support now. However, not being able to move it to another disk defeats the purpose for me completely! And with the workaround not working I can basically no longer use DD on my machine as I don't have enough disk space on my system drive ...

@black-snow if you have a new installation try this:

  1. Create the directory where to move disk images for example D:\my_custom\path\
  2. Quit DockerDestkop
  3. Go to %APPDATA%\Docker (typically, C:\Users\AppData\Roaming\Docker) and open settings.json with your favorite editor.
  4. Find an entry called customWslDistroDir or create a new one if that doesn't exist.
  5. Enter the path that you have created at point 1, note the double slashes (): "customWslDistroDir": "D:\\my_custom\\path",
  6. Remove the docker-desktop distribution (note well: docker-desktop, and not docker-desktop-data) with. At the next startup, it will be recreated at the new path you've specified in the settings.json at the previous step: wsl.exe --unregister docker-desktop
  7. Shut down wsl with wsl.exe --shutdown (note that this will also stop any other WSL distribution you might have) 8.. Start Docker Desktop again

Thanks a lot! The only post that exactly solved my problem. Same problem. Docker version: 4.31.1

changfeng-xu avatar Jun 29 '24 16:06 changfeng-xu

I also was able to fix it manually - someone from the docker desktop team though it's a smart idea to have an extra directory within the code.. :-) Exporting the VHXD from 4.29 and the reimporting it to 4.31.1 (original path only, didn't work for me, when reimporting to any other path) worked for me.

btw.. anyone knows whoe how to start wsl 2 with networking bridge mode - is that possible or only supported with wsl 1?

dreamworks avatar Jul 03 '24 07:07 dreamworks

btw.. anyone knows whoe how to start wsl 2 with networking bridge mode - is that possible or only supported with wsl 1?

FOA: wsl --update

Then find or create the '.wslconfig' file in your %USERPROFILE%

[wsl2] networkingMode=bridged vmSwitch=WSL_external ... <- your actual vmSwitch must be here.

genesem avatar Jul 03 '24 07:07 genesem

grafik

dreamworks avatar Jul 03 '24 09:07 dreamworks

is this the "nice" msg from MS that it's time to upgrade to windows 11?

dreamworks avatar Jul 03 '24 09:07 dreamworks

that it's time to upgrade to windows 11?

As mush as I know win11 is much worse. but wsl still the same.

genesem avatar Jul 03 '24 10:07 genesem

A fix has been issued for this in the latest Docker Desktop 4.32.0, see https://docs.docker.com/desktop/release-notes/

If the issue persists, don't hesitate to reach out!

lorenrh avatar Jul 05 '24 09:07 lorenrh

Docker version 4.34.2

Cannot change the data location disk.

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\Master\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

This issue is supposed to have been fixed, yet, it is still present. Any suggestions as to how to solve this problem? What another process could be using the file? I tried to shutdown everything that could do it, but still no luck. And really would like to move the Docker stuff from the system disk. It's already 40 GB and I only have a couple of images in it.

SergueyT avatar Sep 22 '24 11:09 SergueyT

same here.

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