Cyber Deals - Get up to 65% off on CKA, CKAD, CKS, KCNA, KCSA exams and courses!

GCP Nested Virtualization

Note: This is purely based on GCP Documentation and for my own quick reference with additonal notes.

## Create a boot disk from a public image
$ gcloud compute disks create disk1 --image-project debian-cloud --image-family debian-9 --zone us-central1-b


## Create image
$ gcloud compute images create nested-vm-image \
  --source-disk disk1 --source-disk-zone us-central1-b \
  --licenses "https://www.googleapis.com/compute/v1/projects/vm-options/global/licenses/enable-vmx"

## remove the disk since it not needed anymore

## Create VM with new Image
$ gcloud compute instances create example-nested-vm --zone us-central1-b \
              --min-cpu-platform "Intel Haswell" \
              --image nested-vm-image

## SSH Access to the VM
$ gcloud compute ssh example-nested-vm
## and check the nested virtualization inside VM
$ grep -cw vmx /proc/cpuinfo

Starting a nested VM

## Update the VM instance and install some necessary packages
$ sudo apt update && sudo apt install qemu-kvm -y

## Download OS Image
$ wget https://people.debian.org/~aurel32/qemu/amd64/debian_squeeze_amd64_standard.qcow2

## Run inside screen and press enter
$ screen

## SStart the nested VM. When prompted, login in with user: root, password: root
sudo qemu-system-x86_64 -enable-kvm -hda debian_squeeze_amd64_standard.qcow2 -m 512 -curses

Starting a private bridge between the host and nested VMs

## insall necessary pacakges
$ sudo apt update && sudo apt install uml-utilities qemu-kvm bridge-utils virtinst libvirt-daemon-system libvirt-clients -y

## Start the default network that comes with the libvirt package:
$ sudo virsh net-start default

Appendix

Install GNOME on Debian

$ sudo tasksel install desktop gnome-desktop
$ sudo tasksel install laptop

## To tell Debian 10 to start the graphical desktop environment by default on boot, run the following command:
$ sudo systemctl set-default graphical.target
$ sudo reboot
Disclaimer: Views expressed in articles are those of the respective authors and do not necessarily reflect the views of their employers or this site. While we aim for accuracy, please verify information before relying on it, and let us know if you spot an error.
Share:

Related Posts

Ansible for Infoblox

Ansible for Infoblox

Configure Ansible for Infoblox Install Python3 on RHEL Instal Python3 on Centos Setup Python VirtualEnv (venv) DONOT Upgrade pip to Latest !!! …

Ansible

Ansible awx cli

Note: This notes are based on the AAP 2.5 Installation # On Red Hat Enterprise Linux 8, the Controller CLI can be installed via dnf: dnf install …

Terraform – Infrastructure as Code

Terraform – Infrastructure as Code

What is Terraform? Core Concepts Terraform Workflow Terraform Workspaces Terraform Modules Real-World Use Cases Ansible Lab on AWS AAP All-in-One on …

Ansible

rancher

1. Introduction to Rancher & RKE 1.1. Rancher Architecture 1.2. Disocvering RKE 1.2.1. Node Preparation 1.2.2. Creating the Cluster Configuration …

Ansible

Ansible for Windows

Checkout the Ansible Automation for Windows guides. WinRM vs OpenSSH – Pros & Cons WinRM (Default) ✔️ Pros ❌ Cons 🆕 OpenSSH ✔️ Pros ❌ Cons 💡 Use …