How do I delete a virtualbox machine in the GURU_MEDITATION error state? - virtualization

How do I delete a VirtualBox machine in the GURU_MEDITATION error state? Is it enough just to delete the directory while VirtualBox is not running?
EDIT: After posting, I deleted the entire directory that "Show in File Manager" navigates to.
It looks like:
Note that there is no power off, and even remove is greyed out. I believe this is the exact same as it looked even before I deleted the directory.
EDIT 2: I tried the command line poweroff after deleting the files. It hangs:
vboxmanage controlvm wmf-vagrant_1354733432 poweroff 0%...10%...20%...
EDIT 3: It also fails to unregister it from the command-line:
VBoxManage unregistervm wmf-vagrant_1354733432 --delete VBoxManage:
error: Cannot unregister the machine 'wmf-vagrant_1354733432' while it
is locked VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE
(0x80bb0007), component Machine, interface IMachine, callee
nsISupports Context: "Unregister(fDelete ?
(CleanupMode_T)CleanupMode_DetachAllReturnHardDisksOnly :
(CleanupMode_T)CleanupMode_DetachAllReturnNone,
ComSafeArrayAsOutParam(aMedia))" at line 160 of file
VBoxManageMisc.cpp

Kill the VBoxHeadless process and run "vagrant destroy"
Destroying vagrant and sending the kill signal with the "killall" command looks like:
killall -9 VBoxHeadless && vagrant destroy

If you can't power off the machine from VirtualBox GUI, then try from the command line using vboxmanage command (VBoxManage on OS X), e.g.:
vboxmanage controlvm NAMEOFVM poweroff
Change NAMEOFVM with the name from vboxmanage list vms command.
then unregister and delete the VM:
vboxmanage unregistervm NAMEOFVM --delete
Or delete it manually:
rm -fr ~/"VirtualBox VMs/NAMEOFVM"

I hit this problem. Eveything I read recommend that you should always manage the boxes via Virtual Box, not directly access files. But when I had an invalid box, the unregistervm command refused to delete it and vagrant destroy did not work. In the end the following process worked.
Kill all running VBox* processes
Delete the folder "boxname" from the folder "VirtualBox VMs"
Edit the file "VirtualBox.xml" and remove the tag corresponding to the invalid box.
I then ran this command the verify the box was gone.
VBoxManage list vms
After that I was able to create a new vm with the same name.

I had a VM that got in a similar state
$ vagrant up
Bringing machine 'tempu' up with 'virtualbox' provider...
==> mms: Checking if box 'hashicorp/precise64' is up to date...
==> mms: Resuming suspended VM...
==> mms: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "9fcf2203-d4b3-47a1-a307-61bfa580bd28", "--type", "headless"]
Stderr: VBoxManage: error: The machine 'temp-ubuntu' is already locked by a session (or being locked or unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component Machine, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LaunchVMProcess(a->session, sessionType.raw(), env.raw(), progress.asOutParam())" at line 592 of file VBoxManageMisc.cpp
I looked for a process called VBoxHeadless, but it wasn't running.
I then ran ps and found this process with the same vm id:
$ ps aux | grep -i virtualbox
user 63466 0.0 0.1 2523608 8396 ?? S 9:36am 0:02.67 /Applications/VirtualBox.app/Contents/MacOS/VBoxManage showvminfo 9fcf2203-d4b3-47a1-a307-61bfa580bd28 --machinereadable
Killing that process fixed the problem and VM started correctly after running vagrant up

This is a script I use when I get desperate. It wipes as much trace of any VM from the machine as I can find:
VBoxManage list runningvms | awk '{print $2}' | xargs --no-run-if-empty -t -n1 -IXXX VBoxManage controlvm XXX poweroff
VBoxManage list vms | awk '{print $2}' | xargs --no-run-if-empty -t -n1 VBoxManage unregistervm
killall -9 VBoxHeadless
rm -rf ~/Virtualbox\ VMs/*

I am using Debian Wheezy on a 64-bit multiple-processor host. I was able to solve it eventually by removing all VirtualBox data (though you did not need to delete the Vagrant base box):
Close Virtualbox if running
sudo apt-get remove --purge virtualbox
Move or delete ~/.VirtualBox and ~/VirtualBox\ VMs/. If you're not sure, back them up to a safe place.
Restart.
Reinstall virtualbox.
Use virtualbox/vagrant as normal.
There may be a less disruptive way (e.g. removing only parts of these directories). In my case, fortunately I was using only one VM at the time.

In my case, I wanted to delete ALL Vagrant boxes I currently have on my system by a command line, I did that by:
$ vagrant box list | cut -f 1 -d ' ' | xargs -L 1 vagrant box remove -f --all
Of course, after making sure no further process is attached any more:
killall -9 VBoxHeadless && vagrant destroy
No matching processes belonging to you were found

On windows 10, i solved this problem setting Default firewall configurations back.
Hope it helps...

I've been struggling with frozen Virtual Box instances created earlier using Vagrant.
Luckily found a solution mentioned in similar ticket
so, to recap, if your getting Timeout error or Vagrant complaining it can't provision or any other kind of related issue with Virtual Box try:
List virtual box instances first: VmboxManage list vms
Stop the virtual box instances using id|names of previous command: VBoxManage startvm VMNAME/id --type emergencystop
List vagrant boxes with vagrant box list
Remove one or more causing issues vagrant boxes: vagrant remove box ${box-name}
Afterwards, try vagrant up again and hopefully you will be back to business.
Good luck!

Open the task manager or system monitor and hover with the mouse over the VBoxHeadless to see the name of the VM and kill the process.
Now you can remove the VM with the VirtualBox Manager GUI.

Run vagrant global-status
Identify the vm id
Run vagrant destroy [vm id]

You can use below command to delete VM from vritual box-
vagrant destroy
And use below command to create VM and start again-
vagrant up

Related

How can I start PostgreSQL on Windows?

I have installed Postgresql on my Windows 10 PC. I have used the pgAdmin II tool to create a database called company, and now I want to start the database server running. I cannot figure out how to do this.
I have run the start command on the postgres command line, and nothing seems to happen.
What I doing is:
postgres=# pg_ctl start
postgres=# pg_ctl status
postgres=# pg_ctl restart
postgres=# pg_ctl start company
postgres=# pg_ctl status
.....-> I am seeing nothing returned.
Go inside bin folder in C drive where Postgres is installed.
run following command in git bash or Command prompt:
pg_ctl.exe restart -D "<path upto data>"
Ex:
pg_ctl.exe restart -D "C:\Program Files\PostgreSQL\9.6\data"
Another way:
type "services.msc" in run popup(windows + R).
This will show all services running
Select Postgres service from list and click on start/stop/restart.
Thanks
pg_ctl is a command line (Windows) program not a SQL statement. You need to do that from a cmd.exe. Or use net start postgresql-9.5
If you have installed Postgres through the installer, you should start the Windows service instead of running pg_ctl manually, e.g. using:
net start postgresql-9.5
Note that the name of the service might be different in your installation. Another option is to start the service through the Windows control panel
I have used the pgAdmin II tool to create a database called company
Which means that Postgres is already running, so I don't understand why you think you need to do that again. Especially because the installer typically sets the service to start automatically when Windows is started.
The reason you are not seeing any result is that psql requires every SQL command to be terminated with ; in your case it's simply waiting for you to finish the statement.
See here for more details: In psql, why do some commands have no effect?
If you have installed postgres via the Windows installer you can start it in Services like so:
After a lot of search and tests i found the solution :
if you are in windows :
1 - first you must found the PG databases directory
execute the command as sql command in pgAdmin query tools
$ show data_directory;
result :
------------------------
- D:/PG_DATA/data -
------------------------
2 - go to the bin directory of postgres in my case it's located "c:/programms/postgresSql/bin"
and open a command prompt (CMD) and execute this command :
pg_ctl -D "D:\PSG_SQL\data" restart
This should do it.
The simplest way to start/stop/restart the installed PostgreSQL Server on your Windows device is as follows:
Start -> net start postgresql-x64-14
Stop -> net stop postgresql-x64-14
Restart -> net stop postgresql-x64-14 && net start postgresql-x64-14
The version number must be changed to take into account the installed version of your PostgreSQL Server.
For windows the following command worked well for me
pg_ctl.exe restart -D "<path_to_data>"
Eg: pg_ctl.exe restart -D "D:\Program Files\PostgreSQL\13\data"
If you are getting an error "psql.exe' is not recognized as an internal or external command,... "
There can be :
Causes
System is unable to find the psql.exe tool, because the path to this tool is not specified in the system environment variable PATH
or
- PostgreSQL Database client not installed on your PC
Since you have already installed PostgreSQL the latter can not be the issue(assuming everything is installed as expected)
In order to fix the first one "please specify the full path to the bin directory in the PostgreSQL installation folder, where this tool resides."
For example
Path: "C:\Program Files\PostgreSQL\10\bin"
I found using
net start postgres_service_name
the only reliable way to operate Postgres on Windows
first find your binaries file where it is saved.
get the path in terminal mine is
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries
(1)\pgsql\bin
then find your local user data path, it is in mostly
C:\usr\local\pgsql\data
now all we have to hit following command in the binary terminal path:
C:\Users\LENOVO\Documents\postgresql-9.5.21-1-windows-x64-binaries (1)\pgsql\bin>pg_ctl -D "C:\usr\local\pgsql\data" start
all done!
autovaccum launcher started! cheers!
Remove Postmaster file in "C:\Program Files\PostgreSQL\9.6\data"
and restart the PostgreSQL services
There are different way to open PostgreSql database .
1> One of them is by going windows and select pgAdmin4 or pgAdmin3 depends to version you use and entering password you can access you database .
2> Another one is by terminal :
To able to select from terminal you have to add the path of your installed postgresql by going enviroment variables . To do that got to installed postgresql file and select the path of bin and add to enviroment variable of window setting .
after that you can type in terminal : psql -U postgres -h localhost
Hit enter and it ask you password . After giving password you can create database and tables and can access it .
I was try to solve the problem with Windows Terminal and I've cannot to solve it. Use Windows R + cmd (if you are using Windows) for it work!
The easiest way to enable pg_ctl command is to go to your PostgreSQL directory ~\PostgreSQL\version\bin\ and execute the pg_ctl.exe. Afterwards the pg_ctl commands will be available.

Setting up mongoDB raspberry pi

i just installed mongopi from https://github.com/RickP/mongopi and it working correctly after doing a few adjustments mainly $ sudo chown $USER /data/db. However my mongo and mongod calls arent persistent i do PATH=$PATH:/opt/mongo/bin/ &
export PATH however this does not last on next ssh session. Also how can I make mongo initialize at startup? I did all the steps from the github repo.
For the path part of the question:
To get the path working you should put it in a script that runs every time you log in. Generally there is a rc-file for you shell in your home directory. Type
echo $SHELL
to see what shell you are running. Go to your home directory:
cd
and then open the file that is called .(your shell)rc - that is, if you are running bash, open .bashrc
nano .bashrc
add the path at the end of this file:
PATH=$PATH:/opt/mongo/bin
export PATH
For the initialization part of the question:
Download and edit this script: Mongo init.d at github
You'll need to change the value of the DEAMON at line 50. I had some other troubles, but you should probably be ok if you create a configuration file (that probably could be empty) and refer to it from line 57. Also, you need to add a mongodb user that the server should run as. You can edit this on line 95, but the default is probably a good idea.
When all this editing is done, you move the file to /etc/init.d/mongodb, like so:
sudo mv init.d /etc/init.d/mongodb
and then add it to the systems start-up routine
sudo update-rc.d mongodb defaults
(This is presuming you run debian. Other distros may have other commands to do this.)
Now, see to that you are not running mongod some other place, and control the service by
sudo service mongodb start
service mongodb status
sudo service mongodb stop
... and so on. This will also run automatically on start-up and shutdown.

QEMU - redirect guestOS booting to host machine

I used QEMU to bring CentOS.img (downloaded some where). I find the boot screen of CentOS.img took over the console session of the current terminal and I could see CentOS booting up process and prompts me to the login screen of the guestVM CentOS. This is really helpful for me as I ran QEMU instance from remote console machine.
Now, I created a new RHEL.img using iso and when I try to boot it; I was not able to see anything in the screen other then some symbol of (Y) :(
$>/usr/libexec/qemu-kvm -hda ./RHEL.img -bios bios.bin -nographic -net nic,model=e1000,macaddr=00:AD:BE:EF:4F:BD -net tap,script=./qemu-ifup -m 1024 -smp 2
...Y
on investigation, I find we can do it by redirecting RHEL boot to console using
# virt-edit RHEL_VM /boot/grub/grub.conf
...
title rhel (2.6.38.6-26.rc1.fc15.x86_64)
root (hd0,0)
kernel /vmlinuz ro [...] console=ttyS0
...
but nothing worked out. I am trying to bring the rhel VM session to the same console where I invoked qemu-kvm from remote terminal. Thanks in advance.
NOTE: I don't have GUI enabled on the physical host machine.
You could try adding a serial port and sending output to that. Although you do have to be able to boot it at least once to do these steps...
You might get lucky if you just add a serial port to the qemu command line and then telnet to that; hoping linux detects this and sends output there
edit /etc/init/ttyS0.conf and add
respawn
console none
start on (local-filesystems)
stop on [!12345]
script
exec start ttyS0
end script
then
ln -s /etc/init/ttyS0.conf /etc/rc2.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc0.d/S99ttyS0.conf
ln -s /etc/init/ttyS0.conf /etc/rc6.d/S99ttyS0.conf
then do this to enable grub
Edit /etc/default/grub
1. Edit the GRUB_CMDLINE_DEFAULT="" line to start the console on /dev/ttyS0
GRUB_CMDLINE_LINUX_DEFAULT="console=tty0 console=ttyS0,38400n8"
2. Add a serial console section
# Serial console
GRUB_TERMINAL=serial
GRUB_SERIAL_COMMAND="serial --speed=38400 --unit=0 --word=8 --parity=no --stop=1"
3. Rebuild the grub.cfg file
sudo sh
grub-mkconfig > /boot/grub/grub.cfg

Rails, Deploying With Capistrano to a VPS on Unicorn

I need help debugging the following issue. It's my first time deploying, and I haven't been able to come up with the solution.
* 2012-12-05 18:37:44 executing `deploy:start'
* executing "/etc/init.d/unicorn_blog start"
executing command
/etc/init.d/unicorn_blog: 24: kill: No such process
master failed to start, check stderr log for details
Here's the stderr
/.../unicorn/socket_helper.rb:140:in `initialize': Address already in use - /tmp/unicorn.my_app.sock (Errno::EADDRINUSE)
It looks like you have a zombie Unicorn process running with a PID different from the one that was recorded by init.d. I would try running $ ps aux | grep unicorn to find the zombie process, then kill it.
Unsure how it works, but the following solution actually worked.
lsof /tmp/unicorn.my_app.socket
lists the pids
kill -9 pid
(replace 'pid' with one of those listed)
Then cap deploy:start from the local terminal.
source: Unicorn/Nginx process missing, socket open
I had to
sudo rm /tmp/unicorn.my_app.sock
and
sudo /etc/init.d/unicorn_myapp start
I got same error, and i fixed as below:
SSH to server where your project deploy to, and run these command
ps -ef | grep unicorn => list pid of unicorn. Find your process id of unocorn master.
Replace pid on "unicorn.my_app.sock" with above pid.
Try to deploy again with capistrano.

how to create a shared folder on Virtual machine

We have a windows Oracle vm installed on our solaris machine which will be launched using Xmanager.
Can some one please help me with the following questions
I can use the folders on solaris from windows VM using "\vboxsrv" but how can i do viceversa
How can i access files on windows vm from solaris machine
And can i update the files on windows vm directly without opening it through xmanager
I found a way to execute a command on virtual machine from Hostmachine. Using this command tool I am accessing files or folders in virtual machine
The command line tool is VBoxManage - This has lot of parameters using we can do any thing on virtual machine from VM starting to shutdown
/opt/VirtualBox > VBoxManage Startvm "windows"
/opt/VirtualBox > VBoxManage guestcontrol "windows" execute --image "cmd.exe" --username root --password 12345 --wait-exit --wait-stdout -- -l /usr