myspaghetti / macos-virtualbox

Push-button installer of macOS Catalina, Mojave, and High Sierra guests in Virtualbox on x86 CPUs for Windows, Linux, and macOS
GNU General Public License v2.0
13.48k stars 1.11k forks source link

VBoxManage uses C:\Windows\system32 as working directory on WSL #83

Closed situssoft closed 4 years ago

situssoft commented 5 years ago

Whenever I attempt to use the script on WSL I get the following error, any suggestions as to what I might be doing wrong?

Archive successfully decompressed as HighSierra_BaseSystem.img Converting from raw image file="HighSierra_BaseSystem.img" to file="HighSierra_BaseSystem.vdi"... VBoxManage.exe: error: Cannot open file "HighSierra_BaseSystem.img": VERR_FILE_NOT_FOUND Creating macOS target system virtual disk image. 0%... Progress state: VBOX_E_FILE_ERROR VBoxManage.exe: error: Failed to create medium VBoxManage.exe: error: Could not create the medium storage unit 'C:\Windows\system32\macOS.vdi'. VBoxManage.exe: error: VDI: cannot create image 'C:\Windows\system32\macOS.vdi' (VERR_ACCESS_DENIED)

situssoft commented 5 years ago

This is the file list from my working folder

ApfsDriverLoader.efi HighSierra_BaseSystem.dmg HighSierra_InstallESDDmg.pkg AppleImageLoader.efi HighSierra_BaseSystem.img HighSierra_InstallInfo.plist AppleSupport-v2.0.4-RELEASE.zip HighSierra_InstallESD.part00 HighSierra_installation_files.viso AppleUiSupport.efi HighSierra_InstallESD.part01 LICENSE HighSierra_AppleDiagnostics.chunklist HighSierra_InstallESD.part02 README.md HighSierra_AppleDiagnostics.dmg HighSierra_InstallESD.part03 macos-guest-virtualbox.sh HighSierra_BaseSystem.chunklist HighSierra_InstallESD.part04 startup.nsh

myspaghetti commented 5 years ago

C:\Windows\System32 rears its ugly head again... tested on WSL Ubuntu 18.04 LTS, could not reproduce. If I had to guess, the script identifies your WSL installation as Cygwin. Please run cygcheck -V 2>/dev/null and see if it outputs something. If it does, I'll improve the WSL/Cygwin check.

situssoft commented 5 years ago

No output from cygcheck.

Is there anything else I can do to provide more diagnostics?

myspaghetti commented 5 years ago

I dunno, this was a problem before I properly tested the script of WSL, now the VBoxManage command is defined differently for Cygwin and WSL so they each work on the script's working directory and they accept parameters with spaces.

What WSL distribution are you running?

situssoft commented 5 years ago

/proc/version has this Linux version 4.4.0-17763-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #379-Microsoft Wed Mar 06 19:16:00 PST 2019

and /etc/os-release has this NAME="Ubuntu" VERSION="18.04.1 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.1 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic

myspaghetti commented 5 years ago

I'm running a slightly newer version, but I don't think that's the problem.

Linux version 4.4.0-18362-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #1-Microsoft Mon Mar 18 12:02:00 PST 2019
NAME="Ubuntu"
VERSION="18.04.2 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.2 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
stepanovdg commented 4 years ago

So the reason of so in case you as I tried to put file into linux location on WSL (i just vi new file and insert the script content). After I put script file into windows folder and run it in wsl console through /mnt/c/pathTofile it succeeds on putting file to its own location on windows and vboxmanage was able to access them.

myspaghetti commented 4 years ago

Might be a permissions issue. I'll test later.

myspaghetti commented 4 years ago

@situssoft please test version 0.75.0 and tell me if it fixes the C:\WINDOWS\system32 issue.

situssoft commented 4 years ago

I will test but I'm away for a couple of weeks so won't get to this until September.

Chris

On 22 Aug 2019 05:12, Jack notifications@github.com wrote:

@situssofthttps://github.com/situssoft please test version 0.75.0https://raw.githubusercontent.com/myspaghetti/macos-guest-virtualbox/ab6d514d47e3654ff5e080a63e6355f8f0ea54b3/macos-guest-virtualbox.sh and tell me if it fixes the C:\WINDOWS\system32 issue.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/myspaghetti/macos-guest-virtualbox/issues/83?email_source=notifications&email_token=AAUIKMH4H4NLDFZCPJ62XS3QFZC5LA5CNFSM4IEACP22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD44IXNI#issuecomment-523799477, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAUIKMBETLG3NWEDGJFSY2TQFZC5LANCNFSM4IEACP2Q.

briancasper1 commented 4 years ago

I have the exact issue described above. Fresh install of WSL with Ubuntu 18.04 LTS from the windows store and a fresh copy of the macos-guest-virtualbox.sh script (ver 0.75.2)

$cat /proc/version Linux version 4.4.0-17763-Microsoft (Microsoft@Microsoft.com) (gcc version 5.4.0 (GCC) ) #379-Microsoft Wed Mar 06 19:16:00 PST 2019

$ cat /etc/os-release NAME="Ubuntu" VERSION="18.04.3 LTS (Bionic Beaver)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 18.04.3 LTS" VERSION_ID="18.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=bionic UBUNTU_CODENAME=bionic

After installing the Ubuntu package and the other requirements (coreutils, unzip, etc) I did a full "sudo apt update", if that matters.

This is the first error message from the script at runtime:

[ ... ] Archive successfully decompressed as Mojave_BaseSystem.img Converting from raw image file="Mojave_BaseSystem.img" to file="Mojave_BaseSystem.vdi"... VBoxManage.exe: error: Cannot open file "Mojave_BaseSystem.img": VERR_FILE_NOT_FOUND Creating macOS target system virtual disk image. 0%... Progress state: VBOX_E_FILE_ERROR VBoxManage.exe: error: Failed to create medium VBoxManage.exe: error: Could not create the medium storage unit 'C:\Windows\System32\macOS.vdi'. VBoxManage.exe: error: VDI: cannot create image 'C:\Windows\System32\macOS.vdi' (VERR_ACCESS_DENIED) VBoxManage.exe: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium VBoxManage.exe: error: Context: "enum RTEXITCODE __cdecl handleCreateMedium(struct HandlerArg *)" at line 462 of file VB oxManageDisk.cpp

Same issue for all 3 flavors of MacOS.

What other info can I provide?

myspaghetti commented 4 years ago

Thanks for testing. I'll keep trying to reproduce the issue.

andymule commented 4 years ago

If using WSL, you MUST download and run this script from a location within the Windows Filesystem. Something like /mnt/c/macvmsetup/

This is because windows programs are practically unable to access things located within the WSL install. There is a chance this issue self resolves as Microsoft improves filesystems compatibility in the future for WSL, but for now your safest bet is to avoid it completely and stay within window's obvious fs grasp.

myspaghetti commented 4 years ago

@andymule that's not true, the script runs fine from the WSL filesystem, as tested by several people including myself. There's some other issue regarding WSL and VBoxManage not running on the correct working directory, but please don't mislead by saying it "MUST" run on a Windows path.

andymule commented 4 years ago

Not trying to mislead. I've played with windows programs operating on things the WSL filesystem a lot, to the point that they added a new rule on the 'bashonubuntuonwindows' reddit channel specifically in response to me making tools around it: https://www.reddit.com/r/bashonubuntuonwindows/comments/ai1j4e/i_made_a_easy_way_to_finally_open_explorer_and/ (see rule 8)

So, you're right, I was a bit strong in my wording. I'm sure it's possible to make this work from entirely within WSL, but I don't think it's best to do so simply bc MS is still playing with how they integrate the WSL filesystem, so nothing is guaranteed until that settles.

That said, I'm very confident that everyone who sees this error currently will see it disappear if they run the script from within the windows file space. I just did it today which is why I made the post. How you resolve that as a dev in this repo is best left to you, but my suggestion is to keep everything that a windows program need to touch somewhere within the windows fs.

myspaghetti commented 4 years ago

If you can provide steps to reproduce this issue it would be very helpful, because I was not able to reproduce the issue on Windows 10 version 1903 18362.356 with Ubuntu 18.04 LTS 4.4.0-18362-Microsoft, running the script from the user's home directory.

myspaghetti commented 4 years ago

@andymule that Microsoft blog post is very helpful; seems like prior to Windows 10 1903, accessing files on the WSL filesystem was problemating. I'll update the requirements for the script.

myspaghetti commented 4 years ago

Added WSL path warning for Windows 10 versions other than 1903 in script version 0.75.5