LoginSignup
0

More than 3 years have passed since last update.

FreeBSD/arm64 を AWS で動かす

Posted at

FreeBSD/arm64 を AWS で動かす

AWS に A1 インスタンスが追加され、arm64 を利用できるようになっています。
公式の snapshot も AMI を作成しているので、AMI を利用して FreeBSD/arm64 環境を作成してみます。

A1 インスタンス

に概要が書いてあります。

A1インスタンスについてのブログもあるので参照するといいでしょう。
- 新機能 – EC2 A1インスタンス – ARMベースのAWS Gravitonプロセッサーを搭載

A1 インスタンスが利用できるリージョン

A1 インスタンスはすべてのリージョンで利用できる状態にはなっていません。

で A1 インスタンスタイプがリストに表示されていない場合、そのリージョンではまだ利用できません。

現時点(2019/08/12)で A1 インスタンスタイプが利用できるのは次のリージョンです。
- 米国東部(バージニア北部)
- 米国東部 (オハイオ)
- 米国西部 (オレゴン)
- 欧州 (アイルランド)

EC2 インスタンスの作成

arm64 であっても、EC2 インスタンスの作成方法は変わりません。
注意が必要なのはリージョンの選択で、A1 インスタンスタイプが利用できるリージョンを選択する必要があります。

AMI (Amazon Machine Image) の選択

FreeBSD が公式に snapshot を作成していますが、AMI (Amazon Machine Image) も作成しています。
- New FreeBSD snapshots available: stable/12 (20190808 r350699)

AMI の ID で検索するか、コミュニティAMI を選択して "FreeBSD arm64" で検索し、インスタンス作成に使用する AMI を選びます。

aws_select_ami.png

インスタンスタイプの選択

作成するインスタンスのタイプを選択します。
vCPU、メモリの構成とその値段(Amazon EC2 料金表)で選択します。

aws_select_instance_type.png

設定

ストレージのサイズを変更したり、セキュリティの設定を行ったりします。

インスタンスの起動

作成したインスタンスを起動します。

作成例

  • 米国西部 (オレゴン)
  • 4 vCPU
  • 8G memory
  • 16G ssd

で作成してみました。

aws_instance_list.png

ログインしてみると、ちゃんと FreeBSD/arm64 が動作しています。

[2]<shigeru@edgeworth-kuiper-belt>: ssh ec2-user@ec2-54-212-175-30.us-west-2.compute.amazonaws.com
Last login: Mon Aug 12 09:15:30 2019 from w142149.ppp.asahi-net.or.jp
FreeBSD 12.0-STABLE r350699 GENERIC

Welcome to FreeBSD!

Release Notes, Errata: https://www.FreeBSD.org/releases/
Security Advisories:   https://www.FreeBSD.org/security/
FreeBSD Handbook:      https://www.FreeBSD.org/handbook/
FreeBSD FAQ:           https://www.FreeBSD.org/faq/
Questions List: https://lists.FreeBSD.org/mailman/listinfo/freebsd-questions/
FreeBSD Forums:        https://forums.FreeBSD.org/

Documents installed with the system are in the /usr/local/share/doc/freebsd/
directory, or can be installed later with:  pkg install en-freebsd-doc
For other languages, replace "en" with a language code like de or fr.

Show the version of FreeBSD installed:  freebsd-version ; uname -a
Please include that output and any error messages when posting questions.
Introduction to manual pages:  man man
FreeBSD directory layout:      man hier

Edit /etc/motd to change this login announcement.
In order to support national characters for European languages in tools like
less without creating other nationalisation aspects, set the environment
variable LC_ALL to 'en_US.UTF-8'.
$ uname -a
FreeBSD freebsd 12.0-STABLE FreeBSD 12.0-STABLE r350699 GENERIC  arm64
$ sysctl hw.ncpu
hw.ncpu: 4
$

dmesg

dmesg はこんな感じです。

$ dmesg
---<<BOOT>>---
Copyright (c) 1992-2019 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 12.0-STABLE r350699 GENERIC arm64
FreeBSD clang version 8.0.1 (tags/RELEASE_801/final 366581) (based on LLVM 8.0.1)
VT: init without driver.
Starting CPU 1 (1)
Starting CPU 2 (2)
Starting CPU 3 (3)
FreeBSD/SMP: Multiprocessor System Detected: 4 CPUs
arc4random: no preloaded entropy cache
random: entropy device external interface
MAP 7c2e0000 mode 2 pages 272
MAP 7f6d0000 mode 2 pages 144
MAP 7f780000 mode 2 pages 272
MAP 9010000 mode 0 pages 1
kbd0 at kbdmux0
efirtc0: <EFI Realtime Clock>
efirtc0: registered as a time-of-day clock, resolution 1.000000s
acpi0: <AMAZON AMZNFACP>
acpi0: Power Button (fixed)
acpi0: Sleep Button (fixed)
psci0: <ARM Power State Co-ordination Interface Driver> on acpi0
gic0: <ARM Generic Interrupt Controller v3.0> iomem 0x10000000-0x1001ffff,0x10200000-0x1ffeffff on acpi0
its0: <ARM GIC Interrupt Translation Service> on gic0
generic_timer0: <ARM Generic Timer> irq 37,38,39 on acpi0
Timecounter "ARM MPCore Timecounter" frequency 83333333 Hz quality 1000
Event timer "ARM MPCore Eventtimer" frequency 83333333 Hz quality 1000
pcib0: <Generic PCI host controller> iomem 0x20000000-0x2fffffff on acpi0
pcib0: allocating 80000000-ffffffff range
pcib0: allocating 0-ffff range
pcib0: allocating 8000000000-ffffffffff range
pci0: <PCI bus> on pcib0
pci0: <simple comms, UART> at device 1.0 (no driver attached)
pci0: <old, non-VGA display device> at device 2.0 (no driver attached)
pci0: <old, non-VGA display device> at device 3.0 (no driver attached)
nvme0: <Generic NVMe Device> mem 0x80114000-0x80117fff irq 35 at device 4.0 on pci0
ena0: <ENA adapter> mem 0x80110000-0x80113fff,0x80000000-0x800fffff,0x80100000-0x8010ffff irq 36 at device 5.0 on pci0
ena0: Elastic Network Adapter (ENA)ena v0.8.4
ena0: initalize 1 io queues
ena0: Ethernet address: 0a:a4:17:ff:13:2a
pci0: <old, non-VGA display device> at device 6.0 (no driver attached)
pci0: <old, non-VGA display device> at device 7.0 (no driver attached)
pci0: <old, non-VGA display device> at device 8.0 (no driver attached)
pci0: <old, non-VGA display device> at device 9.0 (no driver attached)
pci0: <old, non-VGA display device> at device 10.0 (no driver attached)
pci0: <old, non-VGA display device> at device 11.0 (no driver attached)
pci0: <old, non-VGA display device> at device 12.0 (no driver attached)
pci0: <old, non-VGA display device> at device 13.0 (no driver attached)
pci0: <old, non-VGA display device> at device 14.0 (no driver attached)
pci0: <old, non-VGA display device> at device 15.0 (no driver attached)
pci0: <old, non-VGA display device> at device 16.0 (no driver attached)
pci0: <old, non-VGA display device> at device 17.0 (no driver attached)
pci0: <old, non-VGA display device> at device 18.0 (no driver attached)
pci0: <old, non-VGA display device> at device 19.0 (no driver attached)
pci0: <old, non-VGA display device> at device 20.0 (no driver attached)
pci0: <old, non-VGA display device> at device 21.0 (no driver attached)
pci0: <old, non-VGA display device> at device 22.0 (no driver attached)
pci0: <old, non-VGA display device> at device 23.0 (no driver attached)
pci0: <old, non-VGA display device> at device 24.0 (no driver attached)
pci0: <old, non-VGA display device> at device 25.0 (no driver attached)
pci0: <old, non-VGA display device> at device 26.0 (no driver attached)
pci0: <old, non-VGA display device> at device 27.0 (no driver attached)
pci0: <old, non-VGA display device> at device 28.0 (no driver attached)
pci0: <old, non-VGA display device> at device 29.0 (no driver attached)
pci0: <old, non-VGA display device> at device 30.0 (no driver attached)
pci0: <old, non-VGA display device> at device 31.0 (no driver attached)
acpi_button0: <Power Button> on acpi0
acpi0: Could not update all GPEs: AE_NOT_CONFIGURED
cryptosoft0: <software crypto>
Timecounters tick every 1.000 msec
ena0: link is UP
ena0: link state changed to UP
nvme0: temperature threshold not supported
Release APs...done
arc4random: no preloaded entropy cache
CPU  0: ARM Cortex-A72 r0p3 affinity:  0
nda0 at nvme0 bus 0 scbus0 target 0 lun 1
Trying to mount root from ufs:/dev/ufs/rootfs [rw]...
 Instruction Set Attributes 0 = <AES+PMULL,SHA1,SHA2,CRC32>
nda0:  Instruction Set Attributes 1 = <>
<Amazon Elastic Block Store 1.0 vol032af420e373bcc9a>
         Processor Features 0 = <GIC,AdvSIMD,Float,EL3 32,EL2 32,EL1 32,EL0 32>
nda0: nvme version 1.0 x0 (max x0) lanes PCIe Gen0 (max Gen0) link         Processor Features 1 = <0>

      Memory Model Features 0 = <4k Granule,64k Granule,MixedEndian,S/NS Mem,16bit ASID,16TB PA>
nda0: 16384MB (33554432 512 byte sectors)
      Memory Model Features 1 = <>
      Memory Model Features 2 = <32b CCIDX,48b VA>
             Debug Features 0 = <2 CTX Breakpoints,4 Watchpoints,6 Breakpoints,PMUv3,Debug v8>
             Debug Features 1 = <0>
         Auxiliary Features 0 = <0>
         Auxiliary Features 1 = <0>
CPU  1: ARM Cortex-A72 r0p3 affinity:  1
CPU  2: ARM Cortex-A72 r0p3 affinity:  2
CPU  3: ARM Cortex-A72 r0p3 affinity:  3
arc4random: no preloaded entropy cache
arc4random: no preloaded entropy cache
random: unblocking device.
lo0: link state changed to UP
ena0: device is going UP
ena0: device is going DOWN
ena0: device is going UP
Security policy loaded: MAC/ntpd (mac_ntpd)
$

pkg

pkg は問題なく利用できます。

root@freebsd:~ # pkg instal -y screen sudo git
Updating FreeBSD repository catalogue...
FreeBSD repository is up to date.
All repositories are up to date.
The following 22 package(s) will be affected (of 0 checked):

New packages to be INSTALLED:
        screen: 4.6.2_1
        sudo: 1.8.27_1
        git: 2.22.0
        p5-CGI: 4.44
        p5-HTML-Parser: 3.72
        p5-HTML-Tagset: 3.20_1
        perl5: 5.28.2
        expat: 2.2.6_1
        p5-IO-Socket-SSL: 2.066
        p5-Mozilla-CA: 20180117
        p5-Net-SSLeay: 1.85
        p5-IO-Socket-INET6: 2.72_1
        p5-Socket6: 0.29
        p5-Authen-SASL: 2.16_1
        p5-GSSAPI: 0.28_1
        p5-Digest-HMAC: 1.03_1
        p5-Error: 0.17027
        curl: 7.65.1
        libnghttp2: 1.39.1
        ca_root_nss: 3.45
        pcre: 8.43_1
        cvsps: 2.1_2

Number of packages to be installed: 22

The process will require 119 MiB more space.
23 MiB to be downloaded.
[1/22] Fetching screen-4.6.2_1.txz: 100%  456 KiB 466.6kB/s    00:01
[2/22] Fetching sudo-1.8.27_1.txz: 100%  655 KiB 335.4kB/s    00:02
[3/22] Fetching git-2.22.0.txz: 100%    5 MiB 596.7kB/s    00:08
[4/22] Fetching p5-CGI-4.44.txz: 100%  154 KiB 158.2kB/s    00:01
[5/22] Fetching p5-HTML-Parser-3.72.txz: 100%   77 KiB  78.8kB/s    00:01
[6/22] Fetching p5-HTML-Tagset-3.20_1.txz: 100%   12 KiB  12.0kB/s    00:01
[7/22] Fetching perl5-5.28.2.txz: 100%   14 MiB 314.8kB/s    00:46
[8/22] Fetching expat-2.2.6_1.txz: 100%   97 KiB  99.0kB/s    00:01
[9/22] Fetching p5-IO-Socket-SSL-2.066.txz: 100%  167 KiB 170.5kB/s    00:01
[10/22] Fetching p5-Mozilla-CA-20180117.txz: 100%  132 KiB 135.3kB/s    00:01   
[11/22] Fetching p5-Net-SSLeay-1.85.txz: 100%  233 KiB 238.7kB/s    00:01
[12/22] Fetching p5-IO-Socket-INET6-2.72_1.txz: 100%   13 KiB  13.1kB/s    00:01
[13/22] Fetching p5-Socket6-0.29.txz: 100%   15 KiB  15.7kB/s    00:01
[14/22] Fetching p5-Authen-SASL-2.16_1.txz: 100%   40 KiB  41.5kB/s    00:01
[15/22] Fetching p5-GSSAPI-0.28_1.txz: 100%   39 KiB  39.5kB/s    00:01
[16/22] Fetching p5-Digest-HMAC-1.03_1.txz: 100%   10 KiB  10.1kB/s    00:01
[17/22] Fetching p5-Error-0.17027.txz: 100%   27 KiB  27.4kB/s    00:01
[18/22] Fetching curl-7.65.1.txz: 100%    1 MiB 103.0kB/s    00:12
[19/22] Fetching libnghttp2-1.39.1.txz: 100%   97 KiB  99.6kB/s    00:01
[20/22] Fetching ca_root_nss-3.45.txz: 100%  295 KiB 301.7kB/s    00:01
[21/22] Fetching pcre-8.43_1.txz: 100%    1 MiB 513.0kB/s    00:02
[22/22] Fetching cvsps-2.1_2.txz: 100%   40 KiB  40.5kB/s    00:01
Checking integrity... done (0 conflicting)
[1/22] Installing perl5-5.28.2...
[1/22] Extracting perl5-5.28.2: 100%
[2/22] Installing p5-HTML-Tagset-3.20_1...
[2/22] Extracting p5-HTML-Tagset-3.20_1: 100%
[3/22] Installing p5-Socket6-0.29...
[3/22] Extracting p5-Socket6-0.29: 100%
[4/22] Installing p5-HTML-Parser-3.72...
[4/22] Extracting p5-HTML-Parser-3.72: 100%
[5/22] Installing p5-Mozilla-CA-20180117...
[5/22] Extracting p5-Mozilla-CA-20180117: 100%
[6/22] Installing p5-Net-SSLeay-1.85...
[6/22] Extracting p5-Net-SSLeay-1.85: 100%
[7/22] Installing p5-IO-Socket-INET6-2.72_1...
[7/22] Extracting p5-IO-Socket-INET6-2.72_1: 100%
[8/22] Installing p5-GSSAPI-0.28_1...
[8/22] Extracting p5-GSSAPI-0.28_1: 100%
[9/22] Installing p5-Digest-HMAC-1.03_1...
[9/22] Extracting p5-Digest-HMAC-1.03_1: 100%
[10/22] Installing libnghttp2-1.39.1...
[10/22] Extracting libnghttp2-1.39.1: 100%
[11/22] Installing ca_root_nss-3.45...
[11/22] Extracting ca_root_nss-3.45: 100%
[12/22] Installing p5-CGI-4.44...
[12/22] Extracting p5-CGI-4.44: 100%
[13/22] Installing expat-2.2.6_1...
[13/22] Extracting expat-2.2.6_1: 100%
[14/22] Installing p5-IO-Socket-SSL-2.066...
[14/22] Extracting p5-IO-Socket-SSL-2.066: 100%
[15/22] Installing p5-Authen-SASL-2.16_1...
[15/22] Extracting p5-Authen-SASL-2.16_1: 100%
[16/22] Installing p5-Error-0.17027...
[16/22] Extracting p5-Error-0.17027: 100%
[17/22] Installing curl-7.65.1...
[17/22] Extracting curl-7.65.1: 100%
[18/22] Installing pcre-8.43_1...
[18/22] Extracting pcre-8.43_1: 100%
[19/22] Installing cvsps-2.1_2...
[19/22] Extracting cvsps-2.1_2: 100%
[20/22] Installing screen-4.6.2_1...
[20/22] Extracting screen-4.6.2_1: 100%
[21/22] Installing sudo-1.8.27_1...
[21/22] Extracting sudo-1.8.27_1: 100%
[22/22] Installing git-2.22.0...
===> Creating groups.
Creating group 'git_daemon' with gid '964'.
===> Creating users
Creating user 'git_daemon' with uid '964'.
[22/22] Extracting git-2.22.0: 100%
Message from perl5-5.28.2:

The /usr/bin/perl symlink has been removed starting with Perl 5.20.
For shebangs, you should either use:

#!/usr/local/bin/perl

or

#!/usr/bin/env perl

The first one will only work if you have a /usr/local/bin/perl,
the second will work as long as perl is in PATH.
Message from ca_root_nss-3.45:

********************************* WARNING *********************************

FreeBSD does not, and can not warrant that the certification authorities
whose certificates are included in this package have in any way been
audited for trustworthiness or RFC 3647 compliance.

Assessment and verification of trust is the complete responsibility of the
system administrator.

*********************************** NOTE **********************************

This package installs symlinks to support root certificates discovery by
default for software that uses OpenSSL.

This enables SSL Certificate Verification by client software without manual
intervention.

If you prefer to do this manually, replace the following symlinks with
either an empty file or your site-local certificate bundle.

  * /etc/ssl/cert.pem
  * /usr/local/etc/ssl/cert.pem
  * /usr/local/openssl/cert.pem

***************************************************************************
Message from cvsps-2.1_2:

===>   NOTICE:

The cvsps port currently does not have a maintainer. As a result, it is
more likely to have unresolved issues, not be up-to-date, or even be removed in
the future. To volunteer to maintain this port, please create an issue at:

https://bugs.freebsd.org/bugzilla

More information about port maintainership is available at:

https://www.freebsd.org/doc/en/articles/contributing/ports-contributing.html#maintain-port
Message from screen-4.6.2_1:

=============================================================

As of GNU Screen 4.4.0:

Note that there was fix to screen message structure field
responsible for $TERM handling, making it impossible
to attach to older versions.

=============================================================
Message from git-2.22.0:

------------------------------------------------------------------------
*************************** GITWEB *************************************
If you installed the GITWEB option please follow these instructions:

In the directory /usr/local/share/examples/git/gitweb you can find all files to
make gitweb work as a public repository on the web.

All you have to do to make gitweb work is:
1) Please be sure you're able to execute CGI scripts in
   /usr/local/share/examples/git/gitweb.
2) Set the GITWEB_CONFIG variable in your webserver's config to
   /usr/local/etc/git/gitweb.conf. This variable is passed to gitweb.cgi.
3) Restart server.
*************************** GITWEB *************************************

*************************** CONTRIB ************************************
If you installed the CONTRIB option please note that the scripts are
installed in /usr/local/share/git-core/contrib. Some of them require
other ports to be installed (perl, python, etc), which you may need to
install manually.
*************************** CONTRIB ************************************
------------------------------------------------------------------------
root@freebsd:~ #
root@freebsd:~ # pkg info
awscli-1.16.185                Universal Command Line Interface for Amazon Web Services
ca_root_nss-3.45               Root certificate bundle from the Mozilla Project
curl-7.65.1                    Command line tool and library for transferring data with URLs
cvsps-2.1_2                    Create patchset information from CVS
dual-dhclient-1.0_1            Spawns dhclients for a dual-stack network
ec2-scripts-1.10               Startup scripts for FreeBSD/EC2 environment
expat-2.2.6_1                  XML 1.0 parser written in C
firstboot-freebsd-update-1.2   Update the system using freebsd-update when it first boots
firstboot-pkgs-1.5             Install packages when the system first boots
gettext-runtime-0.20.1         GNU gettext runtime libraries and programs
git-2.22.0                     Distributed source code management tool
indexinfo-0.3.1                Utility to regenerate the GNU info page index
isc-dhcp44-client-4.4.1        The ISC Dynamic Host Configuration Protocol client
libffi-3.2.1_3                 Foreign Function Interface
libnghttp2-1.39.1              HTTP/2.0 C Library
p5-Authen-SASL-2.16_1          Perl5 module for SASL authentication
p5-CGI-4.44                    Handle Common Gateway Interface requests and responses
p5-Digest-HMAC-1.03_1          Perl5 interface to HMAC Message-Digest Algorithms
p5-Error-0.17027               Error/exception handling in object-oriented programming style
p5-GSSAPI-0.28_1               Perl extension providing access to the GSSAPIv2 library
p5-HTML-Parser-3.72            Perl5 module for parsing HTML documents
p5-HTML-Tagset-3.20_1          Some useful data table in parsing HTML
p5-IO-Socket-INET6-2.72_1      Perl module with object interface to AF_INET6 domain sockets
p5-IO-Socket-SSL-2.066         Perl5 interface to SSL sockets
p5-Mozilla-CA-20180117         Perl extension for Mozilla CA cert bundle in PEM format
p5-Net-SSLeay-1.85             Perl5 interface to SSL
p5-Socket6-0.29                IPv6 related part of the C socket.h defines and structure manipulators
pcre-8.43_1                    Perl Compatible Regular Expressions library
perl5-5.28.2                   Practical Extraction and Report Language
pkg-1.11.1                     Package manager
py36-asn1crypto-0.24.0         ASN.1 library with a focus on performance and a pythonic API
py36-botocore-1.12.175         Low-level, core functionality of boto 3
py36-cffi-1.12.3               Foreign Function Interface for Python calling C code
py36-colorama-0.4.1            Cross-platform API to print colored terminal text from Python apps
py36-cryptography-2.6.1        Cryptographic recipes and primitives for Python developers
py36-dateutil-2.8.0            Extensions to the standard Python datetime module
py36-docutils-0.14_4           Python Documentation Utilities
py36-idna-2.8                  Internationalized Domain Names in Applications (IDNA)
py36-jmespath-0.9.4_1          JSON Matching Expressions
py36-openssl-18.0.0            Python interface to the OpenSSL library
py36-pyasn1-0.4.5              ASN.1 toolkit for Python
py36-pycparser-2.19            C parser in Python
py36-pysocks-1.7.0             Python SOCKS module
py36-rsa-3.4.2_1               Pure-Python RSA implementation
py36-s3transfer-0.2.1          Amazon S3 Transfer Manager for Python
py36-setuptools-41.0.1         Python packages installer
py36-six-1.12.0                Python 2 and 3 compatibility utilities
py36-urllib3-1.22,1            HTTP library with thread-safe connection pooling, file post, and more
py36-yaml-5.1                  Python YAML parser
python36-3.6.9                 Interpreted object-oriented programming language
readline-8.0.0                 Library for editing command lines as they are typed
screen-4.6.2_1                 Multi-screen window manager
sudo-1.8.27_1                  Allow others to run commands as root
root@freebsd:~ #

freebsd-update

arm64 は freebsd-update がサポートされていないので、AWS 環境であっても利用はできません。

まとめ

利用できるリージョンがまだ限られていますが、amd64 と同じ感覚で arm64 の環境を作成できます。
Raspberry Pi 3 や Pine64 など、arm64 環境を手に入れることはできますが、それらはメモリが 2G ぐらいまでのものしかありません。
AWS だと 16 core, 32G まで選ぶことができ、1 core, 2G の環境でも手元の Pine64 よりもコンパイル速度は速いです。
料金もオンデマンドなため、一時的に arm64 環境を利用するには便利でしょう。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0