作成した仮想マシンを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="crashkernel=1G-64G:448M,64G-:512M rd.lvm.lv=ol/root numa=off transparent_hugepage=madvise 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"
systemctl enable getty@ttyS0.service
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Adding boot menu entry for UEFI Firmware Settings ...
done
[root@localhost ~]# systemctl enable getty@ttyS0.service
Created symlink /etc/systemd/system/getty.target.wants/getty@ttyS0.service → /usr/lib/systemd/system/getty@.service.
[root@localhost ~]# shutdown -h now
[root@localhost ~]# Connection to localhost closed by remote host.
Connection to localhost closed.
ynakakoshi@nsmacbookintel ~ %
% nc localhost 10023
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 11032 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/block/virtio_blk.ko.xz
-rw-r--r-- 1 root root 4236 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/char/hw_random/virtio-rng.ko.xz
-rw-r--r-- 1 root root 18648 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/char/virtio_console.ko.xz
-rw-r--r-- 1 root root 10800 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/scsi/virtio_scsi.ko.xz
drwxr-xr-x 2 root root 0 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/virtio
-rw-r--r-- 1 root root 18560 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/virtio/virtio_mem.ko.xz
-rw-r--r-- 1 root root 12276 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/virtio/virtio_pci.ko.xz
-rw-r--r-- 1 root root 3920 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/virtio/virtio_pci_legacy_dev.ko.xz
-rw-r--r-- 1 root root 6916 Apr 8 23:17 usr/lib/modules/5.15.0-207.156.6.el9uek.x86_64/kernel/drivers/virtio/virtio_pci_modern_dev.ko.xz
[root@localhost ~]#
cloud-initの構成
[root@localhost ~]# dnf -y install cloud-init
Last metadata expiration check: 3:39:50 ago on Tue 18 Jun 2024 11:13:09 AM JST.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
cloud-init noarch 23.4-7.0.1.el9_4 ol9_appstream 2.0 M
Installing dependencies:
dhcp-client x86_64 12:4.4.2-19.b1.el9 ol9_baseos_latest 801 k
dhcp-common noarch 12:4.4.2-19.b1.el9 ol9_baseos_latest 135 k
gdisk x86_64 1.0.7-5.el9 ol9_appstream 255 k
ipcalc x86_64 1.0.0-5.el9 ol9_baseos_latest 42 k
python3-attrs noarch 20.3.0-7.0.1.el9 ol9_appstream 132 k
python3-babel noarch 2.9.1-2.el9 ol9_appstream 6.6 M
python3-chardet noarch 4.0.0-5.0.1.el9 ol9_baseos_latest 350 k
python3-configobj noarch 5.0.6-25.el9 ol9_appstream 75 k
python3-idna noarch 2.10-7.0.1.el9_4.1 ol9_baseos_latest 129 k
python3-jinja2 noarch 2.11.3-5.el9 ol9_appstream 328 k
python3-jsonpatch noarch 1.21-16.el9 ol9_appstream 37 k
python3-jsonpointer noarch 2.0-4.el9 ol9_appstream 30 k
python3-jsonschema noarch 3.2.0-13.el9 ol9_appstream 195 k
[中略]
python3-markupsafe-1.1.1-12.el9.x86_64
python3-oauthlib-3.1.1-5.el9.noarch
python3-prettytable-0.7.2-27.el9.noarch
python3-pyrsistent-0.17.3-8.el9.x86_64
python3-pyserial-3.4-12.el9.noarch
python3-pysocks-1.7.1-12.0.1.el9.noarch
python3-pytz-2021.1-5.el9.noarch
python3-requests-2.25.1-8.el9.noarch
python3-urllib3-1.26.5-5.el9.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]#