DEV Community

vast cow
vast cow

Posted on Edited on

PiKVM Setup and Basic Usage

PiKVM is a remote KVM solution that lets you view video output, control the keyboard and mouse, and boot from virtual media even when the target computer's operating system is not running.

This guide walks through the entire process in the order you would actually perform it, from writing the OS image to an SD card, through initial configuration, virtual media setup, remote access with Tailscale, and finally operating the target machine.

Keep in mind that the interface and some features vary depending on the PiKVM model and KVMD version. The virtual media sections in this article primarily assume PiKVM V2 or later.


Understanding the Read-Only Filesystem

PiKVM OS normally operates with its filesystem mounted as read-only to reduce SD card wear and protect against filesystem corruption caused by unexpected power loss. After making configuration changes, you should always return the filesystem to read-only mode.

An important point is that PiKVM provides two different commands for enabling writes, each serving a different purpose.

Comparison of Write Mode Commands

Command Target Primary Purpose Enable Writes Return to Read-Only
rw / ro PiKVM OS root filesystem Changing passwords, installing packages, editing files under /etc, changing the hostname rw ro
kvmd-helper-otgmsd-remount rw / ro Virtual media area at /var/lib/kvmd/msd Uploading, deleting, or modifying ISO and IMG files kvmd-helper-otgmsd-remount rw kvmd-helper-otgmsd-remount ro

The key point is that running rw does not necessarily make the virtual media area writable. Likewise, running kvmd-helper-otgmsd-remount rw does not allow you to modify system configuration files such as those under /etc.

Use the appropriate command depending on what you are modifying.


1. Write the Image to the SD Card

First, write the appropriate PiKVM OS image for your PiKVM model to an SD card.

After writing completes—but before booting PiKVM—open the first FAT32 partition on the SD card. This partition contains the pikvm.txt file used for first-boot configuration.


2. Configure Wi-Fi Before the First Boot

If wired Ethernet is unavailable, configuring Wi-Fi before the first boot makes the initial setup much easier.

Add the following lines to pikvm.txt:

WIFI_ESSID='Your Wi-Fi SSID'
WIFI_PASSWD='Your Wi-Fi Password'
WIFI_REGDOM='JP'
Enter fullscreen mode Exit fullscreen mode

WIFI_REGDOM='JP' specifies Japan as the wireless regulatory domain.

If the following line already exists in pikvm.txt immediately after writing the image, leave it unchanged:

FIRST_BOOT=1
Enter fullscreen mode Exit fullscreen mode

FIRST_BOOT=1 instructs PiKVM to generate SSH host keys, certificates, and other first-boot resources.

If your Wi-Fi password contains a backslash, it must be escaped by doubling it:

WIFI_PASSWD='abc\\def'
Enter fullscreen mode Exit fullscreen mode

After the configuration has been applied, pikvm.txt is automatically deleted.

Also note that configurations based on the Raspberry Pi Zero 2 W cannot use 5 GHz Wi-Fi.

Safely eject the SD card, insert it into the PiKVM, and power it on.


3. Find the PiKVM IP Address

PiKVM normally obtains an IP address using DHCP.

After booting, the assigned IP address is displayed on the monitor connected to PiKVM, making it the easiest way to find it.

If no monitor is attached, check your router's management interface or DHCP lease table to identify the assigned address.

Throughout this guide, the PiKVM IP address will be represented as:

192.168.1.100
Enter fullscreen mode Exit fullscreen mode

4. Connect to PiKVM via SSH

By default, the Linux administrator account is configured as follows:

Item Default
Username root
Password root

Connect using an SSH client:

ssh root@192.168.1.100
Enter fullscreen mode Exit fullscreen mode

On the first connection, SSH asks you to verify the host key. Confirm that you are connecting to the correct device before accepting it.

PiKVM also has a separate admin account for the Web UI. By default, both the username and password are admin.

The Linux root account and the Web UI admin account are completely independent, so both passwords must be changed.


5. Change Both Default Passwords First

Running PiKVM with its default passwords is insecure. Change them before configuring networking or installing additional features.

First, remount the root filesystem as writable:

rw
Enter fullscreen mode Exit fullscreen mode

Change the Linux root password:

passwd root
Enter fullscreen mode Exit fullscreen mode

Next, change the Web UI admin password:

kvmd-htpasswd set admin
Enter fullscreen mode Exit fullscreen mode

After both passwords have been updated, return the filesystem to read-only mode:

ro
Enter fullscreen mode Exit fullscreen mode

The complete sequence is:

rw
passwd root
kvmd-htpasswd set admin
ro
Enter fullscreen mode Exit fullscreen mode

If you forget to run rw before changing passwords, the changes cannot be saved.

The official documentation also recommends changing both passwords between rw and ro.


6. Change the Hostname

If you manage multiple PiKVM devices, assigning meaningful hostnames based on their location or purpose makes administration easier.

For example, a PiKVM managing the first server in a server room might use:

pikvm-server01
Enter fullscreen mode Exit fullscreen mode

Change the hostname using:

rw
systemctl restart systemd-hostnamed
hostnamectl set-hostname pikvm-server01
ro
reboot
Enter fullscreen mode Exit fullscreen mode

After rebooting, both the SSH prompt and the network hostname reflect the new name.

The official FAQ also recommends restarting systemd-hostnamed, then running hostnamectl set-hostname, followed by rebooting PiKVM.

If you plan to install Tailscale, configuring the hostname first makes devices easier to identify in the Tailscale admin console.


7. Update PiKVM OS

After the initial configuration is complete, update PiKVM OS.

pikvm-update
Enter fullscreen mode Exit fullscreen mode

Normally you do not need to manually run rw or ro; pikvm-update is the recommended update method.

However, updates are never completely risk-free. The official documentation recommends performing updates while you still have physical access to the PiKVM, in case the SD card must be reflashed. Avoid updating a PiKVM that is only reachable over a VPN unless necessary.

If you're using an older image that doesn't include pikvm-update, install it first:

rw
pacman -Syy
pacman -S pikvm-os-updater
pikvm-update
Enter fullscreen mode Exit fullscreen mode

Reboot afterward if required.


8. Install Tailscale on PiKVM

If you intend to access PiKVM over the Internet, using a private networking solution such as Tailscale is much safer and easier to manage than exposing the Web UI or SSH directly.

PiKVM provides a dedicated package called tailscale-pikvm.

After running pikvm-update, install it in the following order:

rw
pacman -S tailscale-pikvm
systemctl enable --now tailscaled
tailscale up --qr
ro
Enter fullscreen mode Exit fullscreen mode

Running tailscale up --qr displays a QR code for the authentication URL directly in the terminal. This is especially convenient when using a remote console where copying long URLs is difficult. --qr is an officially supported option in the current Tailscale CLI.

Using PiKVM as an Exit Node

If you want to use PiKVM as an Exit Node, enable the Exit Node feature in Tailscale.

rw

tailscale set \
  --advertise-exit-node \
  --advertise-routes=192.168.0.0/24

ro
Enter fullscreen mode Exit fullscreen mode

For --advertise-routes, specify the LAN subnet that is reachable from the PiKVM. For example, if your managed network is 192.168.0.0/24, use the command above.

After applying the configuration, open the device in the Tailscale admin console and approve both Exit Node and Subnet routes.

You can then select the PiKVM as the Exit Node from your Tailscale client. In addition to routing Internet traffic through the PiKVM, you'll also be able to access devices on the LAN connected to the PiKVM.

Configuring UDP GRO on Raspberry Pi

When using a Raspberry Pi as an Exit Node, it is recommended to enable the Linux kernel's UDP GRO settings.

On PiKVM, you can create the following systemd service to apply the required settings automatically at boot.

rw

cat > /etc/systemd/system/apply-udp-gro.service <<'EOF'
[Unit]
Description=Configure UDP GRO forwarding
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ethtool -K eth0 rx-udp-gro-forwarding on rx-gro-list off
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now apply-udp-gro.service

ro
Enter fullscreen mode Exit fullscreen mode

This service runs the following command each time the PiKVM boots, ensuring that the UDP GRO settings persist across reboots.

ethtool -K eth0 rx-udp-gro-forwarding on rx-gro-list off
Enter fullscreen mode Exit fullscreen mode

After configuring the service, you can verify the current settings with:

ethtool -k eth0 | grep -E 'rx-udp-gro-forwarding|rx-gro-list'
Enter fullscreen mode Exit fullscreen mode

The expected output is:

rx-gro-list: off
rx-udp-gro-forwarding: on
Enter fullscreen mode Exit fullscreen mode

If your PiKVM uses a network interface other than eth0, replace it with the appropriate interface name for your environment.


9. Upload Virtual Media to PiKVM

PiKVM can present ISO and IMG files to the target machine as either a virtual CD/DVD drive or a virtual USB flash drive.

Image files are stored in:

/var/lib/kvmd/msd
Enter fullscreen mode Exit fullscreen mode

Uploading through the Web UI's Drive menu is usually the simplest approach.

If you prefer using SCP or rsync manually, first remount the virtual media partition as writable:

kvmd-helper-otgmsd-remount rw
Enter fullscreen mode Exit fullscreen mode

Transfer the ISO from your local computer:

scp installer.iso root@192.168.1.100:/var/lib/kvmd/msd/
Enter fullscreen mode Exit fullscreen mode

After the transfer completes, remount the partition as read-only:

kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

The official documentation recommends the following sequence:

  1. Run kvmd-helper-otgmsd-remount rw
  2. Copy files into /var/lib/kvmd/msd
  3. Run kvmd-helper-otgmsd-remount ro

Keeping the virtual media partition read-only during normal operation helps prevent corruption caused by unexpected power loss.


Is chown kvmd:kvmd Necessary for ISO Files?

Files uploaded via SCP are normally owned by root.

ls -l /var/lib/kvmd/msd/
Enter fullscreen mode Exit fullscreen mode

For example:

-rw-r--r-- 1 root root ... installer.iso
Enter fullscreen mode Exit fullscreen mode

As long as the file is readable by everyone, changing ownership is not necessarily required for read-only ISO usage.

In other words, you do not need to mechanically run:

chown kvmd:kvmd installer.iso
Enter fullscreen mode Exit fullscreen mode

for every uploaded ISO.

What actually matters is that the kvmd user has permission to read the file. If necessary, set the permissions like this:

kvmd-helper-otgmsd-remount rw
chmod 644 /var/lib/kvmd/msd/installer.iso
kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

On the other hand, if the image will be presented as a writable virtual flash drive, write permissions are also required. The official documentation uses:

chmod 666 /var/lib/kvmd/msd/flash.img
Enter fullscreen mode Exit fullscreen mode

for writable flash images.

If you prefer consistent ownership across all files, you may use:

kvmd-helper-otgmsd-remount rw
chown kvmd:kvmd /var/lib/kvmd/msd/installer.iso
chmod 644 /var/lib/kvmd/msd/installer.iso
kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

However, for read-only ISOs, the essential requirement is that the kvmd user can read the file—not that the file is owned by kvmd.


10. Boot the Target Machine from Virtual Media

After uploading an ISO, open the PiKVM Web UI and select the desired image from the Drive menu.

The basic workflow is:

  1. Open the Drive menu.
  2. Select the ISO or IMG file.
  3. Choose the media type.
  4. Connect the image.
  5. Reboot the target machine.
  6. Select the virtual media from the BIOS or UEFI boot menu.

PiKVM can present virtual media in the following formats:

Mode Appears as Typical Use
CD/DVD Optical drive Standard OS installation ISOs and rescue media
Flash USB flash drive UEFI compatibility workarounds and writable disk images

In most cases, ISO images should be connected as CD/DVD.

However, some UEFI implementations cannot boot correctly from virtual optical drives. If that happens, reconnecting the same image as Flash may allow the firmware to recognize it.

This is a compatibility workaround for specific systems, not a universal requirement.

PiKVM virtual media is accessible from both BIOS and UEFI, and the connection mode can be switched between CD/DVD and Flash through the Web UI.


Precautions When Using Virtual Media

Do not power off PiKVM while an image is being uploaded or while a writable virtual image is connected to the target machine.

Interrupting power during an upload or write operation can corrupt the image file or the filesystem.


11. Send Ctrl+Alt+Del

Since web browsers often intercept keys such as Ctrl and Alt, special key combinations should be sent from the PiKVM Web UI.

To send Ctrl+Alt+Del, open the Shortcuts menu at the top of the Web UI and select Ctrl+Alt+Del.

If the desired shortcut is unavailable, you can also use PiKVM's Magic Key shortcut mechanism. According to the current official documentation, you press and release the Magic Key, then press and release Ctrl, Alt, and Del in sequence.


12. Install Tailscale on the Target Machine

If you also want to install Tailscale on the computer you're controlling through PiKVM, the following command is particularly convenient on Linux:

tailscale up --qr
Enter fullscreen mode Exit fullscreen mode

Scan the QR code displayed on the screen with your smartphone to complete Tailscale authentication.

This eliminates the need to manually type long authentication URLs or rely on clipboard sharing, making it especially useful immediately after installing an operating system or in environments without a graphical desktop.


Recommended Setup Order

To minimize rework, perform the initial setup in the following order:

  1. Write the PiKVM OS image to the SD card.
  2. Configure Wi-Fi in pikvm.txt before the first boot.
  3. Boot PiKVM and determine its IP address.
  4. Connect via SSH as root.
  5. Change the Linux root password.
  6. Change the Web UI admin password.
  7. Change the hostname.
  8. Run pikvm-update while physical access is available.
  9. Install Tailscale if needed.
  10. Upload ISO and IMG files to the virtual media storage.
  11. Connect to the target machine through the Web UI.
  12. Attach virtual media and perform OS installation or recovery.

Summary

The most common source of confusion when using PiKVM is switching between the two write modes.

When modifying system configuration, use:

rw
# Make configuration changes
ro
Enter fullscreen mode Exit fullscreen mode

When uploading ISO or IMG files, use:

kvmd-helper-otgmsd-remount rw
# Upload or remove ISO/IMG files
kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

Understanding the distinction between these two mechanisms and always returning to read-only mode afterward is fundamental to operating PiKVM safely.

Also, immediately after the first boot, be sure to change both the Linux and Web UI passwords. If you need remote access from outside your local network, it is generally better to use a private networking solution such as Tailscale rather than exposing the PiKVM Web UI directly to the Internet.

PiKVMのセットアップと基本的な使い方

PiKVMは、管理対象のコンピューターにOSが起動していない状態でも、映像の確認、キーボード・マウス操作、仮想メディアからの起動などを行えるリモートKVMです。

本記事では、SDカードへのイメージ書き込み後から、初期設定、仮想メディアの配置、Tailscaleによるリモートアクセス、管理対象マシンの操作までを、実際に作業する順番に沿って解説します。

なお、画面構成や一部の機能はPiKVMのモデルやKVMDのバージョンによって異なります。本記事の仮想メディアに関する説明は、主にPiKVM V2以降を想定しています。


最初に理解しておきたい「読み取り専用」の仕組み

PiKVM OSは、突然の電源断によるファイルシステム破損やSDカードの消耗を抑えるため、通常はファイルシステムを読み取り専用で使用します。設定変更が終わったら、必ず読み取り専用へ戻すのが基本です。

ここで注意したいのが、PiKVMには用途の異なる2種類の書き込み切り替えコマンドがあることです。

書き込みモードを変更するコマンドの比較

コマンド 対象 主な用途 書き込み可能にする 読み取り専用に戻す
rw / ro PiKVM OSのルートファイルシステム パスワード変更、パッケージのインストール、/etc以下の編集、ホスト名変更 rw ro
kvmd-helper-otgmsd-remount rw / ro /var/lib/kvmd/msdの仮想メディア領域 ISO・IMGファイルの配置、削除、書き換え kvmd-helper-otgmsd-remount rw kvmd-helper-otgmsd-remount ro

重要なのは、rwを実行しても、仮想メディア領域が書き込み可能になるとは限らないことです。反対に、kvmd-helper-otgmsd-remount rwを実行しても、/etcなどのシステム設定は編集できません。

作業対象に応じて使い分けます。


1. SDカードへイメージを書き込む

まず、使用するPiKVMモデルに対応したOSイメージをSDカードへ書き込みます。

書き込み完了後、PiKVMを起動する前にSDカードの先頭にあるFAT32パーティションを開きます。このパーティションには、初回起動時の設定に使用するpikvm.txtがあります。


2. 初回起動前にWi-Fiを設定する

有線LANを使用できない環境では、初回起動前にpikvm.txtへWi-Fi情報を書いておくと、その後の接続が容易になります。

pikvm.txtへ次の行を追加します。

WIFI_ESSID='Wi-FiのSSID'
WIFI_PASSWD='Wi-Fiのパスワード'
WIFI_REGDOM='JP'
Enter fullscreen mode Exit fullscreen mode

WIFI_REGDOM='JP'は日本の無線規制ドメインを指定する設定です。

初回書き込み直後のpikvm.txtに次の行が存在する場合は、削除せず残してください。

FIRST_BOOT=1
Enter fullscreen mode Exit fullscreen mode

FIRST_BOOT=1は、初回起動時にSSHホスト鍵や証明書などを生成するための指定です。

また、Wi-Fiパスワードにバックスラッシュが含まれる場合は、次のように二重に記述する必要があります。

WIFI_PASSWD='abc\\def'
Enter fullscreen mode Exit fullscreen mode

pikvm.txtは設定の適用後に自動的に削除されます。Raspberry Pi Zero 2 Wを使用した構成では、5GHz Wi-Fiを利用できない点にも注意してください。

編集後はSDカードを安全に取り外し、PiKVMへ戻して起動します。


3. PiKVMのIPアドレスを確認する

PiKVMは通常、DHCPを使ってIPアドレスを取得します。

起動すると、PiKVMに接続されたディスプレイへ現在のIPアドレスが表示されるため、まずはその表示を確認するのが簡単です。

ディスプレイを接続していない場合は、ルーターの管理画面やDHCPリース一覧から、PiKVMへ割り当てられたIPアドレスを確認します。

以降の例では、PiKVMのIPアドレスを次のように表記します。

192.168.1.100
Enter fullscreen mode Exit fullscreen mode

4. SSHでPiKVMへ接続する

初期状態では、Linuxの管理者アカウントは次の設定です。

項目 初期値
ユーザー名 root
パスワード root

SSHクライアントから接続します。

ssh root@192.168.1.100
Enter fullscreen mode Exit fullscreen mode

初回接続時にはSSHホスト鍵の確認が表示されるため、接続先が正しいことを確認して承認します。

PiKVMには、SSHなどで使うLinuxのrootアカウントとは別に、Web UI用のadminアカウントがあります。初期状態では、Web UI側もユーザー名とパスワードがともにadminです。両者は独立したアカウントなので、両方のパスワードを変更する必要があります。


5. 最初に2種類のパスワードを変更する

初期パスワードのまま運用するのは危険です。ネットワーク設定や機能追加よりも先に変更します。

まず、ルートファイルシステムを書き込み可能にします。

rw
Enter fullscreen mode Exit fullscreen mode

Linuxのrootパスワードを変更します。

passwd root
Enter fullscreen mode Exit fullscreen mode

続いて、Web UIで使用するadminのパスワードを変更します。

kvmd-htpasswd set admin
Enter fullscreen mode Exit fullscreen mode

両方の変更が完了したら、ファイルシステムを読み取り専用に戻します。

ro
Enter fullscreen mode Exit fullscreen mode

まとめると、実行順は次のとおりです。

rw
passwd root
kvmd-htpasswd set admin
ro
Enter fullscreen mode Exit fullscreen mode

パスワード変更時にrwを実行し忘れると、設定を保存できません。公式ドキュメントでも、rwroの間で両方のパスワードを変更する手順が案内されています。


6. ホスト名を変更する

複数のPiKVMを管理する場合は、設置場所や管理対象が分かるホスト名へ変更しておくと便利です。

例えば、サーバールームの1号機を管理するPiKVMであれば、次のような名前にします。

pikvm-server01
Enter fullscreen mode Exit fullscreen mode

変更手順は次のとおりです。

rw
systemctl restart systemd-hostnamed
hostnamectl set-hostname pikvm-server01
ro
reboot
Enter fullscreen mode Exit fullscreen mode

再起動後、SSHのプロンプトやネットワーク上のホスト名が変更されます。公式FAQでも、systemd-hostnamedを再起動してからhostnamectl set-hostnameを実行し、PiKVMを再起動する方法が案内されています。

Tailscaleを導入する予定がある場合も、先にホスト名を設定しておくと管理画面上で機器を識別しやすくなります。


7. PiKVM OSをアップデートする

初期設定が終わったら、PiKVM OSを更新します。

pikvm-update
Enter fullscreen mode Exit fullscreen mode

通常、手動でrwroを実行する必要はありません。pikvm-updateを使用するのがPiKVMで推奨される更新方法です。

ただし、更新には失敗の可能性がまったくないわけではありません。公式ドキュメントでは、SDカードの再書き込みが必要になる場合に備え、可能であればPiKVMへ物理的にアクセスできる状態で更新することが推奨されています。VPN経由でしか接続できないPiKVMを安易に更新するのは避けたほうが安全です。

古いイメージでpikvm-updateが存在しない場合は、次の手順でアップデーターを導入します。

rw
pacman -Syy
pacman -S pikvm-os-updater
pikvm-update
Enter fullscreen mode Exit fullscreen mode

更新後は、必要に応じて再起動します。


8. TailscaleをPiKVMへ導入する

インターネット経由でPiKVMを利用する場合、Web UIやSSHを直接ポート開放するよりも、Tailscaleなどのプライベートネットワークを利用する方法が管理しやすくなります。

PiKVMには、PiKVM向けのTailscaleパッケージとしてtailscale-pikvmが用意されています。

先にpikvm-updateを実行したうえで、次の順番で導入します。

rw
pacman -S tailscale-pikvm
systemctl enable --now tailscaled
tailscale up --qr
ro
Enter fullscreen mode Exit fullscreen mode

tailscale up --qrを実行すると、認証用URLに対応するQRコードがターミナルへ表示されます。スマートフォンで読み取って認証できるため、URLをコピーしにくいリモートコンソール環境で便利です。--qrは現在のTailscale CLIで正式に用意されているオプションです。

Exit Nodeを利用する場合

PiKVMをExit Nodeとして利用する場合は、TailscaleでExit Nodeを有効にします。

rw

tailscale set \
  --advertise-exit-node \
  --advertise-routes=192.168.0.0/24

ro
Enter fullscreen mode Exit fullscreen mode

--advertise-routesには、PiKVMから到達可能なLANのネットワークアドレスを指定します。例えば、管理対象ネットワークが192.168.0.0/24であれば上記のようになります。

設定後、Tailscale管理画面で対象ノードを開き、Exit NodeおよびSubnet routesを承認します。

その後、クライアント側でPiKVMをExit Nodeとして選択すると、インターネット通信だけでなく、PiKVMが接続されているLAN上の機器へもアクセスできるようになります。

Raspberry PiのUDP GRO設定

Raspberry PiをExit Nodeとして利用する場合は、LinuxカーネルのUDP GRO設定を有効にすることが推奨されています。

PiKVMでは次のsystemdサービスを作成すると、起動時に自動で設定が適用されます。

rw

cat > /etc/systemd/system/apply-udp-gro.service <<'EOF'
[Unit]
Description=Configure UDP GRO forwarding
Wants=network-online.target
After=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ethtool -K eth0 rx-udp-gro-forwarding on rx-gro-list off
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl enable --now apply-udp-gro.service

ro
Enter fullscreen mode Exit fullscreen mode

このサービスは、PiKVMの起動時に

ethtool -K eth0 rx-udp-gro-forwarding on rx-gro-list off
Enter fullscreen mode Exit fullscreen mode

を実行し、再起動後もUDP GROの設定を維持します。

設定後は、次のコマンドで状態を確認できます。

ethtool -k eth0 | grep -E 'rx-udp-gro-forwarding|rx-gro-list'
Enter fullscreen mode Exit fullscreen mode

期待する出力は次のとおりです。

rx-gro-list: off
rx-udp-gro-forwarding: on
Enter fullscreen mode Exit fullscreen mode

なお、eth0以外のインターフェースを利用している場合は、環境に合わせて読み替えてください。


9. 仮想メディアをPiKVMへ配置する

PiKVMは、ISOやIMGファイルを管理対象マシンへ仮想CD/DVDまたは仮想USBメモリーとして接続できます。

イメージファイルは、PiKVM上の次のディレクトリに保存されます。

/var/lib/kvmd/msd
Enter fullscreen mode Exit fullscreen mode

通常はWeb UIのDriveメニューからアップロードする方法が簡単です。手動でSCPやrsyncを使用する場合は、仮想メディア専用領域を書き込み可能にします。

PiKVM上で次を実行します。

kvmd-helper-otgmsd-remount rw
Enter fullscreen mode Exit fullscreen mode

次に、手元のPCからISOファイルを転送します。

scp installer.iso root@192.168.1.100:/var/lib/kvmd/msd/
Enter fullscreen mode Exit fullscreen mode

転送が完了したら、PiKVM上で読み取り専用へ戻します。

kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

公式ドキュメントでも、手動アップロードは次の順番になっています。

  1. kvmd-helper-otgmsd-remount rw
  2. /var/lib/kvmd/msdへファイルを転送
  3. kvmd-helper-otgmsd-remount ro

仮想メディア用パーティションを通常は読み取り専用にすることで、突然の電源断によるデータ破損を防いでいます。


ISOファイルにchown kvmd:kvmdは必要か

SCPで転送したファイルは、通常はroot所有になります。

ls -l /var/lib/kvmd/msd/
Enter fullscreen mode Exit fullscreen mode

例えば、次のように全ユーザーから読み取り可能になっていれば、読み取り専用ISOとして使用するだけなら、必ずしも所有者を変更する必要はありません。

-rw-r--r-- 1 root root ... installer.iso
Enter fullscreen mode Exit fullscreen mode

つまり、次のコマンドをすべてのISOへ機械的に実行する必要はありません。

chown kvmd:kvmd installer.iso
Enter fullscreen mode Exit fullscreen mode

重要なのは、kvmdユーザーがファイルを読み取れることです。必要なら、次のように読み取り権限を設定します。

kvmd-helper-otgmsd-remount rw
chmod 644 /var/lib/kvmd/msd/installer.iso
kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

一方、管理対象マシンから書き込み可能な仮想Flashイメージとして使用する場合は、書き込み権限も必要です。公式ドキュメントの書き込み可能なFlashイメージ作成例では、次のようにchmod 666を設定しています。

chmod 666 /var/lib/kvmd/msd/flash.img
Enter fullscreen mode Exit fullscreen mode

運用方針として所有者を統一したい場合は、次のようにしても構いません。

kvmd-helper-otgmsd-remount rw
chown kvmd:kvmd /var/lib/kvmd/msd/installer.iso
chmod 644 /var/lib/kvmd/msd/installer.iso
kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

ただし、読み取り専用ISOについては「kvmdから読み取れること」が本質であり、chown自体が必須条件ではありません。


10. 仮想メディアから管理対象マシンを起動する

ISOを配置したら、PiKVMのWeb UIを開き、Driveメニューから対象イメージを選択します。

基本的な流れは次のとおりです。

  1. Driveメニューを開く
  2. ISOまたはIMGファイルを選択する
  3. メディア種別を選択する
  4. イメージを接続する
  5. 管理対象マシンを再起動する
  6. BIOSまたはUEFIのブートメニューから仮想メディアを選択する

PiKVMでは、仮想メディアを次のような形式で接続できます。

モード 管理対象マシンからの見え方 主な用途
CD/DVD 光学ドライブ 一般的なOSインストールISO、レスキューISO
Flash USBメモリー UEFIとの相性対策、書き込み可能なファイル交換用イメージ

通常はISOをCD/DVDとして接続します。

ただし、管理対象マシンのUEFI実装によっては、CD/DVDとして接続したイメージをブートデバイスとして認識できない場合があります。その場合は、同じイメージをFlashとして接続すると認識されることがあります。

これはすべての機種で必要な設定ではなく、仮想CD/DVDから起動できない場合の互換性対策です。

PiKVMの仮想メディアはBIOS・UEFIから利用でき、Web UI上でCD/DVDまたはFlashとしての接続方式を変更できます。


仮想メディア利用時の注意

イメージのアップロード中や、書き込み可能な状態で管理対象マシンへ接続している間は、PiKVMの電源を切らないでください。

アップロード中や書き込み中に電源を切ると、イメージファイルやファイルシステムが破損する可能性があります。


11. Ctrl+Alt+Delを送信する

ブラウザーがCtrlAltなどのキー操作をローカル側で処理してしまうことがあるため、特殊なショートカットはPiKVMのWeb UIから送信します。

Ctrl+Alt+Delを送信する場合は、Web UI上部のShortcutsメニューを開き、Ctrl+Alt+Delを選択します。

Shortcutsメニューに目的の操作がない場合は、PiKVMのショートカット用マジックキー機能を使う方法もあります。現在の公式ドキュメントでは、マジックキーを押して離した後、CtrlAltDelを順番に押して離す操作が案内されています。


12. 管理対象マシンへTailscaleを設定する

PiKVMから操作している管理対象マシンにもTailscaleを導入する場合、Linuxでは次のコマンドが便利です。

tailscale up --qr
Enter fullscreen mode Exit fullscreen mode

画面に表示されたQRコードをスマートフォンで読み取り、Tailscaleの認証を完了します。

PiKVMの画面上で長い認証URLを手入力したり、クリップボードを経由したりする必要がないため、OSインストール直後やGUIを利用できない環境に適しています。


作業全体の推奨順序

初回セットアップは、次の順番で進めると手戻りを減らせます。

  1. SDカードへPiKVM OSを書き込む
  2. 起動前にpikvm.txtへWi-Fi情報を設定する
  3. PiKVMを起動してIPアドレスを確認する
  4. SSHでrootとして接続する
  5. Linuxのrootパスワードを変更する
  6. Web UIのadminパスワードを変更する
  7. ホスト名を変更する
  8. 物理アクセス可能な状態でpikvm-updateを実行する
  9. 必要に応じてTailscaleを導入する
  10. ISO・IMGファイルを仮想メディア領域へ配置する
  11. Web UIから管理対象マシンへ接続する
  12. 仮想メディアを接続してOSのインストールや復旧作業を行う

まとめ

PiKVMを扱ううえで最も混乱しやすいのは、書き込みモードの切り替えです。

システム設定を変更する場合は、次の組み合わせを使用します。

rw
# 設定変更
ro
Enter fullscreen mode Exit fullscreen mode

ISOやIMGを配置する場合は、次の組み合わせです。

kvmd-helper-otgmsd-remount rw
# ISO・IMGの配置や削除
kvmd-helper-otgmsd-remount ro
Enter fullscreen mode Exit fullscreen mode

この2種類を区別し、変更後は読み取り専用へ戻すことが、安全にPiKVMを運用するための基本です。

また、初回起動後は必ずLinux側とWeb UI側の両方のパスワードを変更してください。外部からアクセスする場合は、Web UIを直接公開するのではなく、Tailscaleなどのプライベートネットワークを組み合わせると、接続経路を管理しやすくなります。

Top comments (0)