🦍

Ubuntu Server OS を新規にインストールする

2023/04/28に公開

Linuxディストリビュージョンである Ubuntu Server の構築手順を説明します。

🔰 はじめに

作業環境を用意する。

  • PC端末
  • USBフラッシュドライブ(Ubuntu Server 22.04.2 LTS)

📦 事前準備

1. PC端末の準備

NASを利用する際は以下の記事を参考にする。
https://zenn.dev/mesgory/articles/76699a1ba31775

2. インストールメディアの準備

以下の記事を参考に作成したブートメディアをUSBポートに挿しておく。
https://zenn.dev/mesgory/articles/ea0760681a41b6

🎭 作業手順

1. ブートローダーの起動

電源を入れるとブートローダーが起動するので Try or Install Ubuntu Server を選択してEnterキーを押下する。

                           GUN GRUB  version 2.06
  ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
+ ┃ *Try or Install Ubuntu Server                                       ┃
  ┃  Ubuntu Server with the HWE kernel                                  ┃
  ┃  Boot from next volume                                              ┃
  ┃  UEFI Firmware Settings                                             ┃
  ┃                                                                     ┃
  ┃                                                                     ┃
  ┃                                                                     ┃
  ┃                                                                     ┃
  ┃                                                                     ┃
  ┃                                                                     ┃
  ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

        Use the ▲ and ▼ keys to select which entry is highlighted.
        Press enter to boot the selected OS, `e' to edit the commands
        before booting or `c' for a command-line.
     The highlighted entry will be executed automatically in 28s.

2. インストール用の言語

English を選択してEnterキーを押下する。

  Willkommen! Bienvenue! Welcome! Добро пожаловать! Welkom!      [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  Use UP, DOWN and ENTER keys to select your language.

                [ Asturianu                                 ▸ ]▴
                [ Bahasa Indonesia                          ▸ ]█
                [ Català                                    ▸ ]
                [ Deutsch                                   ▸ ]
+               [ English                                   ▸ ]
                [ English (UK)                              ▸ ]
                [ Español                                   ▸ ]
                [ Français                                  ▸ ]
                [ Galego                                    ▸ ]
                [ Hrvatski                                  ▸ ]
                [ Latviski                                  ▸ ]
                [ Lietuviškai                               ▸ ]
                [ Magyar                                    ▸ ]
                [ Nederlands                                ▸ ]
                [ Norsk bokmål                              ▸ ]
                [ Polski                                    ▸ ]▾

3. キーボード レイアウト

環境に合わせて設定したら [Done] に移動して次へ進む。

  Keyboard configuration                                         [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  Please select your keyboard layout below, or select "Identify keyboard" 
  to detect your layout automatically.

+                Layout:  [ Japanese                         ▾ ]

+               Variant:  [ Japanese                         ▾ ]

                                                       [ Identify keyboard ]

-                                [ Done      ]
                                 [ Back      ]

4. インストールの種類

最小構成で運用する場合は Ubuntu Server (minimized) を選択後 [Done] に移動して次へ進む。

  Choose type of install                                         [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  Choose the base for the installation.

  ( )  Ubuntu Server

       The default install contains a curated set of packages that provide
       a comfortable experience for operating your server.

+ (X)  Ubuntu Server (minimized)

       This version has been customized to have a small runtime footprint
       in environments where humans are not expected to log in.

  Additional options

  [ ]  Search for third-party drivers

       This software is subject to license terms included with its
       documentation. Some is proprietary. Third-party drivers should not
       be installed on systems that will be used for FIPS or the
       real-time kernel.

-                                [ Done      ]
                                 [ Back      ]

5. ネットワーク設定

固定IPに変更する場合は対象のNIC(ここでは enp1s0) で Edit IPv4 を選択する。

  Network connections                                            [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  Configure at least one interface this server can use to talk to other
  machines, and which preferably provides sufficient access for updates.

    NAME    TYPE  NOTES               ┌───────────────────┐
+ [ enp1s0  eth   -                ▸ ]│◂(close)           │
    DHCPv4  192.168.0.18/24           │  Info             │
    6c:bf:b5:02:88:e1 / Intel Corporat│  Edit IPv4        │ller I225-V
                                      │  Edit IPv6        │
  [ enp2s0  eth   not connected    ▸ ]│  Add a VLAN tag  ▸│
    disabled                          └───────────────────┘
    6c:bf:b5:02:88:e2 / Intel Corporation / Ethernet Controller I225-V

  [ Create bond ▸ ]

-                                [ Done      ]
                                 [ Back      ]

モーダルウィンドウが表示されたら IPv4 MethodManual を選択する。

      ┌───────────────── Edit enp1s0 IPv4 configuration ─────────────────┐
      │                ┌───────────────────┐                             │
+     │ IPv4 Method:   │ Automatic (DHCP) ◂│                             │
      │                │ Manual            │                             │
      │                │ Disabled          │                             │
      │                └───────────────────┘  ]                          │
      │                            [ Cancel   ]                          │
      └──────────────────────────────────────────────────────────────────┘

環境に合わせて設定したら [Save] に移動してメイン画面まで戻る。

      ┌───────────────── Edit enp1s0 IPv4 configuration ─────────────────┐
      │                                                                  │
      │ IPv4 Method:   [ Manual           ▾]                             │
      │                                                                  │
+     │         Subnet: 192.168.1.0/24                                   │
      │                                                                  │
+     │      Addresses: 192.168.1.101                                    │
      │                                                                  │
+     │        Gateway: 192.168.1.1                                      │
      │                                                                  │
+     │   Name servers: 192.168.1.1                                      │
      │                 IP addresses, comma separated                    │
      │ Search domains:                                                  │
      │                 Domains, comma separated                         │
      │                                                                  │
-     │                            [ Save     ]                          │
      │                            [ Cancel   ]                          │
      └──────────────────────────────────────────────────────────────────┘

6. プロキシサーバーの構成

プロキシを使用しない場合は空欄のまま [Done] に移動して次へ進む。

  Configure proxy                                                [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  If this system requires a proxy to connect to the internet, enter its
  details here.

+ Proxy address:

                  If you need to use a HTTP proxy to access the outside
                  world, enter the proxy information here. Otherwise, leave
                  this blank.

                  The proxy information should be given in the standard
                  form of "http://[[user][:pass]@]host[:port]/".

-                                [ Done      ]
                                 [ Back      ]

7. ミラーサーバーの設定

ミラーサイトの場所を確認したら [Done] に移動して次へ進む。

  Configure Ubuntu archive mirror                                [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  If you use an alternative mirror for Ubuntu, enter its details here.

+ Mirror address:  http://jp.archive.ubuntu.com/ubuntu

                   You may provide an archive mirror that will be used
                   instead of the default.

-                                [ Done      ]
                                 [ Back      ]

8. ストレージの設定

Use An Entire Disk を選択するとディスク全体をext4のルートファイルシステムとして構成する。また、論理ボリュームを構成しない場合は Set up this disk as an LVM group のチェックを外し [Done] に移動して次へ進む。

  Guided storage configuration                                   [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  Configure a guided storage layout, or create a custom one:

+ (X)  Use an entire disk

       [ QMENU NVMe Ctrl_1234 local disk 10.000G ▾ ]

+      [ ]  Set up this disk as an LVM group

            [ ]  Encrypt the LVM group with LUKS

                         Passphrase:

                 Confirm passphrase:

  ( )  Custom storage layout

-                                [ Done ]
                                 [ Back ]

パーティションの構成を確認して問題がなければ [Done] に移動して次へ進む。

  Storage configuration                                          [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  FILE SYSTEM SUMMARY                                                   
                                                                        
    MOUNT POINT     SIZE    TYPE      DEVICE TYPE                       
  [ /               8.997G  new ext4  new LVM logical volume      ▸ ]   
  [ /boot/efi       1.000G  new fat32 new partition of local disk ▸ ]   
                                                                        
                                                                        
+ AVAILABLE DEVICES                                                     
                                                                        
   DEVICE                            TYPE                 SIZE
  [ QMENU NVMe Ctrl_5678             local disk          10.000G  ▸ ]
    unused

  [ Create software RAID (md) ▸ ]
  [ Create volume group (LVM) ▸ ]

+ USED DEVICES
  
    DEVICE                           TYPE                     SIZE
  [ QMENU NVMe Ctrl_1234             local disk              10.000G  ▸ ]
    partition 1  new, primary ESP, to be mounted as fat32,    1.000G  ▸ 
                 mounted at /boot/efi
    partition 2  new, to be formatted as ext4,                8.997G  ▸ 
                 mounted at /

-                                [ Done  ]
                                 [ Reset ]
                                 [ Back  ]

モーダルウィンドウで確認を促す表示されるので [Continue] に移動して次へ進む。

   ┌────────────────────── Confirm destructive action ──────────────────────┐
   │                                                                        │
   │  Selecting Continue below will begin the installation process and      │
   │  result in the loss of data on the disks selected to be formatted.     │
   │                                                                        │
   │  You will not be able to return to this or a previous screen once the  │
   │  installation has started.                                             │
   │                                                                        │
   │  Are you sure you want to continue?                                    │
   │                                                                        │
   │                             [ No       ]                               │
-  │                             [ Continue ]                               │
   │                                                                        │
   └────────────────────────────────────────────────────────────────────────┘

8. プロファイルの設定

環境に合わせて設定したら [Done] に移動して次へ進む。

  Profile setup                                                  [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  Enter the username and password you will use to log in to the system. 
  You can configure SSH access on the next screen but a password is still
  needed for sudo.

+             Your name:  

+    Your server's name:  ubuntu
                          The name it uses when it talks to other
                          computers.

+       Pick a username:  sysadmin

+     Choose a password:  ********

+ Confirm your password:  ********

-                                [ Done ]

9. Ubuntu Pro へのアップグレード

アップグレードを行わない場合は Skip for now にチェックして [Done] に移動して次へ進む。

    Upgrade to Ubuntu Pro                                          [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  Upgrade this machine to Ubuntu Pro for security updates on a much wider
  range of packages, until 2032. Assists with FedRAMP, FIPS, STIG, HIPAA
  and other compliance or hardening requirements.

  [ About Ubuntu Pro ▸ ]

  ( )  Enabled Ubuntu Pro

  (X)  Skip for now

       You can always enable Ubuntu Pro later via the 'pro attach' command.

-                                [ Continue  ]
                                 [ Back      ]

10.SSHのセットアップ

SSHを使用するため Install OpenSSH server にチェックを入れ [Done] に移動して次へ進む。

  SSH Setup                                                      [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  You can choose to install the OpenSSH server package to enable secure 
  remote access to your server.

+                  [X]  Install OpenSSH server

  Import SSH identity:  [ No             ▾ ]
                        You can import your SSH keys from GitHub or
                        Launchpad.

      Import Username:

                   [X]  Allow password authentication over SSH

-                                [ Done ]
                                 [ Back ]

11. 追加パッケージの選択

必要なサービスを個別にインストールするため、ここでは何も選択せず [Done] に移動して次へ進む。

  Featured Server Snaps                                          [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  These are popular snaps in server environments. Select or deselect with
  SPACE, press ENTER to see more details of the package, publisher and
  versions available.

  [ ] microk8s            Kubernetes for workstations and appliances   ▸▴
  [ ] nextcloud           Nextcloud Server - A safe home for all your  ▸█
  [ ] wekan               The open-source kanban                       ▸█
  [ ] kata-containers     Build lightweight VMs that seamlessly plug i ▸█
  [ ] docker              Docker container runtime                     ▸█
  [ ] canonical-livepatch Canonical Livepatch Client                   ▸█
  [ ] rocketchat-server   Rocket.Chat server                           ▸█
  [ ] mosquitto           Eclipse Mosquitto MQTT broker                ▸
  [ ] etcd                Resilient key-value store by CoreOS          ▸
  [ ] powershell          PowerShell for every system!                 ▸
  [ ] stress-ng           tool to load and stress a computer           ▸
  [ ] sabnzbd             SABnzbd                                      ▸
  [ ] wormhole            get things from one computer to another, saf ▸▾

-                                [ Done ]
                                 [ Back ]

12. システムのインストール

インストールが完了するまでしばらく待つ。

  Installing system                                              [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  ┌─────────────────────────────────────────────────────────────────────┐
  │subiquity/Early/apply_autoinstall_config                            ▴│
  │subiquity/Reporting/apply_autoinstall_config                         │
  │subiquity/Error/apply_autoinstall_config                             │
  │subiquity/Userdata/apply_autoinstall_config                          │
  │subiquity/Package/apply_autoinsta11_config                           │
  │subiquity/Debconf/apply_autoinstall_config                           │
  │subiquity/Kernel/apply_autoinstall_config                            │
  │subiquity/Zdev/apply_autoinstall_config                              │
  │subiquity/Ad/apply_autoinstall_config                                │
  │subiquity/Late/apply_autoinstall_config                              │
  │configuring apt                                                      │
  │  curt in command in-target                                          │
  │installing system                                                    │
  │  executing curtin install initial step                              │
  │  executing curtin install partitioning step                        █│
  │    curtin command install configuring storage                      ▾│
  └─────────────────────────────────────────────────────────────────────┘

                          [ View full log            ]
                          [ Cancel update and reboot ]

USBポートからブートメディアを取り外した後 Reboot Now に移動してEnterキーを押下する。

  Install complete!                                              [ Help ]
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  ┌─────────────────────────────────────────────────────────────────────┐
  │            updating packages on target system                      ▴│
  │            configuring pollinate user-agent on target               │
  │            updating initramfs configuration                         │
  │            configuring target system bootloader                     │
  │            installing grub to target devices                        │
  │final system configuration                                           │
  │  configuring cloud-init                                             │
  │  calculating extra packages to install                              │
  │  installing openssh-server                                          │
  │    retrieving openssh-server                                        │
  │    curtin command system-install                                    │
  │    unpacking openssh-server                                         │
  │    curt in command system-install                                   │
  │  downloading and installing security updates                        │
  │    curtin command in-target                                         │
  │  restoring apt configuration                                        │
  │    curt in command in-target                                       █│
  │subiquity/Late/run                                                  ▾│
  └─────────────────────────────────────────────────────────────────────┘

                          [ View full log ]
-                         [ Reboot Now    ]

⛳️ 動作確認

🖥️ サーバーにログインする

クライアントのPC端末からSSHで接続して、リモートから操作できることを確認する。

🖥️ terminal
$ # サーバーにSSH接続
$ ssh sysadmin@ubuntu

🚨 SSH接続に失敗する場合

🖥️ terminal
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
🖥️ terminal
$ # エントリを削除
$ ssh-keygen -R ubuntu

上記コマンドの代わりに ~/.ssh/known_hosts をエディタで開き、該当行を直接削除してもよい。

Discussion