Category: Virtualization

  • Proxmox useful command to manage Containers

    pct is a command line tool to manage containers (LXC) in proxmox server.

    Here are some useful commands

    pct enter 100
    pct exec 100 yum update
    pct exec 100 yum update -y
    pct list
    pct reboot 100
    pct resize 100 rootfs 100G
    pct set 101 -memory 10000
    pct start 100

    pct documentation available at

    https://pve.proxmox.com/pve-docs/pct.1.html

    See proxmox

  • proxmox config files

    To find versions of proxmox packages

    pveversion -v
    

    Storage Config

    root@server70:~# cat /etc/pve/storage.cfg
    lvm: local_lvm
    	vgname pve
    	content images
    
    dir: local
    	path /var/lib/vz
    	content iso,rootdir,vztmpl,images
    	maxfiles 0
    
    root@server70:~# 
    

    qemu config

    Config for KVM VMs stored in folder

    /etc/pve/nodes/HOSTNAME/qemu-server
    

    Example

    root@server70:~# cat /etc/pve/nodes/server70/qemu-server/100.conf 
    boot: c
    bootdisk: virtio0
    cores: 6
    ide2: none,media=cdrom
    memory: 32768
    name: vm701.hosthat.com
    net0: virtio=02:00:00:AC:77:3C,bridge=vmbr0
    numa: 0
    onboot: 1
    ostype: l26
    protection: 1
    smbios1: uuid=28537e4f-e1ce-4f44-8421-e004370ab6b4
    sockets: 1
    virtio0: local_lvm:vm-100-disk-1,size=500G
    root@server70:~# 
    

    Cluser

    root@server70:~# cat /etc/pve/.members
    {
    "nodename": "server70",
    "version": 3,
    "cluster": { "name": "help", "version": 1, "nodes": 1, "quorate": 1 },
    "nodelist": {
      "server70": { "id": 1, "online": 1, "ip": "158.69.124.221"}
      }
    }
    root@server70:~# 
    
  • KVM VNC Allow Remote Access

    By default VNC Console on a KVM virtual Machine only listens to localhost. So you need to do SSH tunnel to access VNC console.

    To make VNC available on all interfaces on Host machine, you need to edit file

    vi  /etc/libvirt/qemu.conf
    

    You need to uncomment the line vnc_listen = “0.0.0.0”.

    # VNC is configured to listen on 127.0.0.1 by default.
    # To make it listen on all public interfaces, uncomment
    # this next option.
    #
    # NB, strong recommendation to enable TLS + x509 certificate
    # verification when allowing public access
    #
    vnc_listen = "0.0.0.0"
    

    Once this is done, you need to shutdown and start the virtual machine. Just reboot won’t work.

    root@PAR-199235:~# virsh vncdisplay kali-linux
    127.0.0.1:0
    
    root@PAR-199235:~# virsh shutdown kali-linux
    Domain kali-linux is being shutdown
    
    root@PAR-199235:~# virsh list --all
     Id   Name         State
    -----------------------------
     -    kali-linux   shut off
    
    root@PAR-199235:~# virsh start  kali-linux
    Domain kali-linux started
    
    root@PAR-199235:~# virsh vncdisplay kali-linux
    :0
    
    root@PAR-199235:~# 
    

    See Linux KVM

  • Install Vagrant on CentOS

    To install Vagrant on CentOS, go to

    https://www.vagrantup.com/downloads

    Get link to latest version, then run “rpm -ivh URL_TO_RPM_FILE”.

    At time of writing this post, latest Vagrant version is 2.2.9, to install Vagrant 2.2.9, run

    rpm -ivh https://releases.hashicorp.com/vagrant/2.2.9/vagrant_2.2.9_x86_64.rpm
    

    install vagrant on centos

    To check Vagrant version

    vagrant --version
    

    See Vagrant

  • Install Linux KVM on CentOS 8

    To install Linux KVM hypervisor on CentOS 8, run

    dnf install qemu-kvm
    

    Install libvirtd

    dnf install libvirt-daemon libvirt-daemon-kvm libvirt-client
    

    Enable libvirtd to start on boot

    systemctl enable libvirtd
    

    Start libvirtd

    systemctl start libvirtd
    

    To see status, run

    systemctl status libvirtd
    

    Install virt-install

    dnf install virt-install
    

    Now you have Linux KVM installed. You can use virt-install or Virt Manager to create virtual machine.

    See Linux KVM Virtualization

  • OpenVZ

    List available OS Templates in your server

    vzpkg list -O
    vzpkg list -O --with-summary
    

    To create a container, run

    prlctl create MyCT --vmtype ct --ostemplate centos-7-x86_64
    

    Lit all vms

    prlctl list -a
    
  • Identify virtual machine technology

    virt-what is a shell script which can be used to detect if the program is running in a virtual machine.

    It will identify what VM technology is used for current VM. For example KVM, Xen, HyperV etc.

    On CentOS 7, install virt-what with

    yum -y install virt-what

    On Debian/Ubuntu

    apt install virt-what

    Example

    virt-what

    See VPS

  • Vagrant

    Vagrant allows you to quickly create virtual machines.

    You can download vagrant boxes from

    https://app.vagrantup.com/boxes/search
    Vagrant private_network can’t ping

    Install Vagrant

    Install vagrant in Debian/Ubuntu

    apt install vagrant -y
    

    You may also need to install virtualbox

    apt install virtualbox
    

    Using Vagrant

    To update vagrant boxes, run

    vagrant box update
    

    To list all available vagrant boxes

    vagrant box list
    

    Snapshot

    To create a snapshot

    vagrant snapshot save first-snapshot
    

    To list available snapshots

    vagrant snapshot list
    
  • Proxmox 6 disable No valid subscription notice

    Proxmox 6 disable No valid subscription notice

    To disable No valid subscription notice from proxmox, edit file

    vi /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
    

    Find

    if (data.status !== 'Active') {
    

    This is on line 380. inside function checked_command

    Replace with

    if (false) {
    

    Resart pveproxy

    systemctl restart pveproxy
    
  • virt-manager

    virt-manager is a GUI tool to manage virtual machines.

    On CentOS desktop, install it with

    yum install virt-manager
    

    For installing on Ubuntu, see Install virt-manager on Ubuntu

    Connect to remote KVM server

    To connect to remote KVM server from virt-manager, Go to File > Add Connection

    virt-manager kvm

    If SSH port is not 22, use IP:PORT format to connect to KVM installation.

    Once connected, you will see all VMs. Here we have 1 VM with name “foo”

    You can double click on a VM to access its console/desktop.

    virt-manager console

    See kvm