Skip to content

Latest commit

 

History

History
63 lines (58 loc) · 2.17 KB

README.md

File metadata and controls

63 lines (58 loc) · 2.17 KB

Vagrant Box Creation and Import Guide

This guide explains how to create and import Vagrant boxes for VirtualBox and VMware Workstation.
Follow these steps carefully to ensure successful box creation and import.

Prerequisites

Note

VirtualBox and/or VMware Workstation must be installed on your system.
Ensure your virtual machine has:

  • A unique VMDK file.
  • A cloned version of the VM if necessary (for testing or multiple configurations).
  • You have access to the necessary CLI tools: VBoxManage for VirtualBox. vmware-vdiskmanager for VMware.

Steps for VirtualBox

Open a terminal and navigate to the VirtualBox installation directory:

cd "C:\Program Files\Oracle\VirtualBox\"

List all existing VirtualBox VMs to identify the target VM's name or UUID:

.\VBoxManage.exe list vms

Package the VM into a Vagrant box using the VM's UUID or name:

vagrant package --base <VM_UUID_OR_NAME> --output C:\Users\{user}\Desktop\<NameBoxfile>.box

Add the packaged box to Vagrant locally:

vagrant box add <NameBox> <NameBoxfile>.box

Steps for VMware Workstation

Navigate to the VMware Workstation installation directory:

cd "C:\Program Files (x86)\VMware\VMware Workstation\"

Optimize the VMDK file by defragmenting and shrinking it (optional but recommended for performance):

.\vmware-vdiskmanager.exe -d C:\Users\<users>\VMFolder\<VMname>.vmdk
.\vmware-vdiskmanager.exe -k C:\Users\<users>\VMFolder\<VMname>.vmdk

Create a metadata.json file in the directory containing your VMDK and other VM files. The file should contain:

{
  "provider": "vmware_desktop"
}

Package all files into a .box file:

tar cvzf ../<NameBoxfile>.box ./*

Add the packaged box to Vagrant locally:

vagrant box add nixosRHK-vmware vm.box

Note

Replace <VM_UUID_OR_NAME> with the actual name or UUID of your VirtualBox VM.
Replace {user} with your actual username in file paths.
Ensure you have sufficient disk space before packaging large VMs.
Verify the integrity of your .box files before distribution or usage.