|
1 | 1 | # Setting up an Ubuntu VM with Vagrant on Windows 10 |
2 | 2 |
|
| 3 | +Table of Contents |
| 4 | +================= |
| 5 | + |
| 6 | +* [Setting up an Ubuntu VM with Vagrant on Windows 10](#setting-up-an-ubuntu-vm-with-vagrant-on-windows-10) |
| 7 | + * [Set up an Ubuntu VM](#set-up-an-ubuntu-vm) |
| 8 | + * [1\. Install VirtualBox](#1-install-virtualbox) |
| 9 | + * [2\. Install Vagrant](#2-install-vagrant) |
| 10 | + * [3\. (optional) Install Git for Windows](#3-optional-install-git-for-windows) |
| 11 | + * [4\. Create the Vagrant box](#4-create-the-vagrant-box) |
| 12 | + * [Troubleshooting](#troubleshooting) |
| 13 | + * [Login to your Vagrant machine](#login-to-your-vagrant-machine) |
| 14 | + * [Create a new SSH key](#create-a-new-ssh-key) |
| 15 | + * [Set up GitHub Access](#set-up-github-access) |
| 16 | + * [Extras](#extras) |
| 17 | +* [Table of Contents](#table-of-contents) |
| 18 | + |
| 19 | + |
3 | 20 | ## Set up an Ubuntu VM |
4 | 21 |
|
5 | | -1. Install VirtualBox (https://www.virtualbox.org/wiki/Downloads) |
6 | | - - Download and install the latest version of VirtualBox **6.0** (as of this writing, [version 6.0.22](https://download.virtualbox.org/virtualbox/6.0.22/VirtualBox-VirtualBox-6.0.22-137980-Win.exe) |
7 | | - - **Do not use VirtualBox 6.1.** It causes networking issues, and it requires Intel VT-x/AMD-v to be enabled. Even if VT-x is enabled, if Hyper-v is also enabled, VirtualBox will not be able to use it. (https://forums.virtualbox.org/viewtopic.php?f=1&t=62339 https://github.com/kubernetes/minikube/issues/4587) |
8 | | - - Follow the install and use all the defaults. |
9 | | - - After install, open the VirtualBox GUI |
10 | | - - Go to menu *File -> Preferences* |
11 | | - - In the *General* tab, look for the *Default Machine Folder* setting. |
12 | | - Set it to `C:\files\VirtualBox VMs`. |
13 | | - This will avoid your VM being created in your user's home directory, which could cause issues later. |
14 | | - - Now click *Extensions*. |
15 | | - - Make sure there is no Oracle VirtualBox Extension Pack listed. If there is, select it, and click the "X" button to the right to uninstall it. |
16 | | - The license for this Extension Pack is not free for commercial uses, and you don't need it for a basic headless Linux VM. |
17 | | - |
18 | | -2. Install Vagrant (https://www.vagrantup.com/downloads.html) |
19 | | - - Download and install the latest version of Vagrant for Windows (as of this writing, [version 2.2.9](https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.msi) |
20 | | - |
21 | | -3. Open a command-line window (cmd.exe) |
22 | | - |
23 | | -4. Run the following commands: |
| 22 | +### 1. Install VirtualBox |
| 23 | + - Download and install the latest version of VirtualBox **6.0** (as of this writing, [version 6.0.22](https://download.virtualbox.org/virtualbox/6.0.22/VirtualBox-VirtualBox-6.0.22-137980-Win.exe)) |
| 24 | + - **Do not use VirtualBox 6.1.** It causes networking issues, and it requires Intel VT-x/AMD-v to be enabled. Even if VT-x is enabled, if Hyper-v is also enabled, VirtualBox will not be able to use it. (https://forums.virtualbox.org/viewtopic.php?f=1&t=62339 https://github.com/kubernetes/minikube/issues/4587) |
| 25 | + - Follow the install and use all the defaults. |
| 26 | + - After install, open the VirtualBox GUI |
| 27 | + - Go to menu *File -> Preferences* |
| 28 | + - In the *General* tab, look for the *Default Machine Folder* setting. |
| 29 | + Set it to `C:\files\VirtualBox VMs`. |
| 30 | + This will avoid your VM being created in your user's home directory, which could cause issues later. |
| 31 | + - Now click *Extensions*. |
| 32 | + - Make sure there is no Oracle VirtualBox Extension Pack listed. If there is, select it, and click the "X" button to the right to uninstall it. |
| 33 | + The license for this Extension Pack is not free for commercial uses, and you don't need it for a basic headless Linux VM. |
| 34 | + |
| 35 | +### 2. Install Vagrant |
| 36 | + - Download and install the latest version of Vagrant for Windows (as of this writing, [version 2.2.9](https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.msi)) |
| 37 | + |
| 38 | +### 3. (optional) Install Git for Windows |
| 39 | + - Download at https://gitforwindows.org/ |
| 40 | + - This is only used to download the files in this Git repo. |
| 41 | + You can skip this step if you download each file in this repo and put them in the `devbox` folder shown in the next step. |
| 42 | + However, using Git will allow you to `git pull` any updates to this repo in the future. |
| 43 | + |
| 44 | +### 4. Create the Vagrant box |
| 45 | + - Open a command-line window (`cmd.exe`) and run the following commands: |
24 | 46 | ``` |
25 | 47 | C:\Users\willis> mkdir c:\files\vagrant\devbox |
26 | 48 | C:\Users\willis> cd c:\files\vagrant |
27 | 49 | C:\files\vagrant> git clone https://github.com/pwillis-els/vagrant-ubuntu-windows-10.git devbox |
28 | 50 | C:\files\vagrant> cd devbox |
29 | 51 | C:\files\vagrant\devbox> .\vagrant_up.bat |
30 | 52 | ``` |
| 53 | + The `vagrant_up.bat` file sets the location of your *VAGRANT_HOME* directory to `C:\files\vagrant`. Otherwise it would be created in your user's profile directory, which could cause problems later. If you're going to run more `vagrant` commands, first set the variable in your console as shown in `vagrant_up.bat`. |
| 54 | + |
31 | 55 | Vagrant will now create and provision your new Vagrant box. (this will take some time) |
32 | 56 |
|
33 | 57 | ### Troubleshooting |
34 | | - - If `vagrant_up.bat` fails, edit the file to add ` --debug` after `vagrant up`, to find out more information about the failure. |
| 58 | + - If `vagrant_up.bat` fails: |
| 59 | + 1. Edit the file to add ` --debug` after `vagrant up` |
| 60 | + 2. Run `vagrant_up.bat` again, which should provide more information about why it failed. |
35 | 61 |
|
36 | 62 | - If you get the following error: |
37 | 63 | ``` |
38 | 64 | Stderr: VBoxManage.exe: error: Call to WHvSetupPartition failed: ERROR_SUCCESS (Last=0xc000000d/87) (VERR_NEM_VM_CREATE_FAILED) |
39 | 65 | VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole |
40 | 66 | ``` |
41 | | - It means VirtualBox is trying to use Hyper-V and failing. You should turn off HyperV and reboot. |
| 67 | + It may mean VirtualBox is trying to use Hyper-V and failing. You should turn off HyperV and reboot. |
42 | 68 | 1. Open a new `cmd.exe` console *with Administrator privileges*. |
43 | 69 | 2. Run the command `bcdedit /set hypervisorlaunchtype off` |
44 | 70 | 3. Reboot |
@@ -100,4 +126,3 @@ However, it is more secure to have a password-protected key that lives only in y |
100 | 126 | ``` |
101 | 127 |
|
102 | 128 | [1]: https://askubuntu.com/questions/41605/trouble-downloading-packages-list-due-to-a-hash-sum-mismatch-error/ |
103 | | - |
|
0 commit comments