... or another Linux hosting.
Immediately, I’ll make a reservation that since I’ve been tired of demolishing and re-adjusting the droplet in DO during all experiments, I’ll follow the example in VMware ESXi, but this will not affect the final result, the commands will all be the same, in principle, this applies to Any cloud VPS hosting where we have SSH access.The report is based on Dmitry Pichulin
deemru at the
MUM in September 30 in Moscow. In contrast to the report of Dmitry, this article will not consider the issues of choosing a hosting and prices for it (in an effort to make the cloud router cheaper), the settings of the received device. Only the technical side of the issue will be considered and a couple of problems solved.
Returning from MUM, I was in anticipation, my hands itched to gash Mikrotik on Digital Ocean (at that moment, there was Ubuntu Server, which served as a VPN server). It was useful to watch the archive of speeches, but it was not there yet and I wrote a letter to Dmitry with a request to share the slides. Having received a presentation with a cold head, he rushed into battle - breaking his droplet completely. I did everything as in the presentation, everything started. Easier and impossible to come up with. Download the image to the hosting, unpack it, translate the file system to read-only, upload the image to disk via dd. But it was then that the first inconsistency awaited me - when Dmitry first booted the
CHR , the file system expanded automatically and it took up the entire disk, but this did not happen and I had to be content with 128 MB.
Someone will say 128 MB on the router is enough for everyone. But I was not satisfied with this situation, so I began to eliminate it. Everyone knows that RouterOS is based on Linux, but there is not much left of Linux, so after installing the system, it cannot be re-partitioned by regular means. It is impossible to boot from any LiveCD and redefine it (well, at least for DO it is impossible). Attempts to poke with fdisk and parted after uploading the image to disk, but before rebooting, also did not lead to any positive result (the effect either did not exist at all, or I received a non-bootable system).
')
Normal heroes always go around.
So, in order to get RouterOS installed on the Digital Ocean, in which 20 GB of disk space is available (well, or how much you have at the rate), we will need:
- Actually, droplet with the Linux distribution installed (in this case, the distribution will be Ubuntu Server 16.04 x64, and instead of droplet, there will be a virtual machine in ESXi, but once again, it will not play the role) to which we have access via SSH .
- The hypervisor installed on the computer or server (initially I did in VirtualBox, now I will do it again in ESXi, this does not affect the final result).
- LiveCD of your favorite Linux distribution (it is desirable that there is a GUI, it will be more convenient).
As you can see, the list is not very large, there are no special requirements for its points, I tried to make the decision as versatile and simple as possible so that everything could be built literally on my knee from what is.
Let's start with the droplet.
We need to figure out how much disk space we need in the virtual machine, so:
fdisk -l /dev/sda /dev/sda: 16 GiB, 17179869184 , 33554432 : 1 * 512 = 512 (/): 512 / 512 I/O size (minimum/optimal): 512 bytes / 512 bytes : dos : 0x7b5dbf9c - Start Size Id /dev/sda1 * 2048 31457279 31455232 15G 83 Linux /dev/sda2 31459326 33552383 2093058 1022M 5 /dev/sda5 31459328 33552383 2093056 1022M 82 Linux / Solaris
As we see, we have a disk of 17179869184 bytes, remember this value.
Preparation of the intermediate machine
In the hypervisor, create a new virtual machine. Its parameters do not really matter, but you can, for example, make them close to the characteristics of a droplet. It is better to make the disk size with a small margin, just in case (for some reason, 20GB in DO turned out to be less than 20GB in VirtualBox). We configure loading of the virtual computer from LiveCD.

We include it and after downloading we download in any convenient way the latest version of CHR, which can be found
at the link :

We need an image Raw disk image (for example
chr-6.37.1.img.zip ). Unpack the archive:
unzip chr-6.37.1.img.zip Archive: chr-6.37.1.img.zip inflating: chr-6.37.1.img
And we upload the image to the hard disk using dd (Dmitry used the pv utility here, but I honestly don’t see the point, because the image is small and unfolds pretty quickly):
dd if=chr-6.37.1.img.zip of=/dev/sda 262144+0 records in 262144+0 records out 134217728 bytes (134 MB, 128 MiB) copied, 5.64304 s, 23.8 MB/s
instead of sda, you need to specify your disk, its name may differ.
Expanding the file system RouterOS
Fans can do everything in the console there, it seemed to me faster and easier to do everything in GParted.
Run GParted, select the disk on which you installed RouterOS and use the Resize / Move function to increase the size of the second partition. Please note that the partition size minus the size of the first partition should not exceed the size of the disk of your droplet, which we looked at the very beginning (i.e., the first partition is 32 MiB, so the second should be no more than 17179869184 bytes / 1048576 = 16384 MiB and - 32, i.e. 16352 MiB)

Do not forget to apply changes to the disk layout.
Create a new image and click on it with gzip:
dd if=/dev/sda bs=8196 count 17000 | gzip -9cf > chr.img.gz 17000+0 records in 17000+0 records out 139332000 bytes (139 MB, 133 MiB) copied, 3.30824 s, 42.1 MB/s
The value of 17000 we get by reducing the size of the image when it is deployed to disk. There was 128 MiB, i.e. 128 * 1024 = 131072 KiB divide the size by the block size and round 131072/8 = 16384 ≈ 17000 blocks.
Fill the resulting image on the droplet and install it
scp chr.img.gz user@host:~/
Where user is the name of the user on your droplet, and host is his address. Copying will be performed to the user's home directory.
Accept the ssh server certificate, and enter the password when asked for it. After the end of copying, this virtual machine is no longer needed.
Go to our droplet. You can connect to it via ssh or log in via the console. Make sure that our image is copied, anyone can check the checksums. Let's translate the file system into read-only mode and deploy the image to disk via gzip and dd:
echo u > /proc/sysrq-trigger && gunzip -c chr.img.gz | dd of=/dev/vda
Everything! CHR is installed on our droplet. Reboot:
reboot
Welcome to Mikrotik Cloud Hosted Router
@gexogen is a cheat !!!In fact, even though I promised that there is no difference, in Digital Ocean we do it or in ESXi, there is still a difference. In DO everything works, but ESXi after a reboot fell into the Kernel Panic. But, in ESXi the file system is stretched and so at the first boot and these manipulations are not required.
After the reboot, we enter under the user admin without a password, after which we set the password, register the ip address and default route:
/ system user set admin password = YOURPASSWORD
/ ip address add address = YOUR.IP.ADD.RESS / MASK
/ ip route add gateway = YOUR.GATE.WAY.IP
After that, you can connect to it and configure it through the Winbox.
Conclusion

In an accessible place, you can install a Linux virtual machine inside RouterOS, or use it in some other way - at your discretion (to raise an FTP server or something else).
References:
Presentation of Dmitry in PDF formatRecording his performancesJust in case, a link to a ready-made image for a 20 GB file system (i.e., a minimum DO rate of $ 5)