Manual:CHR ProxMox installation

From MikroTik Wiki
Revision as of 15:35, 5 September 2017 by Kasparsk (talk | contribs) (Alternative approach)
Jump to: navigation, search
  • Create a new guest with the system disk and other devices as required.
  • Then you have to manually upload the CHR disk (in qcow format) on the ProxMox host.
  • Use scp or any other comparable tool as that will use SSH for the upload and it does not require any additional configuration.
  • Either copy the file to the server and then manually edit the VM's .conf file or replace previously created system image file used for booting the guest.
  • Local storage on ProxMox is in /var/lib/vz directory. There should be a subdirectory called images with a directory for each VM (named by the VM number). You can copy the files directly there.
  • For adding the existing file to the VM, edit the VM's .conf file directly. Look in /etc/pve/qemu-server/ for a file with the VM number followed by .conf.

Note: It's a good idea to create a second test VM so you can refer to it's .conf file to make sure you get the syntax right

Alternative approach

  • Create Basic VM via ProxMox web gui.
  • Make sure that VM storage is on local storage (This way there will no need to work with LVM config side, and disk image can be moved later on to LVM or other desired storage if needed).
  • Log into ProxMox host via SSH and navigate to VM image directory. Default local storage is located in: "var/lib/vz/images/(VM_ID)"
  • via SCP, wget, etc tool download CHR raw image into this directory.
  • Now convert chr raw image to qcow2 format via qemu-img tool:

"qemu-img convert -f raw -O qcow2 chr-6.40.3.img vm-(VM_ID)-disk-1.qcow2"

Bash script approach

If you have access to ProxMox host then CHR VM can also be created quickly via bash script. Below example of one such script.

What this script does:

  • Stores tmp files in: "/root/temp" dir
  • Downloads raw image archive from MikroTik AWS download page.
  • Converts image file to qcow format
  • Creates basic VM that is attached to MGMT bridge.


echo "############## Start of Script ##############

## Checking if temp dir is available..."
if [ -d /root/temp ] 
    echo "-- Directory exists!"
    echo "-- Creating temp dir!"
    mkdir /home/root/temp
# Ask user for version
echo "## Preparing for image download and VM creation!"
read -p "Please input CHR version to deploy (6.38.2, 6.40.1, etc):" version
# Check if image is available and download if needed
if [ -f /root/temp/chr-$version.img ] 
    echo "-- CHR image is available."
    echo "-- Downloading CHR $version image file."
    cd  /root/temp
    echo "

   unzip chr-$
   echo "

" fi

  1. List already existing VM's and ask for vmID

echo "== Printing list of VM's on this hypervisor!

" qm list echo "" read -p "Please Enter free vm ID to use:" vmID echo ""

  1. Create storage dir for VM if needed.

if [ -d /var/lib/vz/images/$vmID ] then

   echo "-- VM Directory exists! Ideally try another vm ID!"
   read -p "Please Enter free vm ID to use:" vmID


   echo "-- Creating VM image dir!"
   mkdir /var/lib/vz/images/$vmID


  1. Creating qcow2 image for CHR.

echo "-- Converting image to qcow2 format " qemu-img convert \

   -f raw \
   -O qcow2 \
   /root/temp/chr-$version.img \
  1. Creating VM

echo "-- Creating new CHR VM" qm create $vmID \

 --name chr-$version \
 --net0 virtio,bridge=vmbr0 \
 --bootdisk virtio0 \
 --ostype l26 \
 --memory 256 \
 --onboot no \
 --sockets 1 \
 --cores 1 \
 --virtio0 local:$vmID/vm-$vmID-disk-1.qcow2

echo "

                            1. End of Script ##############"