This is another really big subject. I don't know how far I'll get on it. So this will likely take up multiple posts.
Virtualization in Linux refers to the creation of virtual versions of computing resources, such as operating systems, servers, storage devices, and networks. This allows multiple virtual environments to run on a single physical hardware system, improving resource utilization and flexibility.
There are different types of virtualization, and there are different degrees of isolation in virtualization. How is that for confusing? More about that later.
Before we get too far down this road. Is your computer a good candidate for a virtualization host? Well, virtualization takes up resources. More RAM, more CPU, more hard drive space. Most modern CPUs support something called hardware virtualization. It isn't an absolute requirement, but it'll make your life easier and your computer happier if it supports hardware virtualization.
How can I find out if my computer supports hardware virtualization? My first question would be how many CPU cores do you have?
This often returns multiple lines of information, but usually you only need 1 line to know. I would recommend 4 cores at the minimum. People do it with 2 cores. But not very efficiently. These days some desktop CPUs have 8, 12 or 16 cores. More is better for virtualization. (The price goes up accordingly). The second things you need to know, is does my CPU support hyperthreading? Almost all modern CPUs do.
These will almost always be "two". Hyperthreading makes your CPU core look like it's two CPU cores. These are sometimes called "Virtual CPUs" or vcpus. How can you find out how many vcpus you have?
This will usually be the numbers of cores x 2 hyperthreads. So if you have 4 cores, it will show up as 8. If you have 8 cores, it will show up as 16.
Next, OK, I have enough CPU cores, but does my CPU support hardware virtualization?
Intel CPUs will have a vmx flag. AMD CPUs will have a svm flag.
Another way to check is...
This will show either "VT-x" or "AMD-V". I'll let you guess which is Intel, and which is AMD.
If your computer CPU doesn't have these flags, you can still do virtualization. But your CPU will have to emulate it. That takes up even more CPU overhead to emulate these things and it slows down your computer a little. You really need at least 2 vcpus for your host computer, and at least 2 vcpus for your virtual computer.
The second thing is RAM. How much memory does your computer have? There are a number of ways to find this out.
I personally don't like the "free" command because rounds my memory down, so it isn't totally accurate.
So we can use...
This will show your RAM, and your swap space if you're using any. We only really care about memory. Not swap.
Another way to get the same value is...
If you see a number like this... "16081376" that means you have 16GB of RAM. " 65749300 kB" means you have 64GB of RAM.
How much RAM do you need? It depends? First much RAM does your current distro use? In todays Linux, it is usually somewhere between 1.5 and 3.5GB depending on what distro and what desktop you're running. I usually recommend 8GB as the minimum for a Virtualization host. Some people do it with 4GB. But again, this isn't always efficient and often uses swap space.
It's a simple formula, lets say you need 4GB to run Linux on your computer, and lets say you need 4GB to run your VM (virtual machine). That means you need 8GB or RAM. How can you find out how much RAM your computer is currently using?
"top" will also show you. There are multiple ways to find out.
Finally how much hard drive space do you have? How much space do you need? Again it depends on the distro you want to run in your VM. As a rule, I usually recommend 20GB for a Virtual machine disk. This is in addition to whatever your current distro takes up. This isn't quite as bad as it sounds. Most virtualization applications such a VirtualBox and KVM/Qemu use something called "sparse disks". These are very handy, and will often only take up 1GB or 2 GB of disk space, while looking like your VM has 20GB of disk space. As you add more applications to your VM, the disk will grow in size to accommodate the new applications. But eventually the disk will often take up at least 10GB or more or actual disk space.
OK, so now you should know if your computer is a good candidate for a Virtualization host. Does it have enough CPU cores?
Does my CPU support hardware virtualization? Do I have enough RAM? Do I have enough disk space?
If the answers to these questions is yes. We can move forward.
If your computer has enough resources, you can actually run multiple virtual machines at the same time. But not to worry, even if you can't run multiple VMs at the same time, you can still have Multiple VMs on your computer (they do take up disk space) but you might only be able to run one at a time.
... to be continued...
Virtualization in Linux refers to the creation of virtual versions of computing resources, such as operating systems, servers, storage devices, and networks. This allows multiple virtual environments to run on a single physical hardware system, improving resource utilization and flexibility.
There are different types of virtualization, and there are different degrees of isolation in virtualization. How is that for confusing? More about that later.
Before we get too far down this road. Is your computer a good candidate for a virtualization host? Well, virtualization takes up resources. More RAM, more CPU, more hard drive space. Most modern CPUs support something called hardware virtualization. It isn't an absolute requirement, but it'll make your life easier and your computer happier if it supports hardware virtualization.
How can I find out if my computer supports hardware virtualization? My first question would be how many CPU cores do you have?
Code:
cat /proc/cpuinfo | grep cores
This often returns multiple lines of information, but usually you only need 1 line to know. I would recommend 4 cores at the minimum. People do it with 2 cores. But not very efficiently. These days some desktop CPUs have 8, 12 or 16 cores. More is better for virtualization. (The price goes up accordingly). The second things you need to know, is does my CPU support hyperthreading? Almost all modern CPUs do.
Code:
lscpu | grep "Thread(s) per core"
These will almost always be "two". Hyperthreading makes your CPU core look like it's two CPU cores. These are sometimes called "Virtual CPUs" or vcpus. How can you find out how many vcpus you have?
Code:
lscpu | grep "^CPU(s):"
This will usually be the numbers of cores x 2 hyperthreads. So if you have 4 cores, it will show up as 8. If you have 8 cores, it will show up as 16.
Next, OK, I have enough CPU cores, but does my CPU support hardware virtualization?
Code:
grep -E 'vmx|svm' /proc/cpuinfo
Intel CPUs will have a vmx flag. AMD CPUs will have a svm flag.
Another way to check is...
Code:
lscpu | grep Virtualization
This will show either "VT-x" or "AMD-V". I'll let you guess which is Intel, and which is AMD.
If your computer CPU doesn't have these flags, you can still do virtualization. But your CPU will have to emulate it. That takes up even more CPU overhead to emulate these things and it slows down your computer a little. You really need at least 2 vcpus for your host computer, and at least 2 vcpus for your virtual computer.
The second thing is RAM. How much memory does your computer have? There are a number of ways to find this out.
Code:
free -h
So we can use...
Code:
vmstat -s | grep total
This will show your RAM, and your swap space if you're using any. We only really care about memory. Not swap.
Another way to get the same value is...
Code:
cat /proc/meminfo | grep MemTotal
How much RAM do you need? It depends? First much RAM does your current distro use? In todays Linux, it is usually somewhere between 1.5 and 3.5GB depending on what distro and what desktop you're running. I usually recommend 8GB as the minimum for a Virtualization host. Some people do it with 4GB. But again, this isn't always efficient and often uses swap space.
It's a simple formula, lets say you need 4GB to run Linux on your computer, and lets say you need 4GB to run your VM (virtual machine). That means you need 8GB or RAM. How can you find out how much RAM your computer is currently using?
Code:
free
"top" will also show you. There are multiple ways to find out.
Finally how much hard drive space do you have? How much space do you need? Again it depends on the distro you want to run in your VM. As a rule, I usually recommend 20GB for a Virtual machine disk. This is in addition to whatever your current distro takes up. This isn't quite as bad as it sounds. Most virtualization applications such a VirtualBox and KVM/Qemu use something called "sparse disks". These are very handy, and will often only take up 1GB or 2 GB of disk space, while looking like your VM has 20GB of disk space. As you add more applications to your VM, the disk will grow in size to accommodate the new applications. But eventually the disk will often take up at least 10GB or more or actual disk space.
OK, so now you should know if your computer is a good candidate for a Virtualization host. Does it have enough CPU cores?
Does my CPU support hardware virtualization? Do I have enough RAM? Do I have enough disk space?
If the answers to these questions is yes. We can move forward.
If your computer has enough resources, you can actually run multiple virtual machines at the same time. But not to worry, even if you can't run multiple VMs at the same time, you can still have Multiple VMs on your computer (they do take up disk space) but you might only be able to run one at a time.
... to be continued...
Last edited: