Part of the OmniOS distribution media is a set of disk images in various formats which are suitable for using in a cloud environment such as AWS EC2.
These cloud images are available on our downloads page.
Converting these images into an AMI ready to run is fairly straightforward:
If you’re doing this on OmniOS, then the easiest way to set up the AWS command line interface is through a Python virtual environment (venv).
This example uses an environment called awscli.
$ python3 -mvenv awscli $ . awscli/bin/activate (awscli) $ pip install awscli Place your AWS access key and secret key and your preferred region in the AWS cli configuration file at ~/.aws/config, for example: [default] aws_access_key_id=XXXXXXXXXXXXXXXXXXXX aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx region=eu-central-1 At this point you should be able to run aws commands, for example try: $ aws ec2 describe-regions Uploading the image to an S3 bucket Assuming you have an S3 bucket called mybucket, you can upload the cloud VMDK image directly:
>> aws iam create-role --role-name vmimport --assume-role-policy-document "file://./trust-policy.json"
{
"Role": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Condition": {
"StringEquals": {
"sts:Externalid": "vmimport"
}
},
"Principal": {
"Service": "vmie.amazonaws.com"
}
}
]
},
"RoleId": "AROAQ2W5AEWTW4YDP5ADK",
"CreateDate": "2023-07-05T18:43:30Z",
"RoleName": "vmimport",
"Path": "/",
"Arn": "arn:aws:iam::057371796903:role/vmimport"
}
}
>> aws iam put-role-policy --role-name vmimport --policy-name vmimport --policy-document "file://./role-policy.json"
{
"Version":"2012-10-17",
"Statement":[
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:CreateBucket"
],
"Resource": [
"arn:aws:s3:::omniosvmimports/",
"arn:aws:s3:::omniosvmimports/*"
]
},
{
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
"s3:PutObject",
"s3:GetBucketAcl"
],
"Resource": [
"arn:aws:s3:::omniosvmexports/",
"arn:aws:s3:::omniosvmexports/*"
]
},
{
"Effect": "Allow",
"Action": [
"ec2:ModifySnapshotAttribute",
"ec2:CopySnapshot",
"ec2:RegisterImage",
"ec2:Describe*"
],
"Resource": "*"
}
]
}
>> aws ec2 import-snapshot --disk-container file://./ebs.json
{
"Description": "omnios-r151046.cloud",
"Format": "vmdk",
"UserBucket": {
"S3Bucket": "omniosvmimports",
"S3Key": "omnios-r151046.cloud.vmdk"
}
}
....
{
"SnapshotTaskDetail": {
"Status": "active",
"Progress": "0",
"DiskImageSize": 0.0,
"StatusMessage": "pending",
"UserBucket": {
"S3Bucket": "omniosvmimports",
"S3Key": "omnios-r151046.cloud.vmdk"
}
},
"ImportTaskId": "import-snap-092d7c88042c3bfb5"
}
$ aws ec2 describe-import-snapshot-tasks
until the output shows a Status field showing that the job has completed:
{
"ImportSnapshotTasks": [
{
"SnapshotTaskDetail": {
"Status": "active",
"Format": "VMDK",
"DiskImageSize": 718573056.0,
"UserBucket": {
"S3Bucket": "oxidevmimports",
"S3Key": "omnios-r151046.cloud.vmdk"
},
"Progress": "43",
"StatusMessage": "downloading/converting"
},
"ImportTaskId": "import-snap-092d7c88042c3bfb5"
}
]
}
The last step is to create the AMI. Prepare a JSON file to describe the target based on this template. The SnapshotID field must be set to the same value as shown in the previous status command.
{
"Architecture": "x86_64",
"Description": "OmniOS illumos distribution",
"EnaSupport": true,
"Name": "OmniOS r151046",
"RootDeviceName": "/dev/xvda",
"BlockDeviceMappings": [
{
"DeviceName": "/dev/xvda",
"Ebs": {
"SnapshotId": "snap-013fc90c5299a005a"
}
}
],
"VirtualizationType": "hvm",
"BootMode": "uefi"
}
>> aws ec2 register-image \
--region us-east-1 \
--description "OmniOS illumos distribution" \
--name "OmniOS r151046e" \
--block-device-mappings "DeviceName=/dev/xvda,Ebs={SnapshotId=snap-013fc90c5299a005a,DeleteOnTermination=false}" \
--architecture x86_64 \
--root-device-name /dev/xvda \
--virtualization-type hvm \
--ena-support \
--boot-mode uefi
and import:
$ aws ec2 register-image --cli-input-json file://image.json
This should return quite quickly and show the assigned AMI ID
{
"ImageId": "ami-0d2ac53424d3c31e4"
}
Last login: Wed Jul 5 20:01:00 2023 from 66.228.25.123
OmniOS r151046 omnios-r151046-82ebda23c9 April 2023
omnios@ip-172-33-54-144:~$ ls -la
total 47
drwxr-xr-x 3 omnios other 7 Jul 5 20:01 .
dr-xr-xr-x 3 root root 3 Jul 5 19:52 ..
-rw------- 1 omnios other 5 Jul 5 20:01 .bash_history
-rw-r--r-- 1 omnios other 265 Jul 5 19:52 .bashrc
-rw-r--r-- 1 omnios other 371 Jul 5 19:52 .kshrc
-rw-r--r-- 1 omnios other 377 Jul 5 19:52 .profile
drwx------ 2 omnios other 3 Jul 5 19:53 .ssh
omnios@ip-172-33-54-144:~$ sudo su -
OmniOS r151046 omnios-r151046-82ebda23c9 April 2023
root@ip-172-33-54-144:~# pfexec pkg install developer/gcc* system/header
Packages to install: 6
Mediators to change: 1
Services to change: 1
Create boot environment: No
Create backup boot environment: No
DOWNLOAD PKGS FILES XFER (MB) SPEED
Completed 6/6 5529/5529 450.1/450.1 1.8M/s
PHASE ITEMS
Installing new actions 6577/6577
Updating package state database Done
Updating package cache 0/0
Updating image state Done
Creating fast lookup database Done
Reading search index Done
Updating search index 6/6
Updating package cache 1/1
root@ip-172-33-54-144:~# gcc --version
gcc (OmniOS 151046/12.2.0-il-0) 12.2.0
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@ip-172-31-54-147:~# pfexec pkg install \
developer/build/autoconf \
developer/build/automake \
developer/build/gnu-make \
developer/build/make \
developer/lexer/flex \
developer/object-file \
developer/parser/bison
Packages to install: 4
Services to change: 1
Create boot environment: No
Create backup boot environment: No
DOWNLOAD PKGS FILES XFER (MB) SPEED
Completed 4/4 321/321 2.5/2.5 543k/s
PHASE ITEMS
Installing new actions 553/553
Updating package state database Done
Updating package cache 0/0
Updating image state Done
Creating fast lookup database Done
Reading search index Done
Updating search index 4/4
Updating package cache 1/1
root@ip-172-31-54-144:~# pfexec pkg install build-essential
No updates necessary for this image.
root@ip-172-33-54-144:~# bison --version
bison (GNU Bison) 3.8.2
Written by Robert Corbett and Richard Stallman.
Copyright (C) 2021 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
root@ip-172-33-54-144:~#