|# Digital Ocean Ubuntu 18.04 x64 Droplet with "Regular Intel" CPU.|
|# git clone https://gist.github.com/54fc09734a3911e91eeeb43434f117df.git|
|# cd 54fc09734a3911e91eeeb43434f117df/|
|# chmod +x make-chr.sh|
|# Once the reboot is done, login with root/CHANGEME and change the password!|
|# You might get a "Segmentation fault" on line 56 while the image is being written.|
|# Most of the time this is absolutely fine. Reboot the droplet and attempt to login using Winbox.|
|# If it didn't work, just trash the droplet and try it again.|
|wget http://download2.mikrotik.com/routeros/6.37/chr-6.37.img.zip -O chr.img.zip && \|
|gunzip -c chr.img.zip > chr.img && \|
|apt-get update && \|
|apt install -y qemu-utils pv && \|
|qemu-img convert chr.img -O qcow2 chr.qcow2 && \|
|qemu-img resize chr.qcow2 1073741824 && \|
|modprobe nbd && \|
|qemu-nbd -c /dev/nbd0 chr.qcow2 && \|
|echo "Give some time for qemu-nbd to be ready" && \|
|sleep 2 && \|
|partprobe /dev/nbd0 && \|
|sleep 5 && \|
|mount /dev/nbd0p2 /mnt && \|
|ADDRESS=`ip addr show eth0 | grep global | cut -d' ' -f 6 | head -n 1` && \|
|GATEWAY=`ip route list | grep default | cut -d' ' -f 3` && \|
|PASSWORD="CHANGEME" && \|
|echo "/ip address add address=$ADDRESS interface=[/interface ethernet find where name=ether1]|
|/ip route add gateway=$GATEWAY|
|/ip service disable telnet|
|/user set 0 name=root password=$PASSWORD|
|/ip dns set servers=184.108.40.206,220.127.116.11|
|/system package update install|
|" > /mnt/rw/autorun.scr && \|
|umount /mnt && \|
|echo "Magic constant is 65537 (second partition address). You can check it with fdisk before appliyng this" && \|
|echo "This scary sequence removes seconds partition on nbd0 and creates new, but bigger one" && \|
|echo -e 'd\n2\nn\np\n2\n65537\n\nw\n' | fdisk /dev/nbd0 && \|
|e2fsck -f -y /dev/nbd0p2 || true && \|
|resize2fs /dev/nbd0p2 && \|
|sleep 1 && \|
|echo "Compressing to gzip, this can take several minutes" && \|
|mount -t tmpfs tmpfs /mnt && \|
|pv /dev/nbd0 | gzip > /mnt/chr-extended.gz && \|
|sleep 1 && \|
|killall qemu-nbd && \|
|sleep 1 && \|
|echo u > /proc/sysrq-trigger && \|
|echo "Warming up sleep" && \|
|sleep 1 && \|
|echo "Writing raw image, this will take time" && \|
|zcat /mnt/chr-extended.gz | pv > /dev/vda && \|
|echo "Don't forget your password: $PASSWORD" && \|
|echo "Sleep 5 seconds (if lucky)" && \|
|sleep 5 || true && \|
|echo "sync disk" && \|
|echo s > /proc/sysrq-trigger && \|
|echo "Ok, reboot" && \|
|echo b > /proc/sysrq-trigger|
Can be used on a fresh Ubuntu 16.04 installation.
Does work only in DO ? I tried that on Ubuntu on UpCloud provider and server restarted again to the same system what it was before .. Ubuntu
Ok although it started somehow beside those error on servers from DO and UpCloud. You could also add eth1 for ether2 with private IP which is very important
Yes, after partx -a /dev/nbd0 we have only /dev/nbd0p1 on device
All this made on droplet with Ubuntu 16.04.6 x64 and router OS chr-6.45.2.img.zip (RAW image download).
Any success with the latest Ubuntu version?
I've just tried this script (a bit modified) on Ubuntu 16.04.6 LTS (GNU/Linux 4.4.0-159-generic x86_64).
I changed 65537 to 227328, but in fact that wasn't correct.
Could anyone advise me, how to modify the script correctly?
Here is my fdisk -l result
And here is the modified script by me (but still not correct at all)
And here is the end of stdout after starting the script:
FYI this script has been updated and confirmed working 100% with an Ubuntu 16.04.6 droplet on DigitalOcean.
Mileage may vary - I simply copied the script and pasted it into a terminal and executed it. The droplet reboots just fine, takes a few seconds to download the latest ROS, reboots and it's good to go!
I ran the scrip ./make-chr.sh on my VPS Ubuntu 16.04.6 x84_64 and it gets stuck in the next part:
Warming up sleep
In the VPS screen connection this shows me.
What could be happening? What other code can I try?
Thank you in advance for your reply.
@imperio2k Try it a second time. It looks like there’s some disk synchronization that occurs which causes a kernel panic when the image is being written to disk, before the image can be completely written. I’ve tried this many times using Ubuntu 16.04 and 18.04 and I can assure you that it does work if you are not unlucky enough to get a Kernel panic.
Well received sir, I've worked with the 1GB storage which sometimes is filled with user manager SQL logs. what would be the workaround to resize to say 30gb on an already running AWS EC2 instance?…
On Sat, Aug 31, 2019 at 6:07 AM Denys Stroebel ***@***.***> wrote: @nick1543 <https://github.com/nick1543> @vfedyay <https://github.com/vfedyay> @lzcykevin <https://github.com/lzcykevin> @devstudios <https://github.com/devstudios> @fyrstyk <https://github.com/fyrstyk> FYI this script has been updated and confirmed working 100% with an Ubuntu 16.04.6 droplet on DigitalOcean. *CAVEAT: The disk is only 1GB* - You can change this by changing the number "1073741824" and test for yourself. There were some issues, which I've found, researched about and fixed. - Newer ROS images do not have two partitions, so I've gone back to 6.37 - Trying to use autorun.scr on newer images no longer works, so I've gone back to 6.37 - Partition syncing on DO droplets causes a kernel panic while the image is being written to disk, so the disk had to be shrunk to a reasonable size to be written, so reduced image size to 1GB (1073741824). I don't know why this happens but this method works and having a MikroTik with more than 1GB disk is a rare edge case. - DNS servers set to Cloudflare (18.104.22.168, 22.214.171.124) by default - Added an upgrade to the latest stable ROS on startup — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://gist.github.com/54fc09734a3911e91eeeb43434f117df?email_source=notifications&email_token=AFPR6NFGC7IB7FNKPIBKPTTQHHN7TA5CNFSM4HIM5XRKYY3PNVWWK3TUL52HS4DFVNDWS43UINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAFX5GO#gistcomment-3013223>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AFPR6NBOLUXUD2AYJL2F3QLQHHN7TANCNFSM4HIM5XRA> .
No workaround for that @devstudios. For AWS instances, use the marketplace CHR instead as MikroTik has specifically provided a method of provisioning CHR's on newer software, which they will not provide to consumers.
Response from MikroTik support on the matter:
well understood, until it becomes much of a big deal. I will stick with your gist. it's working perfectly for now.…
On Fri, Jun 12, 2020 at 4:06 PM Denys Stroebel ***@***.***> wrote: ***@***.**** commented on this gist. ------------------------------ No workaround for that @devstudios <https://github.com/devstudios>. For AWS instances, use the marketplace CHR instead as MikroTik has specifically provided a method of provisioning CHR's on newer software, which they will not provide to consumers. Response from MikroTik support on the matter: For security reasons this method of file modification was disabled. Please see our wiki article about CHR Provisioning depending on Your Hypervisor:https://wiki.mikrotik.com/wiki/Manual:CHR#Provisioning — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub <https://gist.github.com/54fc09734a3911e91eeeb43434f117df#gistcomment-3339533>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AFPR6NCEFD25MKOOPRFTXGTRWIR7FANCNFSM4HIM5XRA> .
I'm trying to install chr-7.1beta3.img.zip:
But something does wrong:
Could you please help to understand what's wrong?
@ivazin Unfortunately this method does NOT work for any CHR newer than 6.37. The reason for this is because MikroTik has removed the second partition and now disallows customisation of raw images that this gist makes use of. In this script there is an auto-upgrade to the latest CHR on startup but that will only get you to the latest v6 image.
Once v7 is released, I'm sure you'll be able to use this gist to upgrade from v6 to v7.
Hi, i have a problem with the script. Can somebody help me? From already thank you very much