Description
Simply stated, Virtual machines (VMs) are computers inside computers. They are one of the best kept secrets in computers, particularly for consumers. Even people who have been involved with computer technology for a while can be intimidated by them but they are not that hard to use. In fact most web apps are harder to use than setting up a VM.In this episode of the House of Hacks, Harley removes the shroud of mystery surrounding them and shows how easy they are to work with. In this video, he covers:
1) What is a virtual machine?
2) Why use a virtual machine?
3) How does a virtual machine work?
4) What choices are there for virtual machines?
5) What kind of system is needed to run virtual machines?
6) How to install VIrtualBox software.
7) How to create a virtual machine.
8) How to install Windows on a VM.
9) How to install Linux on a VM.
10) Take a one question survey.
References
Application virtualization, past and futureWikipedia: Virtual Machine
History of Virtualization
Wikipedia: Comparison of platform virtualization software
Music under Creative Commons License By Attribution 3.0.
Intro/Exit: "Hot Swing" by Kevin MacLeod at http://incompetech.com
Sound effect: living-room-light-switch by alienxxx at http://freesound.org
Transcript
Want to run software for an operating system that’s not installed on your computer?Want to have different computer configurations for different purposes?
Do you want to try out some software without the risk of installing it on your computer?
Virtual Machines are the answer to all these questions.
Virtual Machine software is really cool technology that can solve a variety of different problems but it can be a bit mysterious and intimidating if you haven’t used it before. Today at the House of Hacks, my aim is to remove that shroud of mystery and show how easy they are to use.
[Intro]
Hi Makers, Builders and Do-it-yourselfers. Harley here.
While virtual machine technology has been around since the 60s, in the late 90s a company called VMWare released software for PCs that pushed it onto mainstream commodity hardware.
Since then, that software has matured with many more features and additional companies have come into the market to give more choices.
Today I’m going to give a brief overview of
what is a virtual machine,
why use a virtual machine,
how does a virtual machine work,
what choices are there for virtual machine software,
what kind of system do you need to run virtual machines,
how to install VIrtualBox software,
how to create a virtual machine,
how to setup two simple VMs for Windows and Linux
and finally there’s a one question survey at the end.
That’s a lot to cover and if you want to skip to the next section, click up here or in the description below.
A virtual machine is a software package that creates another computer, a virtual computer, inside your real computer. There are a couple ways of doing this.
One way is to emulate the hardware.
Examples are Apple ][ emulators that allow you to run Apple ][ software on a PC. Another example is phone emulators that allow you to develop mobile applications on a PC.
In these cases, the virtual computer hardware is likely a completely different CPU architecture from your host computer.
This is not what I'm talking about today.
Another type of software falling into this category is software written to support a programming language.
In this case an abstract computer is defined and the software implements this particular computer.
Examples of this are the JVM for Java, the Perl virtual machine for Perl or the .NET runtime engine for .NET languages.
Again, this type of virtualization is not the topic for today.
For the purposes of this video, virtual machine software is software that partitions part of the real hardware and provides those resources to the software that's installed inside of it.
This virtual computer, or guest, is basically just like your real, or host, computer hardware.
The guest computer has its own memory, disks, video adapters and network ports that are inside, but separate from the host.
To the host computer it looks like any other application. To software inside the virtual computer, it looks just like any other real computer running any operating system you want.
Virtual machines are great whenever you want to isolate software from your computer or from other software.
One example might be on your home computer with kids. Create a virtual machine for their exclusive use and any changes they make will be isolated to their machine.
If they mess something up too bad, just restore their machine to a snapshot and it's back to a known state.
Another example might be you have a machine with one operating system on it and you want to run software designed for a different operating system.
Simply create a VM and install the other operating system in it to run that other software.
For example, I have a Mac with a Windows VM on it to run Windows Adobe products.
A final example might be in software development where you have one VM for back-end server development and a different VM for front-end client development.
Another use is to test software where you have multiple VMs setup with different operating systems and base dependencies for a product. You then save a snapshot of those setups and return to them at the start of each testing cycle.
You can even simulate a network of different computers all running inside a single host computer.
Virtual machine software provides an environment into which you can install an operating system.
The actual computer you install this software on is called the host. The virtual machines you create inside this software are called guests.
When you create a guest machine, you specify various aspects of its configuration.
The main ones are how much memory it should have, how many CPU cores to use, how large the disk is and networking options.
You want to set these to be less than what your real, host computer has. If they are set too high, the guest machine may take up too many resources from the host and slow things down.
Once you've created the guest machine you essentially have an empty computer ready to install an operating system into.
The guest does not have to have the same operating system as the host.
You can have different operating systems running on the same computer at the same time. This is really cool!
When you create a guest machine, its hard drive is stored inside a file on your host computer.
So you can move guests from one host computer to another or back it up by simply copying that one file.
It's also possible to setup a directory on your host computer as a shared file on the guest. This shows up as a drive in the guest and allows you to share files between the host and a guest.
If the same directory is shared between the host and multiple guests, then the guests effectively can see each others files.
However, the files that are stored on the guest's hard drive are only visible to that guest. Neither the host nor other guests can see those files.
There are many, many choices for VM software. There's a link in the description to a Wiki page with a huge number of them. In the PC world, there are three big names: VMWare, VirtualBox and Hyper-V.
VMWare was an early entrant in this space with a history going back to 1998. It has a huge number of different options and configurations.
They have many different software configurations to run virtual machines on anything from a single computer to managing a huge farm of machines in a data center environment.
Hyper-V is a product now owned by Microsoft and is at the core of their server management. Like VMWare, it allows running virtual machines on anything from a single PC to a data center.
VirtualBox started as an proprietary licensed product and eventually went open source. It was first acquired by Sun and subsequently Oracle when they bought Sun.
Its focus is on just the desktop and will run on Windows, Linux or Mac OS X operating systems.
VMWare and Hyper-V are large, flexible but complicated products. Their main focus is more on virtual server management in large data centers.
While they have products that run locally on a single computer, because of their focus on servers, in my experience they are more complicated to install and use.
Also, they are more limited in what operating systems they will run on.
I find VirtualBox to work perfect for my single user, non-server needs for both work and personal use. This is the software I will be demonstrating today.
The real, host computer needs to be reasonably powerful with an Intel or AMD processor. Most modern PCs fall into this category.
The two most important requirements for the host are memory and disk space.
At a minimum, you need to take the minimum memory requirements for the host operating system and add the minimum memory requirements of the guest operating system you want to run.
Of course with all things memory related, the more the better.
The disk needs to be able to store both the host operating system and any related software as well as any guest operating systems and their related software.
The VirtualBox software itself doesn’t need too much disk space, only a couple 10s of megabytes. However operating systems these days typically run into the 10s of gigabytes.
So plan on 10-50 gigabytes per guest machine in addition to the host’s needs.
To create a virtual machine, you first need to install the virtual machine software, VirtualBox in this example, on the host computer. Download VirtualBox from virtualbox.org for your operating system.
This installs just like any other software package: on Windows they have an exe file, on OS X they have a dmg file and on Linux they have different package formats for different distributions.
After downloading, start the installer appropriate for your machine. In this example, I’m on a MacBook Pro so I have a dmg file that’s mounted as a disk.
Double clicking the disk opens the installer. Double clicking again opens the pkg file and I can proceed through the typical installation process.
On a Windows machine, you will probably get a couple more prompts as it installs some low level drivers and disables network communications momentarily.
On a Linux machine, you’d use the package manager for your distribution to install the download.
Once installed, you click on the VirtualBox icon to start the VirtualBox manager. This is where you manage your virtual machines.
On the left is a list of all the guest machines you’ve created. Of course this starts out empty.
On the right is a panel that shows details about the selected VM. If you have multiple, related VMs, you can group them together to expand or collapse the group.
Across the top is a toolbar with common actions.
To create a new virtual machine, click the New button on the top of the toolbar. This wizard pops up.
First put in the name of the virtual machine. This name is what shows up the manager on the left side of the VM manager.
Then select the type and version of the operating system that will be installed. In this case, I’m selecting Windows. When ready, click Continue.
Next you need to select the amount of memory that should be used by the VM. The slider bar is colored to recommend values based on what the host system has.
You cannot allocate more than is installed on the host computer, so this maximum value will vary depending on your particular computer.
The host computer needs some memory for basic operations, so it’s recommended you stay in this green zone.
I tend to use no more than 50% of the maximum number. If you plan on running multiple VMs at the same time, you don’t want the combined memory usage of all the VMs to exceed the green part of this slider. Once the memory size is selected, click Continue.
Now the hard drive for the virtual machine needs to be configured. A disk in the guest computer is simply a file on the host, so the following wizard pages control this file.
The first page allows you to select the source of the file. The first option is if there shouldn’t be a disk. The second is to create a new disk. The third is to use an existing disk.
Generally I always want to use the default and create a new disk. The other options are for special situations and I rarely use them. Click Continue when ready.
On the next page the file format for the virtual hard drive is specified. The different options are for compatibility with other virtual machine software packages.
I always use the VDI format since I always use VirutalBox and don’t care about cross-compatibility. Click Continue to move to the next step.
This step allows you to select whether the hard drive should be dynamically or statically allocated. Dynamic allocation means it starts out small and grows only as needed. This option minimizes space on the host computer.
Fixed size means the hard drive is set to its maximum size when it’s created and does not grow any larger. This option may take a little longer to create but may operate faster. It will take a fixed amount of space on the host, so once it’s allocated, it won’t take up any more space.
Which option you use depends on how many virtual machines you will create and how much free disk space you have on the host computer.
I tend to have quite a few virtual machines so I select the default dynamic mode. This helps minimize disk usage on the host. When ready, click Continue.
The final step allows you to specify the name of the hard drive file name and its maximum size. The name defaults to be the same as was used in step 1 for the virtual machine itself.
The size value entered here is what is reported to the guest operating system as its disk size.
Remember those two options we just had in the previous step? This will be the maximum size of dynamic disk files or the size of the fixed disk file.
The size needs to be large enough to contain the operating system and any programs and data that will be put in it. But you don’t want it to be so large it takes all the disk away from the host computer.
Typically I set this to be in the 30 to 40 GB size range. When this is set to what you want, click Create.
The wizard will close and a new virtual machine shows up in the left side of the manager window. You now have a new, empty virtual machine.
With the machine selected in the manager, click the Settings button and you get a dialog that allows you to change many parameters of the machine and how it appears to the guest operating system. This has all the items from the wizard we just went through plus many other options.
Generally these don’t need to be changed from their defaults with one exception: the CD drive in the storage tab. This is used to install an operating system so the virtual machine is actually capable of doing something.
The virtual machine can use the physical CD drive in the host computer as its CD or any ISO file can be mounted without having to have a physical CD. I generally download ISO files and use them.
And now we get to install Windows. In this example, I select a Windows 10 installation ISO to put Windows 10 on my virtual machine.
I have licenses to all versions of Windows installation images via a Microsoft subscription service and can download these ISO files.
If you don’t have access to this, you can purchase a Windows installation disk and place it in the host computer’s drive. Then select the option to use the host’s CD drive.
Now that the VM is created and an installation disk attached to the CD drive, start the virtual machine by pressing the Start button in the toolbar.
A new window opens up containing the virtual machine. First you see a VirtualBox boot screen and then we see the Windows installation screen.
At this point we’re just walking through a standard Windows install procedure.
Select the values you want on each screen.
When it gets to the custom install/upgrade screen. There isn’t any information on the HD to be able to do an upgrade. If you select upgrade you’ll have to restart the installation process so be sure to choose the custom install.
The custom install allows you to partition the disk. In this case, the disk is actually the VM’s hard drive stored in the file indicated in the VM configuration. I just use the entire disk.
Depending on the installer, you may get a warning saying you are about to overwrite all the data on the disk.
This warning is always a bit disconcerting, but remember, we’re inside a virtual machine, so the only data we could lose is the data inside the blank file we just created.
And now we just wait for the installation process to finish.
When it’s all done, we now have Windows 10 running on our virtual machine and almost ready for use.
Let's shut it down just like any other computer.
Then remove the CD from the virtual machine by going back into settings and selecting the option to remove the mounted CD.
The guest operating system is installed and ready for use, but there’s one more step to help make it easier to use. Virtual Box has some drivers that can be installed that make the virtual machine nicer to use.
To install these, select the Devices menu for the Virtual Box application. On this menu, select the “Insert Guest Additions CD image…” option.
If the VM isn’t running, start it and then pull up Windows Explorer. Select the CD drive and then start the installer. Select all the default options and let it do its thing.
This software does many things to make the VM easier to use.
For example, it allows the clipboard to be shared between the host and guest operating systems,
it increases the options for different network configurations
and allows the guest operating system to resize to whatever size the window is set to rather than the fixed sizes based on common hardware configurations.
And that’s all there is to setting up a Windows virtual machine.
Next we move onto installing Linux.
We start with a freshly created virtual machine as described earlier. I select a Linux installation ISO I downloaded. All distributions I’ve seen have an ISO option to use for installation. This one is from Ubuntu.
Once the ISO is selected for the CD drive we’re ready to start the virtual machine from the toolbar.
A new window is shown with a VirtualBox boot screen. Shortly after that we see the start of the Linux install process.
Just go through the prompts as if installing on a real machine. The default values were appropriate for my situation but you can change them to something different if you need.
Similar to the Windows install, we get this warning indicating we’re going to overwrite the whole drive. This is OK since the whole drive in the context of a virtual machine is contained in the file created to contain the VMs hard drive. It’s not the physical hard drive of our computer.
Enter the user name you want to use and your password to login into the virtual machine. Or you can have it login automatically if you’d prefer.
Once all the setup information is given, it’s just a matter of waiting for the installation to finish.
When it’s all done, we now have Linux running on our virtual machine, almost ready for use.
Just like Windows, the first thing to do to improve usability is to install the guest additions. On the VirtualBox Device menu, select the “Insert Guest Additions CD image” option.
Ubuntu will detect the new disk and ask if you want to run the installer.
Other distributions may require you to mount the CD and/or run the installer manually.
In this case, I’m going to run it and enter the password to authorize the installation.
As mentioned before, this software does makes the VM easier to use.
For example, it allows the clipboard to be shared between the host and guest operating systems,
it increases the options for different network configurations
and allows the guest operating system to resize to whatever size the window is set to rather than the fixed sizes based on common hardware configurations.
When the Guest Additions are done, I reboot the system. In theory this isn’t really needed, but I do it out of habit.
Now the Linux virtual machine is ready for use.
And that's all there is to setting up virtual machines. Basically it's pretty easy.
I’d appreciate some feedback in this short, one question survey. Would you be interested in videos showing advanced features of virtual machines and how they can be used? Select an answer in the survey section above.
In conclusion, join me in the comments below; I’d be interested to know if you’ve used a VM before or not and, if you have, what you have used if for, or plan to use it for in the future.
If this is your first time here at House of Hacks: Welcome, I’m glad you’re here and would love to have you subscribe. I believe everyone has a God-given creative spark. Sometimes this manifests through making things with a mechanical or technical bent.
Through this channel I hope to inspire, educate and encourage these types of makers in their creative endeavors. Usually this involves various physical media like wood, metal, electronics, photography and other similar materials. If this sounds interesting to you, go ahead and subscribe and I’ll see you again in the next video.
Now, go make something. It doesn’t have to be perfect, just have fun!