File:  [NetBSD Developer Wiki] / wikisrc / amazon_ec2 / bsdec2_image_upload.mdwn
Revision 1.2: download - view: text, annotated - select for diffs
Fri Jul 16 09:36:07 2021 UTC (12 months, 3 weeks ago) by wiki
Branches: MAIN
CVS tags: HEAD

# Creating a NetBSD AMI with bsdec2-image-upload

## About bsdec2-image-upload

The [bsdec2-image-upload]( tool automates creation of AMIs based on raw disk images. This tool is available in pkgsrc as [sysutils/bsdec2-image-upload](

## Getting a disk image

The following images are configured to automatically detect an EC2 environment and resize the root disk at boot. Creating a custom image is not covered in this document.

### x86

* NetBSD -current: <>
* NetBSD 9.x: *not supported*

### Arm

* NetBSD -current: <>
* NetBSD 9.x: <>

## Prerequisites

### Install bsdec2-image-upload

Install sysutils/bsdec2-image-upload from pkgsrc.

### Setup AWS credentials

In the [IAM Management Console](, create an access key. Enter these into in a file named *keyfile.txt*:

[[!template  id=filecontent name="keyfile.txt" text="""

### Create S3 bucket for image upload

An S3 bucket is required for temporary storage during the upload and conversion process. This can be created on the [S3 Management Console](

## Creating an AMI

[[!template  id=filecontent name="x86" text="""
$ gunzip NetBSD-9.99.72-amd64-live.img.gz
$ AWS_REGION=us-east-1
$ S3BUCKET=my-bucket-name
$ bsdec2-image-upload --sriov --ena NetBSD-9.99.72-amd64-live.img "NetBSD 9.99.72 x86 2020-09-10" "NetBSD/amd64 -current (9.99.72) built on Sep 10 2020" ${AWS_REGION} ${S3BUCKET} keyfile.txt

[[!template  id=filecontent name="Arm" text="""
$ gunzip arm64.img.gz
$ AWS_REGION=us-east-1
$ S3BUCKET=my-bucket-name
$ bsdec2-image-upload --sriov --ena --arm64 arm64.img "NetBSD 9.99.72 Arm 2020-09-10" "NetBSD/evbarm -current (9.99.72) built on Sep 10 2020" ${AWS_REGION} ${S3BUCKET} keyfile.txt

### Cleanup

Once the images are uploaded, some artifacts will be left in the S3 bucket. These can be safely deleted.

## Starting an instance

On the [EC2 Management Console](, select the region matching the AMI you just uploaded. Then under the AMIs section on the left, select your newly created AMI and click the Launch button to create a new instance.

The credentials specified during creation of the instance can be used to login with ssh as the root user (NetBSD 9) or ec2-user (NetBSD -current) after NetBSD has booted:

[[!template  id=filecontent name="remote login (NetBSD 9.x)" text="""
$ ssh -i netbsd.pem root@my-instance-ip

[[!template  id=filecontent name="remote login (NetBSD -current)" text="""
$ ssh -i netbsd.pem ec2-user@my-instance-ip

CVSweb for NetBSD wikisrc <> software: FreeBSD-CVSweb