What is /Library/StagedExtensions for and how to remove extensions [closed] - kernel-extension

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Locked. This question and its answers are locked because the question is off-topic but has historical significance. It is not currently accepting new answers or interactions.
I'm trying to uninstall Parallels completely from macOS High Sierra.
I removed everything from the disk except some Parallels extensions that are stored under /Library/StagedExtensions/Parallel Desktop.app
I think the location has to do with user approved extensions, but I'd like to find a way to remove/uninstall those too. If I try to delete the extensions it says operation not permitted despite the root rights.
Any idea?

There is new way to clear the StageExtensions folder as following
sudo kextcache --clear-staging
This command will clear the /Library/StageExtensions folder. We dont need to go to recovery mode and delete manually this folder in case there are some permission errors while installing software.

In my case, deleted kext disappears from StagedExtensions when you invalidate kext cache.
sudo rm -rf /Library/Extensions/Parallel\ Desktop.app # check if the name is correct so you don't delete some other kext
sudo kextcache -invalidate /
# now you should not see your deleted kext here
ls /Library/StagedExtensions/
UPDATE 2019:
See man page for full details: man kextcache.
Excerpt related to -invalidate, -i for short:
-i os_volume, -invalidate os_volume
Rebuild out-of-date caches and update any helper partitions
associated with os_volume.
This option mimics sudo touch /System/Library/Extensions on
os_volume. If kextcache cannot find or make sense of
os_volume/usr/standalone/bootcaches.plist, the volume is treated
as if no caches need updating: success is returned.
There are also new options:
-clear-staging
Clears the kernel extension staging area by removing all staged content.
-prune-staging
Prunes the kernel extension staging area by removing all kernel extensions
no longer present in their original location.
Looks like -prune-staging removes only the deleted extensions, shaving little bit of time from the next kext cache rebuild.
See https://www.unix.com/man-page/mojave/8/KEXTCACHE/ for Mojave man page, which contains these new options.

sudo kextcache --clear-staging
Was in folder HD/Library/
Cheers
Edit: Formatting
Edit2: I believe that Parallels writes some files directly into the bootloader/kernel. After running the command from the CMD+R hold restart Disk Utility Terminal the extension was removed from /Library .
I hope this makes sense.

I had a similar issue in trying to uninstall the TelestreamAudio.kext for ScreenFlow. What might be happening is that the kext in StagedExtensions is currently in use or protected while you're in regular mode. Once you get into Recovery mode, you can delete it without disabling System Integrity Protection. The following steps worked for me, though please use caution.
Click the  menu. Select Restart
Hold down command-R to boot into the Recovery System
Choose Disk Utility from the Recovery Menu
Within Disk Utility click on your main hard drive (e.g. Macintosh HD) and then click on Mount
Exit out of Disk Utility
Click Utilities in the menu bar and select Terminal
Use the following commands:
.
cd /Volumes/Macintosh\ HD/Library/StagedExtensions/Library/Extensions/
rm -rf NAME_OF_EXTENSION.kext
Close the Terminal app
Click the  menu and select Restart
From there on, I was able to reinstall ScreenFlow's audio kext and it worked. It may also help you completely remove the Parallels kext.

If you've already deleted the extensions from /Library/Extensions, open the Terminal app from Launchpad, copy/paste the command below and press Enter to run it:
sudo kextcache -prune-staging
As mentioned in another comment, this will only remove the kernel extensions that are no longer present in their original location, i.e., /Library/Extensions.
The extensions you deleted from /Library/Extensions will then disappear from /Library/StagedExtensions/. It won't affect your other kernel staged extensions.
/Library/StagedExtensions/ is an intermediate area where your extensions live after you start your session (like a cache). The staging area won't be immediately affected if changes are made to /Library/Extensions, which I believe is meant to improve stability and security.

This is because of the System Integrity Protection (SIP).
You can disable it (not recommended) and remove the kext manually.
(from https://www.imore.com/el-capitan-system-integrity-protection-helps-keep-malware-away)
Click the  menu. Select Restart...
Hold down command-R to boot into the Recovery System.
Click the Utilities menu and select Terminal.
Type csrutil disable and press return.
Close the Terminal app. Click the  menu and select Restart....
If you decide later you want to re-engage SIP (and I earnestly hope that you do), repeat these steps, use csrutil enable instead.

Related

How to set up, maintain and distribute a template VM in VMware

(i posted this question on VMware community forums, with no response)
All of my developers use VMware workstation 11 for running their Visual Studio development environments in Windows. I originally created a base VM, and then simply shared it around to all the users, unbeknown to all the issues it would cause with computer name conflicts, joining the domain, etc. Apparently I didn't 'sysprep' it. Someone with some VMware knowledge tried to help me out to set it up, but im still not sure if it is 100% correct.
I am now at a point where I need to make changes/updates to the base VM (new VS, run Windows Updates, etc) and distribute a new one around to all the developers again, and I need some help to make sure I do it properly this time:
I have 2 VM images currently: 1) a ‘base’ one that opens up to this screen http://screencast.com/t/tBO0IUvwtpbY and 2) one that opens up to this screen http://screencast.com/t/DLV71PeNygrk . I’m assuming it is the ‘base’ one that I make the ‘edits’ to?
If I do edit the ‘base’ VM, what option(s) should I choose in that sys prep dialog?
Once I make the necessary updates to the base VM, what do I need to do to 'prepare' it for distribution to my developers (do I need to run sys prep, do I need to make a copy of VM beforehand, etc)?
Currently the VM has 2 HD's: 1) used for the OS and applications (Persistent and non-Independent), and 2) used to store data files (Persistent and Independent) . Is this the best way to set it up and use the VM (and then use 'snapshots' to revert back to previous states), or should the OS disk be set up as 'non-persistent' after the user has set up the VM for first use (i.e. joined the domain, set up VS Workspace, etc) ? Basically we have had a few scenarios recently where the OS and VS have been corrupted and it took the devs a while to fix it, so I want them to have some sort of way to revert back to a known clean working state.
Thank you
In answer to your questions you are on the right track.
the first screen that opens is correct, customise everything you require in the OS then run the OOBE before distribution
Choose OOBE and tick Generalise, then choose shutdown.
Once the VM is shutdown export it and pass it round your developers. they will need to complete the wizard and then join to the domain if required, this will ensure all the sids are different on each server, remember they must still change the Servers name before joining the domain
Snapshots are best, if your dev needs to reboot etc he doesn't want to loose his changes, he then has the option to revert to a snapshot.
Hopefully this has answered your question, let me know if there is anything else you need :)

Unable to log in to Ubuntu running on VirtualBox [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
Recently I created a Ubuntu 14.04 (Trusty Tahr) VM in VirtualBox which is running on my Windows 7 laptop. It was working fine, but I am experiencing very strange behavior now. After entering the right password it is again displaying the login screen. But if I enter the wrong password then it says the wrong password that is expected. I checked the log file of VirtualBox, but there is nothing.
RAM and HD allocated for VM is sufficient.
Below is the screen again and again appearing after entering the right password to log in.
This happened to me while adding shared folders on VirtualBox. I have removed the shared folders and restarted VirtualBox.
The above steps solved my issue.
I seems like something is corrupted in your user profile.
You should look into file ~/xsession-errors for the logs and see what is happening.
The usual suspects
Open a terminal screen (Ctrl + Alt + F1) log and and look into these file permissions (owner+mode):
.cache/
.Xauthority
.ICEauthority
If nothing works, just delete these files:
rm -rf .cache
rm .Xauthority
rm .ICEautority
Now go back with Alt + F7, log in and try again.
Another option is to look for any recent changes to the ~/.profile file if any program you installed has modified it recently.
This just happened to me on an Ubuntu 16.04 (Xenial Xerus) guest. I couldn't log in through the GUI, but I was able to log in through the CLI.
Chrome decided to use all the memory in the VM (which somehow prevented a GUI login). I killed Chrome from the CLI and I was then able to login through the GUI.
I recently experienced this issue as well, though with a different Ubuntu OS (Ubuntu MATE 20.04.2.0 (Focal Fossa) on Windows 10), but I've seen this happen on Debian 10 (Buster) and Debian 8 (Jessie), Kali Linux, and Ubuntu 20.04.2.0.
The inability to login has always been due to insufficient memory allocation (with VirtualBox, dynamic allocation doesn't work all the time, and space runs out fast). I received a low drive space warning, but dismissed it; I ended up unable to login to my machine after booting it.
However, you may not receive a warning that you are running low on drive space, so it's a good idea to pay attention to the amount of space you have before running updates or downloading large files. To fix this issue, you'll either need to manually increase the memory allocation from the VirtualBox manager or create a new VM.
You might have made some changes in /etc/environment.
Most probably you have corrupted the PATH variable.
Update the environment file like this (using nano):
sudo nano /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
Save and exit with Ctrl + X.
I'm using the Kali Linux VM, but I just restarted the VirtualBox and everything works just fine! It might help...

VirtualBox error when trying to run Ubuntu "Failed to open a session" [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
Im trying to run Ubuntu in a virtual machine on virtual box. So far I have reinstalled virtualbox once to see if it was the cause, then I redownloaded the .iso, but when I try to run the machine it says it still won't run.
Failed to open a session for the virtual machine ubuntu.
The virtual machine 'ubuntu' has terminated unexpectedly during startup with exit code 1.
Result Code: E_FAIL (0x80004005)
Component: Machine
Interface: IMachine {480cf695-2d8d-4256-9c7c-cce4184fa048}
If you didn't power off the vm after last run, try right-click on VirtualBox Manager >> Discard Saved State. This will start the vm from (virtual) power off state. Current state of vm will be lost.
Are you using VirtualBox 4.3.14? There's a known bug which could be related: https://www.virtualbox.org/ticket/13187
I was having this problem, downgrading "solved" it.
Here's what I did and it worked properly:
(1) Move/copy your hard disk image (my_old_vm.vdi) to a
convenient folder, e.g. C:\my\VMS\my_new_vm\
(2) Create a new virtual machine (click the new button).
(2.b) At some point in time you are asked about the disk
to be used; choose 'existing disk image' and browse
to where you moved my_old_vm.vdi and select that.
(3) Start the VM and reconfigure the machine settings.
(4) Possibly delete the old machine. If you did not move the
.vdi file, then do not delete all files related to the
old machine.
This saved my day.
For me "Detachable Start" works, can you try it out?
I just went through exactly the same problem on a Windows VM. Uninstalling the Norton Internet Security and restarting my computer solved the problem. Credit to this article that I found here: https://forums.virtualbox.org/viewtopic.php?f=6&t=62615

Migrating from VMWARE to VirtualBox [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm trying to migrate an existing VM from VMWARE to VirtualBox. I've made a copy of the Virtual Machine folder for the VM (so I can experiment and not destroy the original) and have successfully created a VM in VirtualBox. I've got everything booting and running, but the issue is that VM is using the "flat" disk image instead of the correct disk image causing the disk image to be from the past (I know this because all the files on the machine have a timestamp of 2009).
To elaborate, in the VM's folder i have the following vmdk files:
Win2003.vmdk (1 K)
Win2003-flat.vmdk (15 gigs)
Win2003-000002.vmdk (10 gigs)
NOTE: the disk is dynamic.
Looking in the configuration of the VM under VMWARE, it says that it's using the win2003-000002.vmdk as the disk image.
When I import the disk image into VirtualBox (the Win2003.vmdk file), it uses the Win2003-flat.vmdk disk image.
My question is, what can I do to either combine or import the Win2003-000002.vmdk disk image into the Win2003-flat.vmdk disk image so that VirtualBox will use the correct disk image?
I've some instructions on using vmware-vdiskmanager.exe to accomplish this, but I get an error stating "The parent of this virtual disk could not be opened."
After many attempts I was finally able to get this working. Essentially what I did was download and use the vmware converter to merge the two disks into one. After that I was able to attach the newly created disk to VitrualBox.
The steps involved are very simple:
BEFORE YOU DO ANYTHING!
1) MAKE A BACKUP!!! Even if you follow these instruction, you could screw things up, so make a backup. Just shutdown the VM and then make a copy of the directory where VM resides.
2) Uninstall VMware Tools from the VM that you are going to convert. If for some reason you forget this step, you can still uninstall it after getting everything running under VirtualBox by following these steps. Do yourself the favor and just do it now.
NOW THE FUN PART!!!
1) Download and install the VMware Converter. I used 5.0.1 build-875114, just use the latest.
2) Download and install VirtualBox
3) Fire up VMWare convertor:
4) Click on Convert machine
6) Browse to the .vmx for your VM and click Next.
7) Give the new VM a name and select the location where you want to put it. Click Next
8) Click Next on the Options screen. You shouldn't have to change anything here.
9) Click Finish on the Summary screen to begin the conversion.
10) The conversion should start. This will take a LOOONG time so be patient.
11) Hopefully all went well, if it did, you should see that the conversion is completed:
12) Now open up VirtualBox and click New.
13) Give your VM a name and select what Type and Version it is. Click Next.
14) Select the size of the memory you want to give it. Click Next.
15) For the Hard Drive, click Use and existing hard drive file and select the newly converted .vmdk file.
16) Now Click Settings and select the Storage menu. The issue is that by default VirtualBox will add the drive as an IDE. This won't work and we need as we need to put it on a SCSI controller.
17) Select the IDE controller and the Remove Controller button.
18) Now click the Add Controller button and select Add SCSI Controller
19) Click the Add Hard Disk button.
20) Click Choose existing disk
21) Select your .vmdk file. Click OK
22) Select the System menu.
23) Click Enable IO APIC. Then click OK
24) Congrats!!! Your VM is now confgiured! Click Start to startup the VM!
I will suggest something totally different, we used it at work for many years ago on real computers and it worked perfect.
Boot both old and new machine on linux rescue Cd.
read the disk from one, and write it down to the other one, block by block, effectively copying the dist over the network.
You have to play around a little bit with the command line, but it worked so well that both machine complained about IP-conflict when they both booted :-) :-)
cat /dev/sda | ssh user#othermachine cat - > /dev/sda
QEMU has a fantastic utility called qmeu-img that will translate between all manner of disk image formats. An article on this process is at http://thedarkmaster.wordpress.com/2007/03/12/vmware-virtual-machine-to-virtual-box-conversion-how-to/
I recall in my head that I used qemu-img to roll multiple VMDKs into one, but I don't have that computer with me to retest the process. Even if I'm wrong, the article above includes a section that describes how to convert them with your VMWare tools.
Note: I am not sure this will be of any help to you, but you never know.
I found this link:http://www.ubuntugeek.com/howto-convert-vmware-image-to-virtualbox-image.html
ENJOY :-)
This error occurs because VMware has a bug that uses the absolute path of the disk file in certain situations.
If you look at the top of that small *.vmdk file you'll likely see an incorrect absolute path to the original VMDK file that needs to be corrected.

How to detect launching from a "Startup"-folder shortcut?

I need to add the "Run when Windows starts" option to my program CintaNotes, but do not want to sacrifice the "cleanness" of it: it is a 100% portable freeware and should not leave traces in the system.
I've come up with the idea to autodetect running from the Startup shortcut and automatically minimizing to the system tray. Is there a way to do it? I'm using C++ and raw Winapi.
So:
- No writing to the registry
- No command line parameters
Thanks!
UPD: The question is NOT how to minimize to the system tray! The question is how can a program differentiate between being run normally and being run from a startup-folder shortcut without using registry and command-line parameters.
Your "cleanness" appears to be an artificial construct at best. If you're telling the user to create a shortcut in the start-up folder, you're already leaving a footprint (and, to be honest, there's little difference between "myprog.exe" and "myprog.exe -m"). In that case, there are some easier approaches than automagically trying to detect where you're running from.
I would simply provide a menu option in your program ("Install") which would then install the software to a fixed-disk location (as opposed to the flash drive), including the requisite Programs entry (Start, All Programs, CintaNotes).
As part of that process (or even after install), you can let them specify "Start with Windows" and then you create the start-up folder shortcut for the user with a command line option so your program can tell if it's running that way. There's no point in allowing "Start with Windows" unless the program's available (i.e., on the fixed disk, not the flash drive).
Your user need never have to worry about creating shortcuts at all, let alone ones with parameters. And this gives your program the control over how it's run - two modes, "installed" (and start minimized) or "running without installing first" (and start normal).
Something like finding the directory of the executable won't work simply because the start-up folder item that starts your program is likely to be a shortcut to it, so you won't have that path.
I think this is a classic case of asking the wrong question. In answer to your specific question, I say: no, there is no way to tell that you've been launched from a start up folder entry without some command-line parameters. But, I've been wrong before, just ask my wife :-). Some-one else may well know a way.
Adding this an an edit since comments don't allow enough space:
You ask:
What do you think of just disabling the "Start when Windows starts" option when program detects it is being run from the flash drive? I guess there's a way to detect this.
That's a good idea since it doesn't make sense to allow automatic running until it's installed (since the flash drive may not be there). One possibility:
1/ Running from flash, you start with "myprog.exe" since you just double-clicked the executable and you run in a normal window. This presents the option to "Install to fixed disk" but not "Start with Windows". As part of the install process, you may allow them to set up the installed copy to "Start with Windows" but not the current running copy.
2/ Your installed program can be set up to run as "myprog.exe -i", since you create the item in Start/AllPrograms. This would disable "Install to fixed disk" but allow you to toggle "Start with Windows". You can choose whether you want explicit running (by the user) to start normal or minimized (see (3)).
3/ The shortcut in StartUp can be "myprog.exe -s" (again, you control this because you created it). This is identical to (2) but starts minimized (if (2) started minimized anyway, there's no distinction between (2) and (3) and no reason for different command-line options).
That way, each option can have different behavior as you see fit.
Even though you have already solver the problem I just wanted to say that it's possible to detect if the program was launched from shortcut. Once you have the shortcut path you can compare it to startup folder.
See the section "Detect if an executable was started from a Short-Cut
" at Undocumented CreateProcess
Check the registry for this key.
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run and add a new String key with the path of your application as value. and use NOTIFYICONDATA structure for minimizing your application to the tray.
Why don't you use an argument to start the application minimized like:
YourProgram.exe -m