Where does Vagrant download its .box files to? - virtual-machine

What happens to the .box file after the following command is executed?
vagrant box add lucid32 http://files.vagrantup.com/lucid32.box
I can't find the lucid32.box file on the file system after download has completed.

As mentioned in the docs, boxes are stored at:
Mac OS X and Linux: ~/.vagrant.d/boxes
Windows: C:/Users/USERNAME/.vagrant.d/boxes

On Mac/Linux System, the successfully downloaded boxes are located at:
~/.vagrant.d/boxes
and unsuccessful boxes are located at:
~/.vagrant.d/tmp
On Windows systems it is located under the Users folder:
C:\Users\%userprofile%\.vagrant.d\boxes
Hope this will help. Thanks

To change the Path, you can set a new Path to an Enviroment-Variable named:
VAGRANT_HOME
export VAGRANT_HOME=my/new/path/goes/here/
Thats maybe nice if you want to have those vagrant-Images on another HDD.
More Information here in the Documentations: http://docs.vagrantup.com/v2/other/environmental-variables.html

The actual .box file is deleted by Vagrant once the download and box installation is complete. As mentioned in other answers, whilst downloading, the .box file is stored as:
~/.vagrant.d/tmp/boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
where the file name is 'box' followed by a 40 byte hexadecimal hash. A temporary file on my system for example, is:
~/.vagrant.d/tmp/boxc74a85fe4af3197a744851517c6af4d4959db77f
As far as I can tell, this file is never saved with a *.box extension, which explains why the searches above failed to locate it. There are two ways to retrieve the actual box file:
Download the .box file from vagrantcloud.com
Find the box you're interested in on the atlas. For example,
https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
Replace the domain name with vagrantcloud.com. So https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
becomes https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box.
Add /providers/virtualbox.box to the end of that URL. So https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1 becomes https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box
Save the .box file
Use the .box as you wish, for example, hosting it yourself and pointing config.vm.box_url to the URL. OR
Get the .box directly from Vagrant
This requires you to modify the ruby source to prevent Vagrant from deleting the box after successful download.
Locate the box_add.rb file in your Vagrant installation directory. On my system it's located at /Applications/Vagrant/embedded/gems/gems/vagrant-1.5.2/lib/vagrant/action/builtin/box_add.rb
Find the box_add function. Within the box_add function, there is a block that reads:
ensure
# Make sure we delete the temporary file after we add it,
# unless we were interrupted, in which case we keep it around
# so we can resume the download later.
if !#download_interrupted
#logger.debug("Deleting temporary box: #{box_url}")
begin
box_url.delete if box_url
rescue Errno::ENOENT
# Not a big deal, the temp file may not actually exist
end
end
Comment this block out.
Add another box using vagrant add box <boxname>.
Wait for it to download.
You can watch it save in the ~/.vagrant.d/tmp/ directory as a boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX file.
Rename the the file to something more useful. Eg, mv boxXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX trusty64.box.
Why would you want this?
For me, this has been useful to retrieve the .box file so it can be hosted on local, fast infrastructure as opposed to downloading from HashiCorp's Atlas box catalog or another box provider.
This really should be part of the default Vagrant functionality as it has a very definitive use case.

#Luke Peterson: There's a simpler way to get .box file.
Just go to https://atlas.hashicorp.com/boxes/search, search for the box you'd like to download. Notice the URL of the box, e.g:
https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20150530.0.1
Then you can download this box using URL like this:
https://vagrantcloud.com/ubuntu/boxes/trusty64/versions/20150530.0.1/providers/virtualbox.box
I tried and successfully download all the boxes I need. Hope that help.

On Windows, the location can be found here. I didn't find any documentation on the internet for this, and this wasn't immediately obvious to me:
C:\Users\\{username}\\.vagrant.d\boxes

In addition to
Mac:
~/.vagrant.d/
Windows:
C:\Users\%userprofile%\.vagrant.d\boxes
You have to delete the files in VirtualBox/OtherVMprovider to make a clean start.

On Windows 10 with Vagrant 2.2.2, setting the environment variable VAGRANT_HOME will ensure that boxes are downloaded to a subfolder of the folder specified for VAGRANT_HOME.
In my case I set VAGRANT_HOME to e:\vagrant_home, and the boxes get stored under e:\vagrant_home\boxes.
This works for me.
That's where the boxes are stored. The virtual machines are being created in the folder configured in Virtual Box. To set the VirtualBox VM storage folder, go to: VirtualBox GUI --> File --> Preferences --> General --> Default Machine Folder.

Related

How to get Docker Desktop on Mac to point to new location of VM Image?

Docker Desktop supports moving the VM Image that it uses onto another drive if needed. On my Mac Mini (2018) I have moved it to an external SSD in order to enlarge it more than the internal storage would have allowed.
The external SSD was named "Extra Space", which (ironically) became a problem when I also tried to use the SSD for other non-Docker development and discovered that some of the Ruby Gems I am using have problems with spaces in path names.
I decided that I would have to rename the drive to "ExtraSpace" (without the "extra" space), but then Docker was not able to find its VM Image. I was unable to use the built-in location chooser ("Preferences" -> "Resources" -> "Advanced" -> "Disk Image Location") because that tool assumes that it is moving the image from one location to another but in my case the image is not being moved, only the path to the existing image is changing.
I looked through the Docker configuration in ~/Library/Containers/com.docker.desktop/ and found the path to the image in Library/Containers/com.docker.docker/Data/vms/0/hyperkit.json. I tried changing it there, but Docker Desktop would not start.
In the error logs, I found lots of messages like this:
time="2021-10-31T15:06:43-04:00" level=error msg="(5487d9bc) 4ecbf40e-BackendAPI S->C f68f0c84-DriverCMD GET /vm/disk (925.402µs): mkdir /Volumes/Extra Space: permission denied"
common/cmd/com.docker.backend/internal/handlers.(*VMInitHandler).VMDiskInfo(0x58c13b8, {0x58b94a0, 0xc0001d82a0})
common/cmd/com.docker.backend/internal/handlers/vminit.go:39 +0x42
Why does Docker Desktop not follow the VM configuration file to find the location of the image? Is there somewhere else I have to change it?
After a lot more searching, I found the following additional files that need to be updated with the new path:
~/Library/Preferences/com.electron.docker-frontend.plist
~/Library/Preferences/com.electron.dockerdesktop.plist
~/Library/Group Containers/group.com.docker/settings.json
Once I had updated all of these files with the new path, Docker Desktop was able to start up correctly.

AMPPS - The file /Applications/AMPPS/ampps/softaculous/includes/enduser.php is corrupted

I've had this issue twice now, just randomly happened.
When I try to view the Ammps 'Home' Dashboard I get the following error:-
The file /Applications/AMPPS/ampps/softaculous/includes/enduser.php is
corrupted.
I had to re-install to fix this last time but since then (a few days ago) this has happened again?
Anybody know why this is happening and how to fix it?
I am using Version: 3.8
Update
I've done another clean install (backed up www and all the databases beforehand). I noticed there isn't even the directory /Applications/AMPPS/ampps/softaculous/includes/.
Seems to be another effected file as well:
/Applications/AMPPS/ampps/softaculous/includes/main/functions.php is
corrupted.
Upon opening these files, it appears a massively long string of characters as been added after the closing PHP tag. Deleting this string had no effect, the same errors persist.
Anyway, I've uploaded the files of Ampps for Mac which you can download here:
https://drive.google.com/file/d/18nA-ldR5BamLLqnEU0nC4Gx-PmzWSwt0/view?usp=sharing
Going to see if I can get it back working once I merge the files together (except the www folder)
Update 2:
You can now download Ampps 3.9 from their official website:
https://ampps.com/download
1.+ don't forget to save database (/var) and domains information (/ampps/data/domains) before replacing files
Doing a clean install of Ampps 3.8 will rectify the problem which is what I had to do. Frustratingly, some people including myself have experienced the issue coming back after a few days. Until there is a permanent fix for this either by an update/patch from Softaculous, a way to rectify this without having to reinstall Ampps is by doing the following:-
Take a backup of your /Applications/AMPPS/www directory
Download the Mac files from a clean installation here;
https://drive.google.com/file/d/18nA-ldR5BamLLqnEU0nC4Gx-PmzWSwt0/view?usp=sharing
Replace the existing Ampps directory with the files from the
download link
Move your /www/ folder back to the same location
You should then be able to access the Home dashboard and everything should work as normal.
As Nika mentioned, don't forget to save database (/var) and domains information (/ampps/data/domains) before replacing files (/www)
Edit 1:
Seems my version of Ampps 3.8 got updated to 3.9, I've not had any issues since this has happened.
Please create a backup first!
Shutdown AMPPS. I have fixed mine locally by replacing the enduser.php with the one from here https://files.ampps.com/5.3.2.zip.
Then after that I have replaced all the IonCube loaders with the ones you can download from here: https://www.ioncube.com/loaders.php. Source and how-to: https://www.softaculous.com/board/index.php?tid=13497&title=Ioncube_Loader_Error
Start AMPPS.
To check if you need to replace another corrupt file check error_log in your logs folder.

Oracle virtual box inaccessible

I am using Oracle Virtual Box version 4.2.16 r86992. Everything was fine until yesterday shutdown.
Today, it shows inaccessible and throws this error:
Runtime error opening C:\Users\xxxxxx\VirtualBox VMs\vBoxxxxXubuntu_Beta\vBoxxxxXubuntu_Beta.vbox for reading: -102 (File not found.).
D:\tinderbox\win-4.2\src\VBox\Main\src-server\MachineImpl.cpp[725] (long __cdecl Machine::registeredInit(void)).
It's good to restore this to working, It would save lot of time and restore configuration settings and data. Thanking your support.
This normally happens if the host OS crashes or you pull the plug on it, leaving the .vbox file unsaved.
In the location:
C:\Users\xxxxxxx\VirtualBox VMs\vBoxxxxXubuntu_Beta\
you should find two files:
vBoxxxxXubuntu_Beta.vbox-prev
vBoxxxxXubuntu_Beta.vbox-tmp
Copy vBoxxxxXubuntu_Beta.vbox-prev to vBoxxxxXubuntu_Beta.vbox.
Select vBoxxxxXubuntu_Beta.vbox, in the VBox manager, right click, and then left click on refresh.
Observe that it now shows Powered Off.
Now you are good to go.
Based on my experience, I was on Windows 7 and running Ubuntu 14.04 as guest OS on Virtual Machine.
Go to your Virtualbox folder (in my case):
C:\Users\Dev12\VirtualBox VMs\Ubuntu
You'll see files with extensions: Ubuntu.vbox-tmp or Ubuntu.vbox-prev
Remove -tmp from file name Ubuntu.vbox-tmp so that it reads as Ubuntu.vbox
Exit from Virtual Machine and start it again.
You should now see error gone away.
The virtual box files with extension .vbox contain metadata the virtualbox hypervisor requires to resolve the guest virtual OS' configuration.
If the main .vbox file is corrupted (i.e. reporting that it is empty) then use the backup .vbox-prev file to recover the contents of the original file.
Do this by renaming the empty .vbox files a temporary name (e.g. rename originalVM.vbox to originalVM-empty.vbox).
Then make a copy of the backup file originalVM.vbox-prev, where the copy will have the same name as the original but with the word "copy" appended to it (i.e. originalVM.vbox-prev is renamed to originalVM (copy).vbox-prev).
It is important to retain the original backup .vbox-prev file it should not be altered or itself renamed.
Now go rename the copy of the newly created .vbox-prev file originalVM (copy).vbox-prev to the original name of the empty .vbox file and be mindful to also change it extension from .vbox-prev back to just .vbox.
That is rename originalVM (copy).vbox-prev back to originalVM.vbox. Now that this is done you may add the .vbox file (guest os) back into the VBOX hypervisor. This will recover the state and snapshot of the "inaccessible" guest VM. Now delete the original empty .vbox file.
I've faced the same issue using CentOs 6.8 on a VirtualBox 5.1 installed in Windows 7 and AjayKumarBasuthkar's solution worked perfectly for me:
I went to C:\Users\\VirtualBox VMs\CentOS6.8
Made a copy of the file CentOS6.8.vbox-prev and gave it the name of CentOS6.8.vbox
Went to the VirtualBox GUI, right-clicked the VM instance and hit refresh
The CentOS instance went from the State Inaccessible to Powered Off
VirtualBox 4.3 is released and could it be that you've updated or there was some issues while updating?
In any case if you are not able to bring up the Virtualbox, remember to backup the VirutalBox VMs folder and going for a fresh install should be the best way forward.
I faced the same problem and I resolved by doing following in Oracle Virtual box 4.3.28 with Ubuntu 14.04 LTS, when Virtual box VM was closed.
Removed ubuntu.vbox to another folder outside virtual box folder
removed -prev from file ubuntu.vbox-prev
start oracle virtualbox, it works excellent.
On a Windows 7 Host, I found that Daemon Tools service had a hold on the file.
The solution was to uninstall Daemon Tools, but I suspect if you stop the service and remove the file association, you would be sorted.
The other issue might be that if your Virtual Machine was on an external hard drive, it is possible that the drive letter has changed. If so, go to Computer Management, and select the hard drive and right click to change the drive letter and save (Note that this is for Windows).
This is going to sound stupid but try to reinstall VB. It may work.
I am adding one critical and important comment to the previous great answers. Make sure that the original .vbox file is corrupted and empty before you copy the content from the.vbox-prev file. If it is not the case and you find it with lines and readable content, don't replace the content of the .vbox.
Changes made to the VM directly before the VM got inaccessible might not be updated in the .vbox-prev backup file . The changes could not be synced with those changes before the OS upgrade or system changes that led to the inaccesable issue.
If you find your VM not accessible after an OS upgrade or system change, first check the.vbox file if it is still readable by a text editor and it has lines. Then you just need to delete the VM from the VirtualBox manager list(just remove the appliance from the list and don't remove files) . Then reopen the.vbox file and it should work perfectly.
If the original.vbox file is corrupted or empty when you open it with a text editor, then and only then, you can copy the content from the .vbox-prev and follow the instructions highlighted.
This was my experience, and I wanted to share it with you to avoid losing some last minute changes before the OS upgrade or crash.

#1 - Can't create/write to file '/var/folders/

I get the following error(see. figure) in my Xampp and can not access mySQL through XAMPP and phpMyAdmin. In this link-1 and link-2 possible solution is given; but none of them woks in Mac OS 10.9
I assume the problem is with configuration file my.cnf which is located in the /Applications/XAMPP/xamppfiles/etc/my.cnf.
Any suggestion will be appreciate. Thanks.
Completely stop XAMPP, this means stop apache, ftp and mysql.
Open the program called Terminal.
Type in sudo -i to become root (or do su root if the first doesn’t work for you).
You are most probably asked for a password which you have to enter while no characters are displayed.
Execute chmod 600 /Applications/XAMPP/xamppfiles/etc/my.cnf .
Exit your root shell with exit or just close Terminal.
Restart XAMPP (apache, ftp and mysql).
From: http://slopjong.de/2009/08/31/houston-i-cant-write-to-file/
Solution
Reinstall Xampp. Before reinstalling delete all the files, take away your htdoc and database folder to other place of your hdd.
The database location in Mac OS-10.9 is
cd '/Applications/XAMPP/xamppfiles/var/mysql/'
Htdoc location
cd '/Applications/XAMPP/xamppfiles/htdocs/'
When you complete reinstallation put all the folders to corresponding location and your database will be automatically update.
I looked some other solution but none of them seems work. I was scare if I remove the database to other location and import later will it work or not. And luckily it works, but as precaution careful when you remove big database.

CGI script create file with wrong permissions

I'm using standard routers2.cgi to display MRTG graphs using .rrd data files in a linux server.
This routers.cgi file reads rrd data files and create MRTG graphs to display them from a web url.
This system is working fine. Only problem is the .png graphs creates with 600 permissions. But it needs 644 permission to display from the web page. So I had to change the permissions manually. How can I fix this, any suggestions?
url:
domain.com/cgi-bin/routers2.cgi
graphs located at:
domain.com/graphs/
apache2 config:
cgi bin: <path>/domain.com/cgi-bin
doc root: <path>/domain.com/public_html/
Well finally I have fixed it.
It got fix by adding following code in top of the script. In my case a have added it just below the ##CONFIG#START# comment line in the routers2.cgi
umask(0033);