Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hyperv: Unable to remove machine directory: ....vmcx: The process cannot access the file because it is being used by another process. #7300

Closed
tstromberg opened this issue Mar 28, 2020 · 17 comments
Labels
co/hyperv HyperV related issues good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/support Categorizes issue or PR as a support question. needs-solution-message Issues where where offering a solution for an error would be helpful triage/needs-information Indicates an issue needs more information in order to work on it.

Comments

@tstromberg
Copy link
Contributor

I have the same problem and tried this:

> minikube stop
*
X Unable to stop VM: open C:\Users\Csongor Halmai\.minikube\machines\minikube\config.json: The system cannot find the file specified.
*
* minikube is exiting due to an error. If the above message is not useful, open an issue:
  - https://github.com/kubernetes/minikube/issues/new/choose

and then

> minikube delete
* Removing C:\Users\Csongor Halmai\.minikube\machines\minikube ...
*
X Unable to remove machine directory: remove C:\Users\Csongor Halmai\.minikube\machines\minikube\minikube\Snapshots\0113C205-19E6-4E44-9903-D0AA9C750A39.vmcx: The process cannot access the file because it is being used by another process.
*
* minikube is exiting due to an error. If the above message is not useful, open an issue:
  - https://github.com/kubernetes/minikube/issues/new/choose

This seems to be show-stopper for me. :(

> minikube version
minikube version: v1.9.0
commit: 48fefd43444d2f8852f527c78f0141b377b1e42a

Originally posted by @halmai in #4286 (comment)

@tstromberg
Copy link
Contributor Author

tstromberg commented Mar 28, 2020

Hey @halmai -

I'm very curious about what happened here, because it's not supposed to be possible, but clearly it is. From your stop output:

X Unable to stop VM: open C:\Users\Csongor Halmai\.minikube\machines\minikube\config.json: The system cannot find the file specified.

minikube was asked to stop a cluster that does not have any local state associated to it, so it failed. Is it possible that you accidentally deleted or moved C:\Users\Csongor Halmai\.minikube\machines, or do we have a bug somewhere?

Alternatively, is it possible that you called stop with a pre-v1.9.0 version of minikube first? We didn't handle Hyper-V deletion so well before.

As far as your delete output:
X Unable to remove machine directory: remove C:\Users\Csongor Halmai\.minikube\machines\minikube\minikube\Snapshots\0113C205-19E6-4E44-9903-D0AA9C750A39.vmcx: The process cannot access the file because it is being used by another process.

This is stating that Hyper-V does in fact have a virtual machine running from this directory, even if the minikube state is gone. This is recoverable by launching the Hyper-V console and shutting the minikube VM down. Then minikube delete should function as expected.

Let me know how it works out. If the instructions work, I'll make sure the error message points users to the appropriate solution. We can do a lot better here.

@halmai
Copy link
Contributor

halmai commented Mar 28, 2020

@tstromberg thanks for the quick response.

It is possible that the files it was unable to delete were coming from an earlier version of minikube. However, even after stopping Hyper-V Host Compute Service from the Task Manager, I was unable to delete the files, which is strange. Both minikube delete and manual delete via Explorer failed.
The solution I chose was to reboot win10 in safe mode and delete all the Snapshots manually. After a normal reboot everything works fine.

@tstromberg
Copy link
Contributor Author

Thanks for the info. I wonder if deleting the VM from Hyper-V would have yielded a different outcome.

Can you confirm that minikube stop and minikube delete now work properly on your system?

@tstromberg tstromberg added co/hyperv HyperV related issues needs-solution-message Issues where where offering a solution for an error would be helpful kind/support Categorizes issue or PR as a support question. triage/needs-information Indicates an issue needs more information in order to work on it. and removed needs-solution-message Issues where where offering a solution for an error would be helpful labels Mar 28, 2020
@medyagh medyagh reopened this Apr 10, 2020
@medyagh
Copy link
Member

medyagh commented Apr 10, 2020

we need to update this suggestion
stopping minikube will not help with deleting
but deleting it from the hyperv manager helps


Minikube v1.9.2 [Approved]
minikube package files upgrade completed. Performing other installation steps.
 ShimGen has successfully created a shim for minikube.exe
 The upgrade of minikube was successful.
  Software install location not explicitly set, could be in package or
  default install location if installer.

Chocolatey upgraded 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32> minikube delete --all --purge
* Removing C:\Users\medya\.minikube\machines\minikube ...
*
* [FILE_IN_USE] Unable to remove machine directory remove C:\Users\medya\.minikube\machines\minikube\disk.vhd: The process cannot access the file because it is being used by another process.
* Suggestion: Another program is using a file required by minikube. If you are using Hyper-V, try stopping the minikube VM from within the Hyper-V manager
* Documentation: https://docs.docker.com/machine/drivers/hyper-v/
* Related issue: https://github.com/kubernetes/minikube/issues/7300
PS C:\Windows\system32> minikube delete --all --purge
* Removing C:\Users\medya\.minikube\machines\minikube ...
*
* [FILE_IN_USE] Unable to remove machine directory remove C:\Users\medya\.minikube\machines\minikube\disk.vhd: The process cannot access the file because it is being used by another process.
* Suggestion: Another program is using a file required by minikube. If you are using Hyper-V, try stopping the minikube VM from within the Hyper-V manager
* Documentation: https://docs.docker.com/machine/drivers/hyper-v/
* Related issue: https://github.com/kubernetes/minikube/issues/7300
PS C:\Windows\system32> minikube delete --all --purge
* Removing C:\Users\medya\.minikube\machines\minikube ...
*
* [FILE_IN_USE] Unable to remove machine directory remove C:\Users\medya\.minikube\machines\minikube\disk.vhd: The process cannot access the file because it is being used by another process.
* Suggestion: Another program is using a file required by minikube. If you are using Hyper-V, try stopping the minikube VM from within the Hyper-V manager
* Documentation: https://docs.docker.com/machine/drivers/hyper-v/
* Related issue: https://github.com/kubernetes/minikube/issues/7300
PS C:\Windows\system32> minikube delete --all --purge
* Removing C:\Users\medya\.minikube\machines\minikube ...
* Removed all traces of the "minikube" cluster.
* Successfully deleted all profiles
* Successfully purged minikube directory located at - [C:\Users\medya\.minikube]
PS C:\Windows\system32>

@medyagh medyagh added good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. needs-solution-message Issues where where offering a solution for an error would be helpful labels Apr 10, 2020
@tstromberg
Copy link
Contributor Author

I believe this is no longer an issue in more recent releases.

@pdefreitas
Copy link

I can confirm this is happening to me on v1.11.0, which is the latest release. Running Windows 10 18363.836. The only way I am able to run minikube again is by disabling hyper-v, deleting the old files, reenabling hyper-v and recreating the VM.

@tejaschitale123
Copy link

I was also facing the same issue , but after Shutting down all the process related to Hyper V from task manager my problem got resolved

@kkcmadhu
Copy link

kkcmadhu commented Aug 4, 2020

happening for me in windows 10 and i am struck,
**BUT KILLING HYPERV PROCESSOR AND MANUALLY DELETING .**minikube works

@rashmip22
Copy link

Not Working, I am facing same issue
I tried solutions provided above, it did not work

@pordaniel01
Copy link

Stopping the service in hyper-v manager solved the problem for me.

@cxsu
Copy link
Contributor

cxsu commented Dec 27, 2020

My solution

Windows 10 pro 1909 (os build: 18363.1256)
minikube version: v1.15.1
commit: 9f1e482427589ff8451c4723b6ba53bb9742fbb1

In my case, I installed minikube by Chocolatey. But it worked as below.
Even though I ran commands on PowerShell, Chocolatey shell was executed!

image

So I found a process that uses the minikube directory,

image

and I killed the process.

taskkill /F /PID <PID_NUMBER>

PURGE MINIKUBE.

minikube delete --purge
# Successfully purged minikube directory located at - [C:\Users\csu04\.minikube]

I installed minikube by Windows installer, not the Chocolatey.
Finally, the command below was executed well.

minikube start
❯ kubectl get po -A
NAMESPACE     NAME                               READY   STATUS    RESTARTS   AGE
kube-system   coredns-74ff55c5b-cnn46            1/1     Running   0          22m
kube-system   etcd-minikube                      1/1     Running   0          22m
kube-system   kube-apiserver-minikube            1/1     Running   0          22m
kube-system   kube-controller-manager-minikube   1/1     Running   0          22m
kube-system   kube-proxy-xk2nk                   1/1     Running   0          22m
kube-system   kube-scheduler-minikube            1/1     Running   0          22m
kube-system   storage-provisioner                1/1     Running   1          22m

@yin1999
Copy link

yin1999 commented Apr 20, 2021

Still heppening on v1.19.0
image

@Abheestanistala
Copy link

The error still persists:

Windows 10 Home;
WSL is enabled

Tried minikube delete and then again minikube start

Please note that both the Minikube and Oracle VMBox are installed on different drive if that makes any difference but as far I know that shouldn't be the issue.

D:\Abheesta\Kubernetes\Minikube>minikube start
* minikube v1.20.0 on Microsoft Windows 10 Home Single Language 10.0.19043 Build 19043
* Automatically selected the virtualbox driver
* Starting control plane node minikube in cluster minikube
* Creating virtualbox VM (CPUs=2, Memory=2200MB, Disk=20000MB) ...
* Deleting "minikube" in virtualbox ...
! StartHost failed, but will try again: creating host: create: creating: Unable to start the VM: D:\Abheesta\Oracle\VBoxManage.exe startvm minikube --type headless failed:
VBoxManage.exe: error: Not in a hypervisor partition (HVP=0) (VERR_NEM_NOT_AVAILABLE).
VBoxManage.exe: error: AMD-V is disabled in the BIOS (or by the host OS) (VERR_SVM_DISABLED)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

Details: 00:00:01.372131 Power up failed (vrc=VERR_SVM_DISABLED, rc=E_FAIL (0X80004005))
* Failed to start virtualbox VM. Running "minikube delete" may fix it: Error loading existing host. Please try running [minikube delete], then run [minikube start] again.: filestore "minikube": open C:\Users\hp\.minikube\machines\minikube\config.json: The system cannot find the file specified.
! Startup with virtualbox driver failed, trying with alternate driver ssh: Failed to start host: Error loading existing host. Please try running [minikube delete], then run [minikube start] again.: filestore "minikube": open C:\Users\hp\.minikube\machines\minikube\config.json: The system cannot find the file specified.
* Removing C:\Users\hp\.minikube\machines\minikube ...

X Exiting due to GUEST_FILE_IN_USE: remove C:\Users\hp\.minikube\machines\minikube\id_rsa: The process cannot access the file because it is being used by another process.
* Suggestion: Another program is using a file required by minikube. If you are using Hyper-V, try stopping the minikube VM from within the Hyper-V manager
* Documentation: https://docs.docker.com/machine/drivers/hyper-v/
* Related issue: https://github.com/kubernetes/minikube/issues/7300

@souzaroberto
Copy link

I had the same issue, and in Hyper-V Manager I deleted the minikube instance running.
I tried the command again:

minikube delete --all --purge

and it works!

image

@jhbswart
Copy link

jhbswart commented Aug 17, 2021

stopping hyper-v service worked for me

@alivelusai
Copy link

I was also facing the same issue , but after Shutting down all the process related to Hyper V from task manager my problem got resolved

nice

@Jaques-Burger
Copy link

Stopping Hyper-V Virtual Machine Management service allowed me to remove these files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
co/hyperv HyperV related issues good first issue Denotes an issue ready for a new contributor, according to the "help wanted" guidelines. kind/support Categorizes issue or PR as a support question. needs-solution-message Issues where where offering a solution for an error would be helpful triage/needs-information Indicates an issue needs more information in order to work on it.
Projects
None yet
Development

No branches or pull requests