作成した仮想マシンをOracle Cloud Infrastructureのコンピュート・インスタンスとして実行できるように変更します。
シリアル・コンソールの構成
/etc/default/grubを編集し、シリアル・コンソールで接続できるようにします。
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_CMDLINE_LINUX="resume=/dev/mapper/ol-swap rd.lvm.lv=ol/root rd.lvm.lv=ol/swap rhgb quiet numa=off transparent_hugepage=never console=tty1 console=ttyS0,115200"
GRUB_DISABLE_RECOVERY="true"
GRUB_ENABLE_BLSCFG=true
GRUB_TERMINAL="serial console"
GRUB_SERIAL_COMMAND="serial --unit=0 --speed=115200"
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done
[root@localhost ~]# shutdown -h now
Connection to localhost closed by remote host.
Connection to localhost closed.
%
% nc localhost 10023
Oracle Linux Server 8.7
Kernel 5.15.0-101.103.2.1.el8uek.x86_64 on an x86_64
localhost login:
準仮想化ドライバの追加
lsinitrd | grep virtio
[root@localhost ~]# dracut --logfile /var/log/dracut.log --force --add qemu
[root@localhost ~]# lsinitrd | grep virtio
-rw-r--r-- 1 root root 14500 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/block/virtio_blk.ko.xz
-rw-r--r-- 1 root root 7116 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/char/hw_random/virtio-rng.ko.xz
-rw-r--r-- 1 root root 22928 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/char/virtio_console.ko.xz
-rw-r--r-- 1 root root 15228 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/scsi/virtio_scsi.ko.xz
drwxr-xr-x 2 root root 0 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/virtio
-rw-r--r-- 1 root root 14372 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/virtio/virtio_pci.ko.xz
-rw-r--r-- 1 root root 8304 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/virtio/virtio_pci_legacy_dev.ko.xz
-rw-r--r-- 1 root root 11296 Jan 13 20:43 usr/lib/modules/5.15.0-101.103.2.1.el8uek.x86_64/kernel/drivers/virtio/virtio_pci_modern_dev.ko.xz
[root@localhost ~]#
cloud-initの構成
[root@localhost ~]# dnf -y install cloud-init
Failed to set locale, defaulting to C.UTF-8
Last metadata expiration check: 0:15:34 ago on Mon May 22 10:54:45 2023.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
cloud-init noarch 22.1-8.0.2.el8 ol8_appstream 1.1 M
Installing dependencies:
bind-export-libs x86_64 32:9.11.36-8.el8 ol8_baseos_latest 1.1 M
dhcp-client x86_64 12:4.3.6-49.el8 ol8_baseos_latest 318 k
dhcp-common noarch 12:4.3.6-49.el8 ol8_baseos_latest 207 k
dhcp-libs x86_64 12:4.3.6-49.el8 ol8_baseos_latest 148 k
gdisk x86_64 1.0.3-11.el8 ol8_baseos_latest 241 k
ipcalc x86_64 0.2.4-4.el8 ol8_baseos_latest 38 k
python3-babel noarch 2.5.1-7.el8 ol8_appstream 4.8 M
python3-chardet noarch 3.0.4-7.el8 ol8_baseos_latest 195 k
python3-configobj noarch 5.0.6-11.el8 ol8_baseos_latest 68 k
python3-idna noarch 2.5-5.el8 ol8_baseos_latest 97 k
python3-jinja2 noarch 2.10.1-3.el8 ol8_appstream 538 k
[中略]
python3-markupsafe-0.23-19.el8.x86_64
python3-oauthlib-2.1.0-1.el8.noarch
python3-prettytable-0.7.2-14.el8.noarch
python3-pyserial-3.1.1-8.el8.noarch
python3-pysocks-1.6.8-3.el8.noarch
python3-pytz-2017.2-9.el8.noarch
python3-requests-2.20.0-2.1.el8_1.noarch
python3-urllib3-1.24.2-5.0.1.el8.noarch
Complete!
[root@localhost ~]#
[root@localhost ~]# cd /etc/cloud/cloud.cfg.d
[root@localhost cloud.cfg.d]# ls -l
total 12
-rw-r--r--. 1 root root 2070 Feb 16 2022 05_logging.cfg
-rw-r--r--. 1 root root 1661 May 22 11:15 99_oci.cfg
-rw-r--r--. 1 root root 167 Feb 16 2022 README
[root@localhost cloud.cfg.d]#