Oracle Cloud Infrastructure (OCI)のコンピュート・インスタンスは、シリアル・コンソール接続を使用して、インスタンスの誤動作をリモートでトラブルシューティングできます。
例) ・インポートまたはカスタマイズしたイメージが正常に起動しない
・以前は稼働していたインスタンスが応答しなくなった
クラウド・シェルを使用すると、インスタンス・コンソール接続と一時SSH鍵が自動的に作成されるのでシリアル・コンソールに迅速かつ簡単に接続できます。
ということで、シリアル・コンソール接続で Single User Mode で起動し rootユーザーでログインしてみてみます。
#■ 前提条件
クラウド・シェルを使用してシリアル・コンソールに接続する場合、正しい権限が必要です。
Oracle Cloud Infrastructureを使用するには、管理者によってポリシーでセキュリティ・アクセス権が付与されている必要があります。
権限がない、または認可されていないというメッセージが表示される場合は、管理者に連絡して、どのタイプのアクセス権があり、どのコンパートメントで作業するかを確認してください。
##● 必要な IAMポリシー
インスタンス・コンソール接続を作成するには、管理者は、インスタンス・コンソール接続を管理し、IAMポリシーを介してインスタンスを読み取るためのアクセス権をユーザーに付与する必要があります。インスタンス・コンソール接続のリソース名はinstance-console-connectionです。
次のポリシーは、インスタンス・コンソール接続を作成する権限をユーザーに付与します。
Allow group <group_name> to manage instance-console-connection in tenancy
Allow group <group_name> to read instance in tenancy
次のポリシーは、ネットワーク・ソースとのインスタンス・コンソール接続を作成する権限をユーザーに付与します。
Allow group <group_name> to manage instance-console-connection in tenancy where request.networkSource.name='example-network-source'
Allow group <group_name> to read instance in tenancy where request.networkSource.name='example-network-source'
ポリシーを初めて使用する場合は、ポリシーの開始と共通ポリシーを参照
#■ クラウド・シェルを使用したシリアル・コンソールへの接続
##1) コンピュート・インスタンス 画面
Oracle Cloud Infrastructureコンソールのインスタンスの詳細ページで、「リソース」の下の[コンソール接続]をクリック
##2) コンソール接続 画面
[Cloud Shell接続の起動]をクリック
このアクションにより、クラウド・シェルがコンソールの下部にあるドロワーに表示されます。
コンソール接続がすでに存在する場合、既存のリソースを削除するかどうかを尋ねられます。[y]を押してから、[Enter]を押します。
#■ Single User Mode 起動
##1) コンピュート・インスタンス 画面
[再起動]をクリック
##2) インスタンスの再起動画面
[インスタンスの再起動]をクリック
##4) 起動画面(GRUB)メニュー
起動画面(GRUB)メニューが表示されたら、ブートしたいカーネルのバージョンを選択して、5秒以内に"e" Key を入力
##5) Kernel Boot Line with an Additional Parameter画面
linuxefi項目の最後尾に " rw init=/bin/bash"を入力して、Ctrl+x をクリックして起動
##7) 起動完了
自動で rootユーザーでログインできていることを確認できます
#■ おまけ
プロンプトの出力結果
####● Oracle Cloud Shell 起動画面出力
Oracle Cloud Shellへようこそ。
Cloud Shellの新しいファイルのアップロード/ダウンロード機能を試してください。この新機能は、Cloud Shellメニューからアクセスします。
Cloud Shellマシンにはホーム・ディレクトリ用に5GBのストレージが付属しています。Cloud Shell (マシンとホーム・ディレクトリ)は次に配置されています: US East (Ashburn)。
テナンシshirokのCloud ShellをOCIのフェデレーテッド・ユーザーoracleidentitycloudservice/shirokとして使用しています
詳細は、「help」と入力してください。
Running instance console connection version 1
2022/01/06 10:25:22 Fetching instance info.
2022/01/06 10:25:23 Looking for existing console connections.
2022/01/06 10:25:25 Waiting for Instance Console Connection to complete transition. Current state: CREATING
2022/01/06 10:25:29 Waiting for Instance Console Connection to complete transition. Current state: CREATING
2022/01/06 10:25:32 Instance Console Connection reached state: ACTIVE
2022/01/06 10:25:33
=================================================
IMPORTANT: Use a console connection to troubleshoot a malfunctioning instance. For normal operations, you should connect to the instance using a Secure Shell (SSH) or Remote Desktop connection. For steps, see https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/accessinginstance.htm
For more information about troubleshooting your instance using a console connection, see the documentation: https://docs.cloud.oracle.com/en-us/iaas/Content/Compute/References/serialconsole.htm#four
=================================================
Oracle Linux Server 7.8
Kernel 4.14.35-2025.400.9.el7uek.x86_64 on an x86_64
tokyo-inst01 login:
####● 起動画面(GRUB)メニュー出力
Oracle Linux Server 7.8, with Linux 3.10.0-1127.19.1.el7.x86_64
Oracle Linux Server 7.8, with Unbreakable Enterprise Kernel 4.14.35-2025>
Oracle Linux Server 7.7 Rescue c63a5dae4fd54ffb9575bbfbeb445f3e (4.14.35>
Oracle Linux Server 7.7, with Unbreakable Enterprise Kernel 4.14.35-1902>
Oracle Linux Server (3.10.0-1062.el7.x86_64 with Linux) 7.6
Oracle Linux Server (0-rescue-5f60d2b209c441d5af8e976870bc5573 with Linu>
Use the ^ and v keys to change the selection.
Press 'e' to edit the selected item, or 'c' for a command prompt.
The selected entry will be started automatically in 1s.
####● Kernel Boot Line with an Additional Parameter画面出力: 修正前
setparams 'Oracle Linux Server 7.9, with Unbreakable Enterprise Kernel 5.4.17-\
2102.201.3.el7uek.x86_64'
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod xfs
set root='hd0,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-\
efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3 79ba4403-7532-4e2c-ac5d-2910dce62009
search --no-floppy --fs-uuid --set=root 79ba4403-7532-4e2c-ac5d-2910\
else
search --no-floppy --fs-uuid --set=root 79ba4403-7532-4e2c-ac5d-2910\
dce62009
fi
linuxefi /boot/vmlinuz-5.4.17-2102.201.3.el7uek.x86_64 root=UUID=79ba4\
403-7532-4e2c-ac5d-2910dce62009 ro crashkernel=auto LANG=en_US.UTF-8 console=t\
ty0 console=ttyS0,9600 rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 rd.iscsi.bypass=1 ne\
troot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi iscsi_param=node.sess\
ion.timeo.replacement_timeout=6000 net.ifnames=1 nvme_core.shutdown_timeout=10\
ipmi_si.tryacpi=0 ipmi_si.trydmi=0 libiscsi.debug_libiscsi_eh=1 loglevel=4 ip\
=single-dhcp crash_kexec_post_notifiers
initrdefi /boot/initramfs-5.4.17-2102.201.3.el7uek.x86_64.img
Press Ctrl-x to start, Ctrl-c for a command prompt or Escape to
discard edits and return to the menu. Pressing Tab lists possible
completions.
####● Kernel Boot Line with an Additional Parameter画面出力: 修正後
rw init=/bin/bash 追加
setparams 'Oracle Linux Server 7.9, with Unbreakable Enterprise Kernel 5.4.17-\
2102.201.3.el7uek.x86_64'
load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod xfs
set root='hd0,gpt3'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt3 --hint-\
efi=hd0,gpt3 --hint-baremetal=ahci0,gpt3 79ba4403-7532-4e2c-ac5d-2910dce62009
search --no-floppy --fs-uuid --set=root 79ba4403-7532-4e2c-ac5d-2910\
else
search --no-floppy --fs-uuid --set=root 79ba4403-7532-4e2c-ac5d-2910\
dce62009
fi
linuxefi /boot/vmlinuz-5.4.17-2102.201.3.el7uek.x86_64 root=UUID=79ba4\
403-7532-4e2c-ac5d-2910dce62009 ro crashkernel=auto LANG=en_US.UTF-8 console=t\
ty0 console=ttyS0,9600 rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 rd.iscsi.bypass=1 ne\
troot=iscsi:169.254.0.2:::1:iqn.2015-02.oracle.boot:uefi iscsi_param=node.sess\
ion.timeo.replacement_timeout=6000 net.ifnames=1 nvme_core.shutdown_timeout=10\
ipmi_si.tryacpi=0 ipmi_si.trydmi=0 libiscsi.debug_libiscsi_eh=1 loglevel=4 ip\
=single-dhcp crash_kexec_post_notifiers rw init=/bin/bash
initrdefi /boot/initramfs-5.4.17-2102.201.3.el7uek.x86_64.img
Press Ctrl-x to start, Ctrl-c for a command prompt or Escape to
discard edits and return to the menu. Pressing Tab lists possible
completions.
####● Single User Mode 起動画面出力
Welcome to Oracle Linux Server 7.9 dracut-033-572.0.3.el7 (Initramfs)!
[ OK ] Started Dispatch Password Requests to Console Directory Watch.
[ OK ] Reached target Local File Systems.
[ OK ] Reached target Timers.
[ OK ] Reached target Paths.
[ OK ] Reached target Swap.
[ OK ] Created slice Root Slice.
[ OK ] Listening on Journal Socket.
[ OK ] Created slice System Slice.
Starting Journal Service...
Starting Apply Kernel Variables...
Starting Create list of required st... nodes for the current kernel...
Starting dracut cmdline hook...
[ OK ] Reached target Slices.
[ OK ] Listening on udev Kernel Socket.
[ OK ] Listening on udev Control Socket.
[ OK ] Reached target Local Encrypted Volumes.
[ OK ] Started Apply Kernel Variables.
[ OK ] Started Create list of required sta...ce nodes for the current kernel.
Starting Create Static Device Nodes in /dev...
[ OK ] Started Create Static Device Nodes in /dev.
[ OK ] Started Journal Service.
[ OK ] Started dracut cmdline hook.
Starting dracut pre-udev hook...
Starting Open-iSCSI...
[ OK ] Started Open-iSCSI.
[ OK ] Started dracut pre-udev hook.
Starting udev Kernel Device Manager...
[ OK ] Started udev Kernel Device Manager.
Starting dracut pre-trigger hook...
[ OK ] Started dracut pre-trigger hook.
Starting udev Coldplug all Devices...
Mounting Configuration File System...
[ OK ] Mounted Configuration File System.
[ OK ] Started udev Coldplug all Devices.
Starting dracut initqueue hook...
[ OK ] Reached target System Initialization.
[ OK ] Listening on Open-iSCSI iscsiuio Socket.
[ OK ] Reached target Sockets.
[ OK ] Reached target Basic System.
[ OK ] Found device BlockVolume 3.
Starting File System Check on /dev/...3-7532-4e2c-ac5d-2910dce62009...
[ 1.106693] dracut-initqueue[499]: RTNETLINK answers: File exists
[ OK ] Started File System Check on /dev/d...403-7532-4e2c-ac5d-2910dce62009.
[ 3.293814] dracut-initqueue[499]: RTNETLINK answers: File exists
[ OK ] Started dracut initqueue hook.
Starting dracut pre-mount hook...
[ OK ] Reached target Remote File Systems (Pre).
[ OK ] Reached target Remote File Systems.
[ OK ] Started dracut pre-mount hook.
Mounting /sysroot...
[ OK ] Mounted /sysroot.
[ OK ] Reached target Initrd Root File System.
Starting Reload Configuration from the Real Root...
Mounting /sysroot/boot/efi...
[ OK ] Started Reload Configuration from the Real Root.
[ OK ] Mounted /sysroot/boot/efi.
[ OK ] Reached target Initrd File Systems.
[ OK ] Reached target Initrd Default Target.
Starting dracut pre-pivot and cleanup hook...
[ OK ] Started dracut pre-pivot and cleanup hook.
Starting Cleaning Up and Shutting Down Daemons...
[ OK ] Stopped target Timers.
[ OK ] Stopped dracut pre-pivot and cleanup hook.
[ OK ] Stopped target Remote File Systems.
[ OK ] Stopped target Remote File Systems (Pre).
[ OK ] Stopped target Initrd Default Target.
[ OK ] Stopped dracut pre-mount hook.
[ OK ] Stopped dracut initqueue hook.
Stopping Open-iSCSI...
[ OK ] Stopped target Basic System.
[ OK ] Stopped target Paths.
[ OK ] Stopped target Slices.
[ OK ] Stopped target Sockets.
[ OK ] Closed Open-iSCSI iscsiuio Socket.
[ OK ] Stopped target System Initialization.
[ OK ] Stopped target Local Encrypted Volumes.
[ OK ] Stopped target Swap.
[ OK ] Stopped udev Coldplug all Devices.
[ OK ] Stopped dracut pre-trigger hook.
[ OK ] Stopped target Local File Systems.
Stopping udev Kernel Device Manager...
[ OK ] Stopped Apply Kernel Variables.
[ OK ] Stopped Dispatch Password Requests to Console Directory Watch.
[ OK ] Stopped Open-iSCSI.
[ OK ] Stopped udev Kernel Device Manager.
[ OK ] Stopped Create Static Device Nodes in /dev.
[ OK ] Stopped Create list of required sta...ce nodes for the current kernel.
[ OK ] Stopped dracut pre-udev hook.
[ OK ] Closed udev Control Socket.
[ OK ] Closed udev Kernel Socket.
Starting Cleanup udevd DB...
[ OK ] Stopped dracut cmdline hook.
[ OK ] Started Cleaning Up and Shutting Down Daemons.
[ OK ] Started Cleanup udevd DB.
[ OK ] Reached target Switch Root.
Starting Switch Root...
bash-4.2#
bash-4.2# id -a
uid=0(root) gid=0(root) groups=0(root)
bash-4.2# cd /home/opc
bash-4.2# ls -la
total 36
drwx------. 5 opc opc 4096 Aug 12 03:51 .
drwxr-xr-x. 3 root root 17 Jun 11 2021 ..
-rw-------. 1 opc opc 1965 Nov 19 11:30 .bash_history
-rw-r--r--. 1 opc opc 18 Nov 22 2019 .bash_logout
-rw-r--r--. 1 opc opc 193 Nov 22 2019 .bash_profile
-rw-r--r--. 1 opc opc 231 Nov 22 2019 .bashrc
drwxrwxr-x. 3 opc opc 18 Jun 11 2021 .cache
-rw-rw-r--. 1 opc opc 47 Aug 12 03:51 config
drwxrwxr-x. 3 opc opc 18 Jun 11 2021 .config
-rw-r--r--. 1 opc opc 172 Apr 1 2020 .kshrc
drwx------. 2 opc opc 48 Aug 11 15:46 .ssh
-rw-------. 1 opc opc 1979 Aug 12 03:51 .viminfo
bash-4.2#
#■ 参考
・OCI Document
- インスタンス・コンソール接続を使用したインスタンスのトラブルシューティング
- コンピュート・インスタンスのトラブルシューティング
- クラウド・シェルの使用
・Oracle Linux Document
- Working With the GRUB 2 Bootloader and Configuring Boot Services
・その他
- Single-user mode
- Why use a serial console?