Access denied after moving my Ubuntu distribution to another drive


kgeorg

Member
Local time
12:26 AM
Posts
4
OS
Windows 11
After a
Code:
wsl --manage Ubuntu --move D:\WSL2Distros\
when trying to start Ubuntu under Windows Terminal I get:

Code:
Failed to attach disk 'D:\WSL2Distros\ext4.vhdx' to WSL2: Access is denied.
Error code: Wsl/Service/CreateInstance/MountDisk/HCS/E_ACCESSDENIED

The vdhx file moved correctly to the new location.


Also when starting Docker Desktop I get a similar:

Code:
configuring docker in Ubuntu: docker cli config: failed to write file: running wslexec: An error occurred while running the command. Wsl/Service/CreateInstance/MountDisk/HCS/E_ACCESSDENIED: c:\windows\system32\wsl.exe -d ubuntu -e sh -c cat - > ~/.docker/config.json: exit status 0xffffffff (stderr: , wslErrorCode: Wsl/Service/CreateInstance/MountDisk/HCS/E_ACCESSDENIED)

I tried to assign all permissions to my standard user. I also tried to change owner from my user to Administrator, and finally back again. Nothing helped.
 
Windows Build/Version
24H2 26100.7171

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lynx
    CPU
    Intel Core i7 3770S
    Motherboard
    Intel Corporation DH77EB
    Memory
    16.0GB Dual-Channel DDR3
    Graphics Card(s)
    GeForce GTX 1050 Ti
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP Pavilion
    CPU
    AMD Ryzen 7 5700G
    Motherboard
    Erica6
    Memory
    Micron Technology DDR4-3200 16GB
    Graphics Card(s)
    NVIDIA GeForce RTX 3060
    Sound Card
    Realtek ALC671
    Monitor(s) Displays
    Samsung SyncMaster U28E590
    Screen Resolution
    3840 x 2160
    Hard Drives
    SAMSUNG MZVLQ1T0HALB-000H1
When looking for a solution that was one of the ways to do it. However, since a very recent WSL2 update the -move command is supported. I think its a bug and have reported it on github. However, I have the feeling it's an ownership issue, but there exist no other users than me and Administrator on my machine.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lynx
    CPU
    Intel Core i7 3770S
    Motherboard
    Intel Corporation DH77EB
    Memory
    16.0GB Dual-Channel DDR3
    Graphics Card(s)
    GeForce GTX 1050 Ti
When looking for a solution that was one of the ways to do it. However, since a very recent WSL2 update the -move command is supported. I think its a bug and have reported it on github. However, I have the feeling it's an ownership issue, but there exist no other users than me and Administrator on my machine.
can you get to the Ubuntu Terminal
if you can get to the terminal
please try at the command prompt ..

sudo update grub

enter your password then press enter

and see if the boot loader is updated for the new location of Ubuntu.
best of luck Steve ..
 

My Computers

System One System Two

  • OS
    Debian 13 Trixie .. Windows 11 Home
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP 24" AiO
    CPU
    Ryzen 7 5825u
    Motherboard
    HP
    Memory
    64GB DDR4 3200
    Graphics Card(s)
    Ryzen 7 5825u
    Sound Card
    RealTek
    Monitor(s) Displays
    24" HP AiO
    Screen Resolution
    1920 x 1080 @60 Hz
    Hard Drives
    1TB WD Blue SN580 M2 SSD Partitioned.
    2x 1TB USB HDD External Backup/Storage.
    PSU
    90W external power brick
    Case
    24" All in One
    Cooling
    Default Air Cooling
    Keyboard
    HP WiFi UK extended
    Mouse
    HP WiFi 3 Button
    Internet Speed
    1GB full fibre
    Browser
    Edge & Firefox
    Antivirus
    AVG Internet Security/Windows Defender
    Other Info
    Mainly Open Source Software
  • Operating System
    Ubuntu 22.04.5 LTS
    Computer type
    Laptop
    Manufacturer/Model
    Dell 13" Latitude 2017
    CPU
    i5 7200u
    Motherboard
    Dell
    Memory
    16GB DDR4
    Graphics card(s)
    Intel
    Sound Card
    Intel
    Monitor(s) Displays
    13" Dell Laptop
    Hard Drives
    250GB Crucial 2.5" SSD
    Mouse
    Generic WiFi 3 button
    Internet Speed
    WiFi only
    Browser
    Firefox
    Antivirus
    ClamAV TK
    Other Info
    Mainly Open Source Software
That didn't work. Never got into Ubuntu. Same error message as in Windows Terminal above. I did, in the end, move the file back to its original location and it works again. However, I moved it in the first place because I was running out of space on my C: drive (only a 265 GB SSD).
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lynx
    CPU
    Intel Core i7 3770S
    Motherboard
    Intel Corporation DH77EB
    Memory
    16.0GB Dual-Channel DDR3
    Graphics Card(s)
    GeForce GTX 1050 Ti
That didn't work. Never got into Ubuntu. Same error message as in Windows Terminal above. I did, in the end, move the file back to its original location and it works again. However, I moved it in the first place because I was running out of space on my C: drive (only a 265 GB SSD).

now you can get back into ubuntu

open the file /etc/default/grub.conf

check the drive entry within that file for its location
ie. SBA then open disks and get the location entry for the disk you wish to move the VM to

change the grub entry in nano in a terminal
sudo nano then the grub file location /etc/default/grub.conf
add the new location for the drive you wish to transfer the VM and save the file
ctrl and x then 's' then enter

open a terminal and > sudo update grub <

once grub has been updated move the Ubuntu VM to the new location
and then try to boot the Ubuntu VM.

if this doesn't work you can change the grub entry via nano to its default
before any changes and re-locate the file back to C: drive ..

best of luck Steve ..
 

My Computers

System One System Two

  • OS
    Debian 13 Trixie .. Windows 11 Home
    Computer type
    PC/Desktop
    Manufacturer/Model
    HP 24" AiO
    CPU
    Ryzen 7 5825u
    Motherboard
    HP
    Memory
    64GB DDR4 3200
    Graphics Card(s)
    Ryzen 7 5825u
    Sound Card
    RealTek
    Monitor(s) Displays
    24" HP AiO
    Screen Resolution
    1920 x 1080 @60 Hz
    Hard Drives
    1TB WD Blue SN580 M2 SSD Partitioned.
    2x 1TB USB HDD External Backup/Storage.
    PSU
    90W external power brick
    Case
    24" All in One
    Cooling
    Default Air Cooling
    Keyboard
    HP WiFi UK extended
    Mouse
    HP WiFi 3 Button
    Internet Speed
    1GB full fibre
    Browser
    Edge & Firefox
    Antivirus
    AVG Internet Security/Windows Defender
    Other Info
    Mainly Open Source Software
  • Operating System
    Ubuntu 22.04.5 LTS
    Computer type
    Laptop
    Manufacturer/Model
    Dell 13" Latitude 2017
    CPU
    i5 7200u
    Motherboard
    Dell
    Memory
    16GB DDR4
    Graphics card(s)
    Intel
    Sound Card
    Intel
    Monitor(s) Displays
    13" Dell Laptop
    Hard Drives
    250GB Crucial 2.5" SSD
    Mouse
    Generic WiFi 3 button
    Internet Speed
    WiFi only
    Browser
    Firefox
    Antivirus
    ClamAV TK
    Other Info
    Mainly Open Source Software
There is no grub.conf in /etc/default

Also, I don't think this is it. This is inside the virtual disk, right? But it looks like WSL isn't able to mount the disk because of permission problems.
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lynx
    CPU
    Intel Core i7 3770S
    Motherboard
    Intel Corporation DH77EB
    Memory
    16.0GB Dual-Channel DDR3
    Graphics Card(s)
    GeForce GTX 1050 Ti
Run PowerShell (as Admin) - replace the path with your file: p=′D:\WSL2Distros\ext4.vhdx′takeown/fp /a icacls p/grant"NTAUTHORITY\SYSTEM:(F)""Administrators:(F)""Users:(RX)"icacls(Split−Pathp) /grant "NT AUTHORITY\SYSTEM:(F)" "Administrators:(F)" "Users:(RX)"

takeown /a makes Administrators the owner - WSL expects SYSTEM/Administrators rights on the file. If you prefer your user to own it - run takeown without /a then icacls to give SYSTEM full control too.

If that doesn't work, temporarily disable Controlled Folder Access - or add wsl.exe and your drive/folder as allowed, as in:

Windows Security > Virus & threat protection > Manage ransomware protection > Turn off Controlled folder access - or add these allowed apps:

C:\Windows\System32\wsl.exe

C:\Windows\System32\vmcompute.exe (if present)

Optionally add the whole D:\WSL2Distros folder as an allowed folder. Reboot Windows to ensure services see the ACL changes - then run:

wsl -l -v wsl -d Ubuntu

If still failing - try export/import instead of move (that's the safer option)

wsl --export Ubuntu C:\temp\ubuntu.tar
wsl --unregister Ubuntu
mkdir D:\WSL2Distros\Ubuntu
wsl --import Ubuntu D:\WSL2Distros\Ubuntu C:\temp\ubuntu.tar --version 2
 

My Computer

System One

  • OS
    WinDOS 25H2
    Computer type
    Laptop
    CPU
    Intel & AMD
    Memory
    SO-DIMM SK Hynix 15.8 GB Dual-Channel DDR4-2666 (2 x 8 GB) 1329MHz (19-19-19-43)
    Graphics Card(s)
    nVidia RTX 2060 6GB Mobile GPU (TU106M)
    Sound Card
    Onbord Realtek ALC1220
    Screen Resolution
    1920 x 1080
    Hard Drives
    1x Samsung PM981 NVMe PCIe M.2 512GB / 1x Seagate Expansion ST1000LM035 1TB
If you can get into your previous version of Ubuntu - disable the firewall before moving the VM - that could be a problem as well as any selinux security you've got operating.
The problem might not actually be from the Windows end.

I don't like Ubuntu - more problems than its worth IMHO and I've been using Linux "Since Pontius was a Pilot" (Pilate for those unfamiliar with "the Good Book") !!. Plus I don't like Canonical - the company behind the distro. You're a lot better off with say FEDORA (Red Hat - now owned by IBM whose software record is pretty good on the whole), Debian private but still rigoursly maintained with emphasis on stability so older stable software, ArchLinux ("Roll your own - great for people who want to tinker and make the thing lean and mean and lightning fast) or SUSE - big german company who apply legendary Teutonic efficiency to their products. Some of these also have MINT variations for people who like Linux Mint e.g look at Fedora "spins".

Windows Hyper-V as a host is usually pretty good but it does sometimes get its knickers in a twist when moving VM's - probably the best thing is to re-create the VM from scratch and don't use GRUB as the default boot loader any more - it's gradually being deprecated - certainly in the latest more up to date distros.

Cheers
jimbp
 

My Computer

System One

  • OS
    Windows XP,11 Linux Fedora Rawhide pre-release 45
    Computer type
    PC/Desktop
    CPU
    2 X Intel i7
    Screen Resolution
    4KUHD X 2
Back
Top Bottom