1 00-VirtualMachines


1.1 A virtual sandbox for big-kids

… for you to play around and make mistakes in.
00-VirtualMachines/computer-sandbox.jpg

1.2 Hypervisors and Virtual Machines

00-VirtualMachines/russian_computer.png

https://en.wikipedia.org/wiki/Virtual_machine

A virtual machine (VM) is an emulation of a computer system.
Virtual machines are based on computer architectures,
and provide functionality of a physical computer.
Their implementations may involve specialized hardware, software, or a combination.

https://en.wikipedia.org/wiki/Hypervisor

A hypervisor is also known as a virtual machine monitor (VMM)
It is computer software, firmware, and hardware that creates and runs virtual machines.
A computer on which a hypervisor runs one or more virtual machines is called a host machine,
and each virtual machine is called a guest machine.
The hypervisor presents the guest operating systems with a virtual operating platform,
and manages the execution of the guest operating systems.

1.2.1 Type-1, native or bare-metal hypervisors

Type 1 hypervisors run directly on the host’s hardware,
to control the hardware and to manage guest operating systems.
For this reason, they are sometimes called bare-metal hypervisors.
00-VirtualMachines/Type-1-Hypervisor.png
00-VirtualMachines/type2.png

Examples:

Xen:
https://en.wikipedia.org/wiki/Xen

Qubes (Builds on top of Xen):
https://www.qubes-os.org/

1.2.2 Type-2 or hosted hypervisors

Type-2 hypervisors run on/in a conventional operating system (OS)w
just as other computer programs do.
A guest operating system runs as a process on the host OS.
Type-2 hypervisors abstract guest operating systems from the host operating system.
00-VirtualMachines/Type-2-Hypervisor.png
00-VirtualMachines/type1.png

Examples:

VirtualBox:
https://en.wikipedia.org/wiki/VirtualBox

KVM:
https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine

++++++++++++++++++++++++++++++++++++
Cahoot-02a.1

1.3 Benefits: why virtualize?

A virtual sandbox where you can experiment with coding, hacking, cracking, etc.
Snapshots allow reverting to earlier states!!
You can do software unit and integration testing on other operating systems.
Security and isolation (Graders run student code in a virtual machine for example).
Good computer hygiene (keep your OS clean).
Train yourself on the numerous platforms where software development usually happens.
The use of virtualization is truly massive,
and is pervasive in software development, software testing, network engineering, and web design.
Migrations of many computer systems from facility to facility is more efficient.
Re-engineer your network faster.
Energy bills are lower (more efficient use of computer resources).
This list could go on for pages, just “duck it”:

https://duckduckgo.com/?q=why+virtualize
https://duckduckgo.com/?q=why+run+a+virtual+machine

1.4 Setting up your virtual machine

1.4.1 Preparation

This comes in several options:

1.4.1.1 Campus machines

If you want to use campus computers (Windows CLC),
then open AppsAnywhere, and launch VirtualBox.
Everything should be ready to go.
Use the S-DRIVE (recommended) or your own USB drive (slower) as your install location,
to store your virtual disk image,
not the C: drive (which forgets your install upon reboot)!
When using the S drive,
you can launch the VM by double-clicking on the VirtualBox file,
where you stored it, and VirtualBox will automatically open.

1.4.1.2 Bare metal on your own machine

  1. If you are already running Linux on your own machine,
    then see the ../../../SyllabusGeneral for more details.

1.4.1.3 Virtualbox on your own machine

If you want to run VirtualBox on your own computer:
If you do not have a Mac, and are running Windows,
then open your BIOS (Mac virtualization is usually enabled by default).
F2, F8, or other function keys, and/or “Advanced Startup” from within Windows may help.
Use your favorite search engine to find out how for your particular laptop.
Once you have figured out how to enter your BIOS,
then enable any features that sound like:
virtualization, vt-x, vt-d, AMD-v, AMD-vi, NPT, RVI, etc.
Make sure you have >=20 Gb of free hard drive space, and >=4Gb of RAM.
Download VirtualBox: https://www.virtualbox.org/wiki/Downloads
If you are running MacOS,
then you want VirtualBox version 6.0, not version 6.1 (VM’s crash).
Install VirtualBox:
Launch and click through all, accepting the defaults (Mac and Windows).
VirtualBox kernel modules require a restart,
even in Unix-based operating systems (Mac, Linux, BSD, etc).
You could use KVM or Xen instead if you’re on Linux,
and want to be adventurous.

1.4.2 Installation

Choose an operating system: 01-02-LinuxBash.html
Then, get your virtual machine installed, either:

  1. From-scratch install in VirtualBox
    Typically, you just need the default install options.

  2. From-scratch install on a USB drive.
    Choose a second USB sick or external hard drive as the install location.
    This is useful for network hacking, forensics, file-recovery, password bypassing, etc.
    Though it may be slow to boot, after booting,
    this option should be generally faster than a VM,
    and so is useful if your computer is slow.

++++++++++++++++++++++++++++++++++++
Cahoot-02a.2

1.5 Usability

Host and guest additions
Extension pack is not required, and really only needed for things like fancy USB-3 peripherals.
Guest additions: helpful for shared folder, for example.

Shared clipboard
Menu: Devices > Shared Clipboard > bidirectional

Shared folders: Platform-dependent (DataStructures will go over in lab)
In host: in VirtualBox GUI settings for your VM, enable a shared folder
Choose location in host to share.
Check auto mount and permanent.

1.6 VM hygiene (keep it clean)

Just after installation, but before using your VM for anything,
shut down, and create a snapshot!
00-VirtualMachines/Screenshot_20190122_010252.png

Then, use your VM to your heart’s content, but before you update,
refresh the snapshot, getting rid of any potential contamination.
Then, do updates, snapshot again, and delete the original snapshot;
you have another clean base.
Use your VM, rinse, repeat.
Show: demonstrate snapshots for updates, browsing, breaking the OS.

1.7 Using your VM

Open up the file browser, how to look around.
Open up the terminal, how to look around.
Skim first section of 01-02-LinuxBash (which we will repeat again in a couple days).
What is a bash terminal, how is it like the python interpreter?
Make a simple bash script.
Open an ipython3 interpreter/shell.
Make a simple a python3 script, run it via ipython3.
What are the commands: python3, ipython3, python?
Open an IDE, make another python script, show help, linting, debugging, auto-completion, object inspection, etc.
Go to git-classes, login.
Create a repository.
Clone the repository.
Edit some files, add, commit, push, etc.

1.8 More

If you’re still curious about virtualization, keep on reading:
../../Security/Content/21b-Virtualization.html

Next: 01-02-LinuxBash.html