1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
---|
2 | <html xmlns="http://www.w3.org/1999/xhtml"> |
---|
3 | <head> |
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
5 | <meta http-equiv="Content-Style-Type" content="text/css" /> |
---|
6 | <meta name="generator" content="pandoc" /> |
---|
7 | <title>VirtualBox lab</title> |
---|
8 | <style type="text/css">code{white-space: pre;}</style> |
---|
9 | <link rel="stylesheet" href="style.css" type="text/css" /> |
---|
10 | </head> |
---|
11 | <body> |
---|
12 | <div id="header"> |
---|
13 | <h1 class="title">VirtualBox lab</h1> |
---|
14 | </div> |
---|
15 | <div id="TOC"> |
---|
16 | <ul> |
---|
17 | <li><a href="#objective"><span class="toc-section-number">1</span> Objective</a></li> |
---|
18 | <li><a href="#install-virtualbox"><span class="toc-section-number">2</span> Install VirtualBox</a><ul> |
---|
19 | <li><a href="#for-mac-osx"><span class="toc-section-number">2.1</span> For Mac OSX</a></li> |
---|
20 | <li><a href="#for-windows"><span class="toc-section-number">2.2</span> For Windows</a><ul> |
---|
21 | <li><a href="#checking-vt-x"><span class="toc-section-number">2.2.1</span> Checking VT-x</a></li> |
---|
22 | </ul></li> |
---|
23 | <li><a href="#for-linux-ubuntu-12.04"><span class="toc-section-number">2.3</span> For Linux (Ubuntu 12.04)</a></li> |
---|
24 | </ul></li> |
---|
25 | <li><a href="#create-a-virtual-machine"><span class="toc-section-number">3</span> Create a virtual machine</a><ul> |
---|
26 | <li><a href="#new-virtual-machine"><span class="toc-section-number">3.1</span> New Virtual Machine</a></li> |
---|
27 | <li><a href="#insert-virtual-cd"><span class="toc-section-number">3.2</span> Insert virtual CD</a></li> |
---|
28 | <li><a href="#start-the-vm"><span class="toc-section-number">3.3</span> Start the VM</a></li> |
---|
29 | <li><a href="#restart"><span class="toc-section-number">3.4</span> Restart</a></li> |
---|
30 | <li><a href="#try-the-console"><span class="toc-section-number">3.5</span> Try the console</a></li> |
---|
31 | <li><a href="#mouse-cursor"><span class="toc-section-number">3.6</span> Mouse cursor</a></li> |
---|
32 | <li><a href="#acpi-shutdown"><span class="toc-section-number">3.7</span> ACPI shutdown</a></li> |
---|
33 | </ul></li> |
---|
34 | <li><a href="#additional-exercises"><span class="toc-section-number">4</span> Additional exercises</a><ul> |
---|
35 | <li><a href="#install-virtualbox-guest-additions"><span class="toc-section-number">4.1</span> Install VirtualBox Guest Additions</a></li> |
---|
36 | <li><a href="#install-another-vm"><span class="toc-section-number">4.2</span> Install another VM</a></li> |
---|
37 | <li><a href="#add-a-desktop-to-your-server"><span class="toc-section-number">4.3</span> Add a desktop to your server</a><ul> |
---|
38 | <li><a href="#reinstall-guest-additions"><span class="toc-section-number">4.3.1</span> Reinstall guest additions</a></li> |
---|
39 | <li><a href="#copy-paste"><span class="toc-section-number">4.3.2</span> Copy-paste</a></li> |
---|
40 | </ul></li> |
---|
41 | <li><a href="#getting-rid-of-the-proxy"><span class="toc-section-number">4.4</span> Getting rid of the proxy</a></li> |
---|
42 | </ul></li> |
---|
43 | </ul> |
---|
44 | </div> |
---|
45 | <h1 id="objective"><a href="#objective"><span class="header-section-number">1</span> Objective</a></h1> |
---|
46 | <p>You will install VirtualBox on your laptop, create a VM, and install a guest operating system.</p> |
---|
47 | <p>Note: the files you will need (VirtualBox software and ISO images) will be provided either on a USB stick or on the workshop web server. Please don't download large files directly from the Internet.</p> |
---|
48 | <p>The USB stick is preferred as it will be faster than the shared wireless.</p> |
---|
49 | <p>If your laptop has less than 1GB of RAM or less than 5GB of spare disk space, please check with the instructors if it will be suitable.</p> |
---|
50 | <h1 id="install-virtualbox"><a href="#install-virtualbox"><span class="header-section-number">2</span> Install VirtualBox</a></h1> |
---|
51 | <p>Separate instructions follow for Mac OSX, Windows and Linux. Once you have installed VirtualBox, move onto the section entitled "Create a Virtual Machine".</p> |
---|
52 | <h2 id="for-mac-osx"><a href="#for-mac-osx"><span class="header-section-number">2.1</span> For Mac OSX</a></h2> |
---|
53 | <p>Double-click on the disk image file <code>VirtualBox-x.x.x-xxxxx-OSX.dmg</code></p> |
---|
54 | <p>Double-click on VirtualBox.pkg and follow the installer.</p> |
---|
55 | <p>Open the Applications folder and double-click on VirtualBox. You can lock its icon onto the Dock to make it quicker to find in future. The Host Key by default is the Left Cmd key.</p> |
---|
56 | <h2 id="for-windows"><a href="#for-windows"><span class="header-section-number">2.2</span> For Windows</a></h2> |
---|
57 | <p>Double-click on the executable <code>VirtualBox-x.x.x-xxxxx-Win.exe</code> and follow the install wizard with default settings. Give it permission to install the device drivers.</p> |
---|
58 | <p>Start VirtualBox using the icon on the desktop or in the start menu.</p> |
---|
59 | <p>Note: if you have Windows 8 and have enabled Hyper-V, you will need to <a href="http://superuser.com/questions/500166/intel-vt-x-disappeared-after-upgrading-to-windows-8">disable</a> <a href="http://social.technet.microsoft.com/Forums/windows/en-US/118561b9-7155-46e3-a874-6a38b35c67fd/hyperv-disables-vtx-for-other-hypervisors?forum=w8itprogeneral">Hyper-V</a> before VirtualBox can work.</p> |
---|
60 | <h3 id="checking-vt-x"><a href="#checking-vt-x"><span class="header-section-number">2.2.1</span> Checking VT-x</a></h3> |
---|
61 | <p>VirtualBox doesn't require VT-x or AMD-V (except when running 64-bit guests), but it will work faster with it.</p> |
---|
62 | <p>You can check whether hardware virtualization is enabled on your laptop by downloading and running the <a href="http://www.microsoft.com/en-us/download/details.aspx?id=592">Hardware-Assisted Virtualization Detection Tool</a></p> |
---|
63 | <p>If it says "this computer does not have hardware-assisted virtualization" then your laptop may be so old that it does not have this feature, or it could just be disabled in the BIOS.</p> |
---|
64 | <p>Restart your laptop, go into BIOS Setup, then look for a setting which may be under "Advanced BIOS Features" or "Security".</p> |
---|
65 | <pre><code>Virtualization Technology (VT-x)</code></pre> |
---|
66 | <p>Ensure it is set to Enabled. (If you see VT-d, you can turn that on as well, but it's only important if you want to give your guest VM direct access to some of the host hardware)</p> |
---|
67 | <p>After changing this setting and saving, some systems require you to fully power off and power on again.</p> |
---|
68 | <p>In extreme cases you may need to <a href="disable%20and%20re-enable%20VT-x">https://forums.virtualbox.org/viewtopic.php?p=108857</a></p> |
---|
69 | <h2 id="for-linux-ubuntu-12.04"><a href="#for-linux-ubuntu-12.04"><span class="header-section-number">2.3</span> For Linux (Ubuntu 12.04)</a></h2> |
---|
70 | <p>Copy the appropriate file for your operating system:</p> |
---|
71 | <ul> |
---|
72 | <li><code>virtualbox-x.x_x.x.x-xxxxx~Ubuntu~precise_i386.deb</code> for a 32-bit system</li> |
---|
73 | <li><code>virtualbox-x.x_x.x.x-xxxxx~Ubuntu~precise_amd64.deb</code> for a 64-bit system</li> |
---|
74 | </ul> |
---|
75 | <p>Install it by double-clicking, or from the command line using this command:</p> |
---|
76 | <pre><code>$ sudo dpkg -i virtualbox-x.x_x.x.x-xxxxx~Ubuntu~precise_xxx.deb</code></pre> |
---|
77 | <p>Start the GUI by typing "VirtualBox"</p> |
---|
78 | <p>To check whether your laptop has VT-x, at a command line type</p> |
---|
79 | <pre><code>$ egrep '(vmx|svm)' /proc/cpuinfo</code></pre> |
---|
80 | <p>If you see at least one line containing vmx or svm, the CPU has this capability, although it is not necessarily enabled in the BIOS.</p> |
---|
81 | <h1 id="create-a-virtual-machine"><a href="#create-a-virtual-machine"><span class="header-section-number">3</span> Create a virtual machine</a></h1> |
---|
82 | <p>You are now going to create a virtual machine and install Ubuntu inside it.</p> |
---|
83 | <p>You will install Ubuntu Server Edition, as it is faster to install than the Desktop Edition, and will give you an opportunity to practice administering a system using the command line.</p> |
---|
84 | <p>The 32-bit (i386) version is fine because we do not expect to give this VM more than 4GB of RAM. For a real server you would more likely install the 64-bit (amd64) version instead.</p> |
---|
85 | <p>Find the appropriate Ubuntu ISO image (e.g. <code>ubuntu-12.04.3-server-i386.iso</code>). Make a folder on your laptop for ISO images, and copy the Ubuntu ISO image there.</p> |
---|
86 | <h2 id="new-virtual-machine"><a href="#new-virtual-machine"><span class="header-section-number">3.1</span> New Virtual Machine</a></h2> |
---|
87 | <p>In the VirtualBox Manager window, click on the "New" button (a blue spiky circle)</p> |
---|
88 | <div class="figure"> |
---|
89 | <img src="buttons.png" /> |
---|
90 | </div> |
---|
91 | <p>The first screen asks for Name and operating system</p> |
---|
92 | <p>Enter:</p> |
---|
93 | <ul> |
---|
94 | <li>Name: ubuntu-1 (or any other name you like)</li> |
---|
95 | <li>Type: Linux</li> |
---|
96 | <li>Version: Ubuntu (or Ubuntu 64-bit if you're installing 64-bit version)</li> |
---|
97 | <li>click Next</li> |
---|
98 | </ul> |
---|
99 | <p>The next screen is the memory size. Accept the default of 512MB, unless your machine is very limited on RAM. You can change this later.</p> |
---|
100 | <p>The next screen asks for Hard drive. Select "Create a virtual hard drive now" and click "Create"</p> |
---|
101 | <p>Select the default VDI (VirtualBox Disk Image) and click Next.</p> |
---|
102 | <p>Choose "Dynamically allocated" and click Next. (This option allocates disk space only when the guest OS writes to the virtual disk)</p> |
---|
103 | <p>Accept the default size of 8.00 GB. Note that this won't actually use 8GB straight away on your laptop, but will allow it to grow up to 8GB. Click Create.</p> |
---|
104 | <p>Now you will see the VM created but in state "Powered Off"</p> |
---|
105 | <h2 id="insert-virtual-cd"><a href="#insert-virtual-cd"><span class="header-section-number">3.2</span> Insert virtual CD</a></h2> |
---|
106 | <p>When you start a VM for the first time, VirtualBox will automatically prompt you for a CD-ROM image. However you are going to do it the manual way so that you learn your way around the settings.</p> |
---|
107 | <p>Before starting the VM, click on the "Settings" button (an orange sprocket)</p> |
---|
108 | <p>Click on Storage.</p> |
---|
109 | <p>You should see:</p> |
---|
110 | <ul> |
---|
111 | <li>Controller: IDE</li> |
---|
112 | <li>... Empty (with a CD icon)</li> |
---|
113 | <li>Controller: SATA</li> |
---|
114 | <li>... ubuntu-1.vdi</li> |
---|
115 | </ul> |
---|
116 | <p>Click on the CD icon by "Empty". To the right you will see:</p> |
---|
117 | <ul> |
---|
118 | <li>Attributes:</li> |
---|
119 | <li>CD/DVD Drive: IDE Secondary Master, and another CD icon</li> |
---|
120 | </ul> |
---|
121 | <p>Click on this other CD icon. From the menu which appears, select "Choose a virtual CD/DVD disk file..."</p> |
---|
122 | <div class="figure"> |
---|
123 | <img src="choose-cd-image.png" /> |
---|
124 | </div> |
---|
125 | <p>Browse to the directory where you copied the ubuntu server ISO image, and select it.</p> |
---|
126 | <p>You should now see:</p> |
---|
127 | <ul> |
---|
128 | <li>Controller: IDE</li> |
---|
129 | <li>... ubuntu-12.04-3-server-i386</li> |
---|
130 | <li>Controller: SATA</li> |
---|
131 | <li>... ubuntu-1.vdi</li> |
---|
132 | </ul> |
---|
133 | <p>Click OK.</p> |
---|
134 | <h2 id="start-the-vm"><a href="#start-the-vm"><span class="header-section-number">3.3</span> Start the VM</a></h2> |
---|
135 | <p>Select the VM and click the green Start arrow - or simply double-click the VM - and your VM will start.</p> |
---|
136 | <p>You may get some warnings - read them. One will read something like this:</p> |
---|
137 | <blockquote> |
---|
138 | <p>"You have Auto capture keyboard option turned on ... You can press the host key at any time to uncapture the keyboard and mouse and return them to normal operation ... The host key is currently defined as Right Ctrl"</p> |
---|
139 | </blockquote> |
---|
140 | <p>Have a look at the bottom right-hand corner of the window. It should show a reminder of what the host key is set to, next to a small downward arrow.</p> |
---|
141 | <p>The Ubuntu installer should start. Click inside the window. Note that you have to press the host key to get your mouse out again.</p> |
---|
142 | <p>If this is the first time you've installed Ubuntu, ask a neighbor or an instructor for help if you get stuck.</p> |
---|
143 | <p>Select your language, and press F3 if you want to select a non-US keyboard layout.</p> |
---|
144 | <p>Next, press F4 and select "Install a minimal virtual machine".</p> |
---|
145 | <div class="figure"> |
---|
146 | <img src="modes.png" /> |
---|
147 | </div> |
---|
148 | <p>This selects the minimum number of packages to get a very basic system.</p> |
---|
149 | <p>Then select "Install Ubuntu Server" from the front menu, and follow the prompts. Use Tab to move around the screen, Enter to select something.</p> |
---|
150 | <p>Follow the prompts for timezone, keyboard and so on. It's quickest to say "No" when asked if you want to auto-detect the keyboard layout; you can then manually select the US English layout or whichever is appropriate.</p> |
---|
151 | <p>Use whatever hostname, username and password you like. This is your own VM to take away and keep! Ask your neighbor or an instructor if you need help.</p> |
---|
152 | <p>We do strongly suggest the following settings:</p> |
---|
153 | <ul> |
---|
154 | <li>Encrypt your home directory? No</li> |
---|
155 | <li><p>Partitioning method: Guided - use entire disk</p> |
---|
156 | <div class="figure"> |
---|
157 | <img src="partitioning.png" /> |
---|
158 | </div> |
---|
159 | <p>It will say that it will use the entire disk sda, which is about 8.6GB and is an "ATA VBOX HARDDISK"</p> |
---|
160 | <p>Allow it to write changes to the disk. Remember, this is safe - you're not overwriting your real hard drive, it's only writing into the virtual disk file you created before.</p></li> |
---|
161 | <li><p>For HTTP proxy please enter <code>http://apt.ws.nsrc.org:3142/</code> unless the instructors tell you otherwise. This will speed up the installation by using a local cache of packages.</p> |
---|
162 | <div class="figure"> |
---|
163 | <img src="proxy.png" /> |
---|
164 | </div></li> |
---|
165 | <li>No automatic updates</li> |
---|
166 | <li>When you get to "Choose software to install", move to OpenSSH Server and hit Space to select it, but leave everything else unselected.</li> |
---|
167 | <li><p>Install GRUB boot loader to the master boot record? Yes.</p></li> |
---|
168 | </ul> |
---|
169 | <h2 id="restart"><a href="#restart"><span class="header-section-number">3.4</span> Restart</a></h2> |
---|
170 | <p>Once the installation is complete, you will be prompted to restart.</p> |
---|
171 | <p>If the machine starts up with the virtual CD-ROM still attached, you may need to remove it. Go to <code>Settings > Storage</code> as before, click on the CD icon under Controller IDE, click on the second CD icon, select "Remove disk from virtual drive". Then restart the VM again.</p> |
---|
172 | <p>After a few seconds you should get an Ubuntu login prompt. Login with the username and password you created.</p> |
---|
173 | <h2 id="try-the-console"><a href="#try-the-console"><span class="header-section-number">3.5</span> Try the console</a></h2> |
---|
174 | <p>You a sitting in front of a server text console. Just like on a real PC, you can switch between virtual consoles using Ctrl-Alt-F1 to Ctrl-Alt-F6.</p> |
---|
175 | <p>Here are a few basic commands you can try: the "$" is the prompt you will see, so don't type it.</p> |
---|
176 | <pre><code>$ uptime # how long machine is running, how busy it is |
---|
177 | $ uname -a # information about the kernel |
---|
178 | $ df -h # free disk space in (h)uman readable form |
---|
179 | $ ls / # list the root directory</code></pre> |
---|
180 | <h2 id="mouse-cursor"><a href="#mouse-cursor"><span class="header-section-number">3.6</span> Mouse cursor</a></h2> |
---|
181 | <p>If you want a mouse cursor in Ubuntu Server, you need to install the package "gpm". These commands need to be run with "root" or superuser privileges, so you prefix them with "sudo".</p> |
---|
182 | <pre><code>$ sudo apt-get update # update the index of downloadable packages |
---|
183 | $ sudo apt-get install gpm # install the package</code></pre> |
---|
184 | <p>Once you've done this, you should be able to copy-paste within your VM by using the left and right buttons to select, and middle button to paste.</p> |
---|
185 | <p>If you want to be able to copy-paste between the VM and your laptop, see the optional exercises at the end.</p> |
---|
186 | <h2 id="acpi-shutdown"><a href="#acpi-shutdown"><span class="header-section-number">3.7</span> ACPI shutdown</a></h2> |
---|
187 | <p>Try selecting <code>Machine > ACPI shutdown</code> from VirtualBox, and you should see that this triggers the virtual machine to shut itself down. It takes only a couple of seconds. Then you can restart your virtual machine.</p> |
---|
188 | <p>If nothing happens, it could be because your server doesn't have an acpi daemon installed to respond to the request. If so, you can install it like this:</p> |
---|
189 | <pre><code>$ sudo apt-get install acpid</code></pre> |
---|
190 | <h1 id="additional-exercises"><a href="#additional-exercises"><span class="header-section-number">4</span> Additional exercises</a></h1> |
---|
191 | <p>If you complete the basic Ubuntu install early, here are some additional things you can do, as well as exploring the Ubuntu install you've just done.</p> |
---|
192 | <h2 id="install-virtualbox-guest-additions"><a href="#install-virtualbox-guest-additions"><span class="header-section-number">4.1</span> Install VirtualBox Guest Additions</a></h2> |
---|
193 | <p>The "guest additions" are some extra code which can be installed inside the guest OS to improve keyboard and mouse integration, and enable things like copy-paste and easy file transfer between host and guest.</p> |
---|
194 | <ul> |
---|
195 | <li>In VirtualBox, select <code>Devices > Insert Guest Additions CD image...</code></li> |
---|
196 | <li><p>Inside the VM (as the root user) mount the CD image and run the installer script.</p> |
---|
197 | <pre><code>$ sudo -s # enter a root shell |
---|
198 | # apt-get install build-essential dkms # we need these packages |
---|
199 | # mount /dev/cdrom /mnt # mount the CD-ROM |
---|
200 | # /mnt/VBoxLinuxAdditions.run # run the installer</code></pre> |
---|
201 | <p>Note: it is normal to see an error about the window system, because we have installed the server version of Ubuntu with no graphical interface</p> |
---|
202 | <pre><code>Installing the Window System drivers ...fail! |
---|
203 | (Could not find the X.Org or XFree86 Window System.)</code></pre></li> |
---|
204 | <li><p>When it has finished, you can unmount the CD image:</p> |
---|
205 | <pre><code># umount /mnt |
---|
206 | # exit # leave the root shell |
---|
207 | $</code></pre></li> |
---|
208 | </ul> |
---|
209 | <p>You may need to repeat this every time you install an updated kernel from Ubuntu.</p> |
---|
210 | <p>Once this is done, you should find that mousing over the window works without having to capture and release the mouse any more.</p> |
---|
211 | <p>Note: copy-paste between guest and host only works with a desktop GUI.</p> |
---|
212 | <h2 id="install-another-vm"><a href="#install-another-vm"><span class="header-section-number">4.2</span> Install another VM</a></h2> |
---|
213 | <p>Create another VM and install from a different ISO image. The instructor may be able to provide you with some other ISO images e.g. Ubuntu Desktop, Antix, Debian, FreeBSD, pfSense, Asterisk Now, or some other operating system. (Antix runs in only 128MB of RAM, or even 64MB if you use the CLI installer)</p> |
---|
214 | <p>This is an excellent way to get to learn other operating systems.</p> |
---|
215 | <h2 id="add-a-desktop-to-your-server"><a href="#add-a-desktop-to-your-server"><span class="header-section-number">4.3</span> Add a desktop to your server</a></h2> |
---|
216 | <p>Your installed Ubuntu Server VM can have a desktop added. There are many to choose from, but LXDE is a compact and lightweight one. All you need to do is:</p> |
---|
217 | <pre><code>$ sudo apt-get install xorg lxde |
---|
218 | $ sudo service lxdm start</code></pre> |
---|
219 | <p>This should switch to a graphical interface where you can login again. You can still get to the text console with Ctrl-Alt-F1, and return to the graphical interface with Ctrl-Alt-F7.</p> |
---|
220 | <p>Inside your VM you probably want to disable the screensaver (<code>Start > Preferences > Screensaver</code>) because the default screensavers are very CPU intensive and will drain your laptop battery!</p> |
---|
221 | <p>The virtual console screen may be larger than the window on your desktop, so you may need to scroll down to see the bottom line of the console where the LXDE start button is. <code>Start > Accessories > LXTerminal</code> will give you a terminal window.</p> |
---|
222 | <h3 id="reinstall-guest-additions"><a href="#reinstall-guest-additions"><span class="header-section-number">4.3.1</span> Reinstall guest additions</a></h3> |
---|
223 | <p>When the graphical interface is present, you can reinstall the guest additions (just open the file manager and double-click on <code>autorun.sh</code>)</p> |
---|
224 | <p>Then after you reboot the VM, whenever you resize the window the desktop should auto-resize to fit, avoiding the need to scroll.</p> |
---|
225 | <p>Furthermore, the "seamless windows" feature should now be available (<code>View > Switch to seamless mode</code>). This scales the VM to fit your available screen and removes the background, so VM windows sit side-by-side with your regular windows.</p> |
---|
226 | <h3 id="copy-paste"><a href="#copy-paste"><span class="header-section-number">4.3.2</span> Copy-paste</a></h3> |
---|
227 | <p>If you want to copy-paste between the VM and your host machine, you need to enable it in VirtualBox by selecting</p> |
---|
228 | <pre><code>Devices > Shared Clipboard > Bidirectional</code></pre> |
---|
229 | <p>Finally, you may also need to open a terminal and run <code>VBoxClient-all</code> in the guest OS before copy-paste works.</p> |
---|
230 | <h2 id="getting-rid-of-the-proxy"><a href="#getting-rid-of-the-proxy"><span class="header-section-number">4.4</span> Getting rid of the proxy</a></h2> |
---|
231 | <p>If you continue to use this VM outside the classroom, you will find that the HTTP proxy (apt.ws.nsrc.org) is not available. To disable it you need to edit the file <code>/etc/apt/apt.conf</code> and remove or comment out this line:</p> |
---|
232 | <pre><code>Acquire::http::Proxy "http://apt.ws.nsrc.org:3142/";</code></pre> |
---|
233 | <p>But don't do this until after the end of the system administration section of the workshop.</p> |
---|
234 | </body> |
---|
235 | </html> |
---|