Community discussions

MikroTik App
 
benthompson
just joined
Topic Author
Posts: 23
Joined: Fri Jun 10, 2016 12:24 am

Using CHR on AWS with a disk bigger than 1GB

Wed Mar 07, 2018 5:42 am

We're running CHR in AWS as a Dude server. This works great for our purpose, but we had hit the limits of the 1GB disk that comes from the standard AMI image. Resizing the disk proved very difficult. To get a disk bigger than 1GB I ended up having to create our own AMI from scratch and manually update it.

To make things further complicated, the steps on the CHR AWS Installation page proved to be outdated and of little use.

So to help the next guy with this problem, here are the steps I used to get there:
  1. Download the latest raw disk image from the the normal download page. The current version is called chr-6.41.2.img.zip at this moment
  2. Extract the zip
  3. Download and install QEmu
  4. Use QEmu to resize the image to whatever size you want, in this case, 16GB
    qemu-img resize -f raw chr-6.41.2.img 16G
  5. Upload the resulting file to your AWS S3 bucket however you want. I used S3 Express since it supported multipart uploading.
    put chr-6.41.2.img <your bucket>/chr-6.41.2.img -mul:50 -t:4
  6. Create a text file called container.json that specifies where the images is in S3, and what you want to call it.
    {
    "Description": "Mikrotik CHR 6.41.2 (16GB)",
    "Format": "raw",
    "UserBucket": {
    "S3Bucket": "<your bucket name>",
    "S3Key": "chr-6.41.2.img"
    }
    }
  7. Import the uploaded file as a snapshot in EC2 - this returns a ImportTaskId which you will need for the next step
    aws ec2 import-snapshot --description "Mikrotik CHR 6.41.2 (16GB)" --disk-container file://containers.json
  8. Use the ImportTaskId to check the import status periodically. This took me about 10mins for this to complete. When this is done it will give you a SnapshotId which you will need for the next step
    aws ec2 describe-import-snapshot-tasks --import-task-ids <ImportTaskId>
  9. Use the SnapshotId to create an AMI from the snapshot
    aws ec2 register-image --name "Mikrotik CHR 6.41.2 (16GB)" --architecture x86_64 --root-device-name /dev/sda1 --virtualization-type hvm --block-device-mappings DeviceName="/dev/sda1",Ebs={SnapshotId=<SnapshotId>}
  10. Tada! You now have a AMI that you can launch to create your CHR.

Who is online

Users browsing this forum: No registered users and 14 guests