Add docs/tech_docs/KVM-virtualization-setup.md
This commit is contained in:
60
docs/tech_docs/KVM-virtualization-setup.md
Normal file
60
docs/tech_docs/KVM-virtualization-setup.md
Normal file
@@ -0,0 +1,60 @@
|
||||
### 1. Folder Structure Best Practices
|
||||
For a well-organized virtualization environment, consider the following directory structure:
|
||||
|
||||
- **VM Images Directory:**
|
||||
- Default path: `/var/lib/libvirt/images/`
|
||||
- This is the default location where the disk images of your VMs are stored. However, if you have a dedicated storage device or partition for VMs, you can create a directory there and symlink it to this path.
|
||||
|
||||
- **ISOs Directory:**
|
||||
- Suggested path: `/var/lib/libvirt/isos/`
|
||||
- Store all your downloaded ISO files here. This helps in easily locating and managing different OS installation media.
|
||||
|
||||
- **Cloud Images:**
|
||||
- Suggested path: `/var/lib/libvirt/cloud-images/`
|
||||
- If you plan to use cloud-init images for VMs, it's good to keep them separate from standard ISOs for clarity.
|
||||
|
||||
- **Snapshots and Backups:**
|
||||
- Suggested path: `/var/lib/libvirt/snapshots/` and `/var/lib/libvirt/backups/`
|
||||
- Having dedicated directories for snapshots and backups is crucial for easy management and recovery.
|
||||
|
||||
**Note:** Always ensure that these directories have appropriate permissions and are accessible by the `libvirt` group.
|
||||
|
||||
### 2. Networking Setup
|
||||
For networking, you typically have a few options:
|
||||
|
||||
- **NAT Network (Default):**
|
||||
- This is the default network (`virbr0`) set up by libvirt, providing NAT (Network Address Translation) to the VMs. VMs can access external networks through the host but are not accessible from outside by default.
|
||||
|
||||
- **Bridged Network:**
|
||||
- A bridge network connects VMs directly to the physical network, making them appear as physical hosts in your network. This is useful if you need VMs accessible from other machines in the network.
|
||||
- To set up a bridge, you can use `nmcli` (NetworkManager command-line interface) or manually edit network interface configuration files.
|
||||
|
||||
- **Host-Only Network:**
|
||||
- For VMs that only need to communicate with the host and other VMs, a host-only network is suitable.
|
||||
|
||||
**Verifying Network:**
|
||||
- Check the default network is active: `virsh net-list --all`
|
||||
- For custom network configurations, validate using `ip addr` and `brctl show`.
|
||||
|
||||
### 3. Storage Setup
|
||||
For VM storage, consider the following:
|
||||
|
||||
- **LVM (Logical Volume Management):**
|
||||
- Ideal for production environments. LVM allows for flexible management of disk space, easy resizing, and snapshotting capabilities.
|
||||
- You can create a dedicated volume group for your VMs for better management.
|
||||
|
||||
- **Standard Partitions:**
|
||||
- If you don’t use LVM, ensure that you have a partition or a separate disk with sufficient space for your VM images.
|
||||
|
||||
- **External/NAS Storage:**
|
||||
- For larger setups, you might consider network-attached storage (NAS). Ensure the NAS is mounted properly on your system and has the necessary read/write permissions.
|
||||
|
||||
- **Storage Pools:**
|
||||
- Libvirt can manage various types of storage pools. You can create and manage them using `virsh` or Virt-Manager.
|
||||
|
||||
### Final Checks and Tips
|
||||
|
||||
- **Permissions:** Ensure the `libvirt` group has proper permissions on all these directories.
|
||||
- **Security:** If your VMs are exposed to the internet, implement necessary security measures (firewalls, updates, secure passwords).
|
||||
- **Monitoring and Maintenance:** Regularly monitor the performance and storage usage. Tools like `virt-top` and `nmon` can be handy.
|
||||
- **Documentation:** Keep a record of your setup and configurations for future reference or troubleshooting.
|
||||
Reference in New Issue
Block a user