Manual:CHR ProxMox installation
- 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.
- 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.
#!/bin/bash #vars version="nil" vmID="nil" echo "############## Start of Script ############## ## Checking if temp dir is available..." if [ -d /root/temp ] then echo "-- Directory exists!" else echo "-- Creating temp dir!" mkdir /home/root/temp fi # 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 ] then echo "-- CHR image is available." else echo "-- Downloading CHR $version image file." cd /root/temp echo "
"wget https://download2.mikrotik.com/routeros/$version/chr-$version.img.zip unzip chr-$version.img.zip echo "
- 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 ""
- Create storage dir for VM if needed.
if [ -d /var/lib/vz/images/$vmID ] thenecho "-- VM Directory exists! Ideally try another vm ID!" read -p "Please Enter free vm ID to use:" vmID
elseecho "-- Creating VM image dir!" mkdir /var/lib/vz/images/$vmID
- Creating qcow2 image for CHR.
echo "-- Converting image to qcow2 format " qemu-img convert \-f raw \ -O qcow2 \ /root/temp/chr-$version.img \ /var/lib/vz/images/$vmID/vm-$vmID-disk-1.qcow2
- 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
- End of Script ##############"