Community discussions

MikroTik App
 
Iliasla
just joined
Topic Author
Posts: 12
Joined: Thu Dec 22, 2011 7:33 pm
Location: Siberia
Contact:

Manual - Installing CHR on VPS hosting with GRUB loader (vpsserver.com for example)

Tue Mar 01, 2022 11:24 am

Installing CHR on VPS hosting with GRUB loader

Instructions are given for hosting vpsserver.com as of 2022-03-01

Hosting is distinguished by the presence of pre-installed Grub in Linux systems, the primary loader of which is loaded over the network (PXE).
The user's system must therefore contain a Grub configuration file.
But the config is missing in CHR and therefore the booting process does not occur.
This manual solves this problem.

CHR installation is performed in the standard way "on a hosting without CHR support" with overwriting the disk of the selected Linux system with the CHR image.
It is convenient to choose Debian.


== Attention! Before installing CHR, you need to find out the IP address, network mask and gateway in the preinstalled Linux system. ==


1. In the VPS control panel, restart our VPS server in "Resque-Mode" (at the same time, CentOS is launched from the service media on the hosting).

2. Log in to CentOS (the login and password are the same as those issued when registering the server)

3. Install unzip in CentOS (answer Yes to both questions during installation)
sudo yum install unzip

4. Mount "tmp" folder
mount -t tmpfs tmpfs /tmp/

5. Download chr to the tmp folder and unpack
cd /tmp
wget https://download.mikrotik.com/routeros/7.1.3/chr-7.1.3.img.zip
unzip chr-7.1.3.img.zip

6. We find out the necessary disk with the command
fdisk -l | grep da
in our case it will be /dev/vda

7. Deploy the image to disk
dd if=chr-7.1.3.img of=/dev/vda bs=4M oflag=sync
You can give the "sync" command to be sure

8. Check that there are now two partitions on the disk (vda1 and vda2)
fdisk -l | grep da

9. Launch MC (this is Midnight Commander)
create a folder along the path /media/vda1,
mount the primary partition of the expanded CHR image (in our case, this is /dev/vda1)
mount /dev/vda1 /media/vda1

10. Go to the /media/vda1 folder, create a folder structure /boot/grub2/
and place the Grub config file in it under the name grub.cfg (this is used on hosting vpsserver.com )
It is convenient to simply copy and rename to grub.cfg some existing short text file.
Edit grub.cfg and place the text in it:

setparams 'Grub 2'
set root=(hd0,msdos1)
chainloader +1

Save the file, exit to MC from these folders (from disk vda1) and exit MC.

11. Flush data from memory to disk and unmount the folder
sync
umount /dev/vda1

You can run MC again and make sure that the /media/vda1 folder is now empty.

12. Reboot in the standard forced way (perhaps this step is not needed when working with resque systems?)
echo 1 > /proc/sys/kernel/sysrq
echo b > /proc/sysrq-trigger

With this reboot, we continue to be in "Resque Mode" and CentOS is loaded.

13. Restart our VPS from the hosting control panel in normal mode. It will take some time.
Power -> Reboot

14. Connect the hosting console to the terminal of our newly installed Mikrotik CHR and set the admin password.
We introduce a minimum of the necessary rules on CHR:
(new admin account, turn off the old one, firewall, ip address, main table and gateway)

user add name=youradmin password=yourpassword group=full
ip firewall filter add chain=input action=accept connection-state=established,related,untracked
ip firewall filter add chain=input action=accept protocol=icmp
ip firewall filter add chain=input action=accept protocol=tcp dst-port=8291 src-address=yourIPaddress
ip firewall filter add chain=input action=drop
ip address add address=VPSaddressIP/MASK interface=ether1
ip route add dst-address=0.0.0.0/0 gateway=VPSgatewayIP

15. We connect with the winbox, license, configure further.
Last edited by Iliasla on Fri Apr 29, 2022 5:16 am, edited 1 time in total.
 
brg3466
Member Candidate
Member Candidate
Posts: 177
Joined: Sat Aug 01, 2015 7:29 am

Re: Manual - Installing CHR on VPS hosting with GRUB loader (vpsserver.com for example)

Fri Apr 01, 2022 7:55 am

Thank you for sharing !
 
BoZi
just joined
Posts: 2
Joined: Fri Jan 29, 2021 11:08 am

Re: Manual - Installing CHR on VPS hosting with GRUB loader (vpsserver.com for example)

Fri May 20, 2022 9:55 am

With RouterOS CHR v7.x.x. you can get an error "xz-compress data is corrupt" during the first boot.
The workaround is to:
  • update to v 7.x.x.
Did work for me on SolusVM Qemu KVM VDS(VPS) of Hostlife hosting provider.
Last edited by BoZi on Fri May 20, 2022 9:57 am, edited 1 time in total.

Who is online

Users browsing this forum: No registered users and 11 guests