0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Ubuntu22.04 インストール後の初期設定メモ

Last updated at Posted at 2023-08-17

はじめに

このドキュメントは RaspberryPi3+LXD(snap) で Ubuntu 22.04 コンテナインスタンスを作成したあとに実施する初期設定をまとめたものです。

おことわり

  • 作業は root で実行してます。
  • 個人的な好みであることをご承知おきください。

環境

LXDホスト

pi@raspberrypi:~ $
pi@raspberrypi:~ $ cat /proc/device-tree/model
Raspberry Pi 3 Model B Rev 1.2
pi@raspberrypi:~ $
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
pi@raspberrypi:~ $
pi@raspberrypi:~ $ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye
pi@raspberrypi:~ $
pi@raspberrypi:~ $ snap list lxd
Name  Version       Rev    Tracking       Publisher   Notes
lxd   5.15-002fa0f  25116  latest/stable  canonical?  -
pi@raspberrypi:~ $

コンテナ

pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc launch images:ubuntu/jammy ubuntu2204-vanilla
pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc exec ubuntu2204-vanilla -- bash
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# uname -a
Linux ubuntu2204-c1 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 aarch64 aarch64 GNU/Linux
root@ubuntu2204-c1:root@ubuntu2204-vanilla:~#
root@ubuntu2204-c1:root@ubuntu2204-vanilla:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
root@ubuntu2204-vanilla:~#

初期設定

アップデート

リポジトリを編集する。
http://ports.ubuntu.com/http://jp.ports.ubuntu.com/ に変更する。

root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# vi /etc/apt/sources.list
# Generated by distrobuilder
deb http://jp.ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse
deb http://jp.ports.ubuntu.com/ubuntu-ports jammy-updates main restricted universe multiverse
deb http://jp.ports.ubuntu.com/ubuntu-ports jammy-security main restricted universe multiverse
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# apt update
root@ubuntu2204-vanilla:~# apt upgrade -y 
root@ubuntu2204-vanilla:~# apt autoremove -y
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# reboot
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# apt update && apt upgrade -y && apt autoremove -y
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# reboot
root@ubuntu2204-vanilla:~#

追加パッケージのインストール

root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# apt install -y curl dnsutils lsof
root@ubuntu2204-vanilla:~# apt install -y zip unzip
root@ubuntu2204-vanilla:~# apt install -y lsb-release
root@ubuntu2204-vanilla:~# apt install -y tree
root@ubuntu2204-vanilla:~# apt install -y man-db
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# apt install -y curl dnsutils lsof zip unzip lsb-release tree man-db 
root@ubuntu2204-vanilla:~#

リソース監視をするためにsarコマンドを使えるようにする

root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# apt install -y sysstat
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# vi /etc/default/sysstat
 :
ENABLED="false"
 ↓
ENABLED="true"
 :
root@ubuntu2204-vanilla:~#

timezone変更

root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# timedatectl
               Local time: Thu 2023-08-17 02:00:53 UTC
           Universal time: Thu 2023-08-17 02:00:53 UTC
                 RTC time: n/a
                Time zone: Etc/UTC (UTC, +0000)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# timedatectl set-timezone Asia/Tokyo
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# timedatectl
               Local time: Thu 2023-08-17 11:01:07 JST
           Universal time: Thu 2023-08-17 02:01:07 UTC
                 RTC time: n/a
                Time zone: Asia/Tokyo (JST, +0900)
System clock synchronized: yes
              NTP service: inactive
          RTC in local TZ: no
root@ubuntu2204-vanilla:~#

locale変更

root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# apt install -y language-pack-ja
root@ubuntu2204-vanilla:~# update-locale LANG=ja_JP.UTF-8
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# vi /etc/bash.bashrc
 :
# set $LANG
if [ -f /etc/default/locale ]; then
    . /etc/default/locale
fi
 :
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# exit
ログアウト
 ↓
ログイン
root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# date
2023年  8月 17日 木曜日 11:08:36 JST
root@ubuntu2204-vanilla:~#

デフォルトエディタを変更

root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# update-alternatives --config editor
There are 2 choices for the alternative editor (providing /usr/bin/editor).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/vim.basic   30        auto mode
  1            /usr/bin/vim.basic   30        manual mode
  2            /usr/bin/vim.tiny    15        manual mode

Press <enter> to keep the current choice[*], or type selection number:
root@ubuntu2204-vanilla:~#

コマンド履歴を削除

root@ubuntu2204-vanilla:~#
root@ubuntu2204-vanilla:~# history -c
root@ubuntu2204-vanilla:~#

その他

スナップショットを作成する

pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc snapshot ubuntu2204-vanilla
pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc info ubuntu2204-vanilla
Name: ubuntu2204-vanilla
Status: STOPPED
Type: container
Architecture: aarch64
Created: 2023/08/17 11:25 JST
Last Used: 2023/08/17 11:25 JST

Snapshots:
+-------+----------------------+------------+----------+
| NAME  |       TAKEN AT       | EXPIRES AT | STATEFUL |
+-------+----------------------+------------+----------+
| snap0 | 2023/08/17 11:31 JST |            | NO       |
+-------+----------------------+------------+----------+

pi@raspberrypi:~ $ lxc iamge list

イメージ化する

pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc publish ubuntu2204-vanilla/snap0 --alias ubuntu2204-vanilla
Instance published with fingerprint: 11b1d52d9cf0e1f9e60241b50019a27a8adee4752c28f504059b529f3c94b2b1
pi@raspberrypi:~ $ lxc image list
+--------------------+--------------+--------+-------------------------------------+--------------+-----------+----------+------------------------------+
|       ALIAS        | FINGERPRINT  | PUBLIC |             DESCRIPTION             | ARCHITECTURE |   TYPE    |   SIZE   |         UPLOAD DATE          |
+--------------------+--------------+--------+-------------------------------------+--------------+-----------+----------+------------------------------+
| ubuntu2204-vanilla | 11b1d52d9cf0 | no     | Ubuntu jammy arm64 (20230816_07:42) | aarch64      | CONTAINER | 190.07MB | Aug 17, 2023 at 2:48am (UTC) |
+--------------------+--------------+--------+-------------------------------------+--------------+-----------+----------+------------------------------+
|                    | d7cb780536fc | no     | Ubuntu jammy arm64 (20230816_07:42) | aarch64      | CONTAINER | 110.77MB | Aug 17, 2023 at 1:47am (UTC) |
+--------------------+--------------+--------+-------------------------------------+--------------+-----------+----------+------------------------------+
pi@raspberrypi:~ $

自作したイメージからコンテナを作成する

pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc launch ubuntu2204-vanilla web01 
pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc list
+--------------------+---------+----------------------+------+-----------+-----------+
|        NAME        |  STATE  |         IPV4         | IPV6 |   TYPE    | SNAPSHOTS |
+--------------------+---------+----------------------+------+-----------+-----------+
| ubuntu2204-vanilla | STOPPED |                      |      | CONTAINER | 3         |
+--------------------+---------+----------------------+------+-----------+-----------+
| web01              | RUNNING | 192.168.3.140 (eth0) |      | CONTAINER | 0         |
+--------------------+---------+----------------------+------+-----------+-----------+
pi@raspberrypi:~ $
pi@raspberrypi:~ $ lxc exec web01 -- bash
root@web01:~#
root@web01:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:        22.04
Codename:       jammy
root@web01:~#

変更履歴

2023/8/17

  • Ubuntu22.04用を新規投稿
0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?