はじめに
Winapps を使って Linux でも MS Office が使えるようになりました。
( Winboat というものもあるようです。)
MS Office がネイティブに Linux 上で動くわけではありません。
仮想化技術( VM )を使って、Windows VM 上の MS Office をリモートデスクトップで、そのウィンドウだけを見て操作しているような状態です。
XfreeRDP(リモートデスクトップ・クライアント)を使うので、X11 を使います。
Wayland についてはこちらのディスカッションを参照してください。
Winapps のバックエンドには Docker、Podman、Virt-manager が利用できますが、3つとも試してみた結果、Docker が一番簡単だったので、Docker での環境構築を説明したいと思います。
必要なもの・技術
- Linux (今回は Debian を利用します)
- X11 ( freeRDP を使います)
- Docker
- Win11 (手順通りやっていけば勝手にインストールできます。長期的に使うならライセンスの購入が必要です)
- MS Office (ライセンスが必要です。今回は MSペイントで代用します)
Windows版 Google Mozc ( https://www.google.co.jp/ime/ 日本語入力に使います)
注意 : Linux で MS Office を試したい場合は Microsoft 365 Personal を利用すると良いでしょう。支払情報の入力が求められますが、30日内に解約すれば無料です。また、5台までインストールできるので、Windows と Linux のデュアルブート、トリプルブートでも利用することができます。
環境構築
Debian Linux のインストールは既に済んでいるものとします。
設定はこちらに従って説明していきます。
Docker の準備
Docker のインストールはディストリビューションごとに Docker の公式ページに従います。
レポジトリの追加
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyriMyWindowsUserngs/docker.asc
# Add the repository to Apt sources:
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
Docker のインストール
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
docker のグループに自らを追加します。
sudo /sbin/usermod -a -G docker ユーザ名
グループに入りなおすため一度再起動します。
Winapps の依存関係のインストール
sudo apt install -y wget curl dialog freerdp3-x11 git iproute2 libnotify-bin netcat-openbsd
compose.yaml の設定
mkdir -p ~/.config/winapps
cd ~/.config/winapps
wget https://raw.githubusercontent.com/winapps-org/winapps/refs/heads/main/compose.yam
Docker VM のもとになる compose.yaml は次のようになっています。
Docker、Podman、Virt-manager 共通のファイルになっているので、不必要な部分もありますので、少し変更を加えます。
# For documentation, FAQ, additional configuration options and technical help, visit: https://github.com/dockur/windows
name: "winapps" # Docker Compose Project Name.
volumes:
# Create Volume 'data'.
# Located @ '/var/lib/docker/volumes/winapps_data/_data' (Docker).
# Located @ '/var/lib/containers/storage/volumes/winapps_data/_data' or '~/.local/share/containers/storage/volumes/winapps_data/_data' (Podman).
data:
services:
windows:
image: ghcr.io/dockur/windows:latest
container_name: WinApps # Created Docker VM Name.
environment:
# Version of Windows to configure. For valid options, visit:
# https://github.com/dockur/windows?tab=readme-ov-file#how-do-i-select-the-windows-version
# https://github.com/dockur/windows?tab=readme-ov-file#how-do-i-install-a-custom-image
VERSION: "11"
RAM_SIZE: "4G" # RAM allocated to the Windows VM.
CPU_CORES: "4" # CPU cores allocated to the Windows VM.
DISK_SIZE: "64G" # Size of the primary hard disk.
# DISK2_SIZE: "32G" # Uncomment to add an additional hard disk to the Windows VM. Ensure it is mounted as a volume below.
USERNAME: "MyWindowsUser" # Edit here to set a custom Windows username. The default is 'MyWindowsUser'.
PASSWORD: "MyWindowsPassword" # Edit here to set a password for the Windows user. The default is 'MyWindowsPassword'.
HOME: "${HOME}" # Set path to Linux user home folder.
ports:
- 8006:8006 # Map '8006' on Linux host to '8006' on Windows VM --> For VNC Web Interface @ http://127.0.0.1:8006.
- 3389:3389/tcp # Map '3389' on Linux host to '3389' on Windows VM --> For Remote Desktop Protocol (RDP).
- 3389:3389/udp # Map '3389' on Linux host to '3389' on Windows VM --> For Remote Desktop Protocol (RDP).
cap_add:
- NET_ADMIN # Add network permission
stop_grace_period: 120s # Wait 120 seconds before sending SIGTERM when attempting to shut down the Windows VM.
restart: on-failure # Restart the Windows VM if the exit code indicates an error.
volumes:
- data:/storage # Mount volume 'data' to use as Windows 'C:' drive.
- ${HOME}:/shared # Mount Linux user home directory @ '\\host.lan\Data'.
#- /path/to/second/hard/disk:/storage2 # Uncomment to create a virtual second hard disk and mount it within the Windows VM. Ensure 'DISK2_SIZE' is specified above.
- ./oem:/oem # Enables automatic post-install execution of 'oem/install.bat', applying Windows registry modifications contained within 'oem/RDPApps.reg'.
#- /path/to/windows/install/media.iso:/custom.iso # Uncomment to use a custom Windows ISO. If specified, 'VERSION' (e.g. 'tiny11') will be ignored.
devices:
- /dev/kvm # Enable KVM.
- /dev/net/tun # Enable tuntap
# Uncomment to mount a disk directly within the Windows VM.
# WARNING: /dev/sdX paths may change after reboot. Use persistent identifiers!
# NOTE: 'disk1' will be mounted as the main drive. THIS DISK WILL BE FORMATTED BY DOCKER.
# All following disks (disk2, ...) WILL NOT BE FORMATTED.
# - /dev/disk/by-id/<id>:/disk1
# - /dev/disk/by-id/<id>:/disk2
# group_add: # uncomment this line and the next one for using rootless podman containers
# - keep-groups # to make /dev/kvm work with podman. needs "crun" installed, "runc" will not work! Add your user to the 'kvm' group or another that can access /dev/kvm.
- | デフォルト値 | 説明 |
name | winapps | VM の名前です |
VERSION | 11 | Windows のバージョンです |
RAM_SIZE | 4G | VM の利用するメモリサイズです。VMを起動するとこの値だけメモリが使用されます |
CPU_CORES | 4 | VM の利用する CPUコア数です |
DISK_SIZE | 64G | VM のストレージ容量です |
USERNAME | MyWindowsUser | Windows のログインに使うユーザー名です |
PASSWORD | MyWindowsPassword | Windows のログインに使うパスワードです |
USERNAME と PASSWORD 以外は特に変更する必要はないと思います。
パスワード情報もありますので、ファイルの読み取り権限を自分だけにしておきましょう。
chmod 600 compose.yaml
Docker compose
Docker VM の作成。
docker compose --file compose.yaml up
30分くらいかかるので、先に Winapps の設定ファイルを作りましょう。
20分くらいしたら、下記のような画面が表示されます。
WinApps |
WinApps | ❯ Extracting Windows 11 image...
WinApps | ❯ Adding drivers to image...
WinApps | ❯ Adding OEM folder to image...
WinApps | ❯ Adding win11x64.xml for automatic installation...
WinApps | ❯ Building Windows 11 image...
WinApps | ❯ Creating a 64 GB growable disk image in raw format...
WinApps | ❯ Booting Windows using QEMU v10.0.3...
WinApps | BdsDxe: skipped Boot0002 "UEFI QEMU QEMU HARDDISK " from PciRoot(0x0)/Pci(0xA,0x0)/Scsi(0x0,0x0)
WinApps | BdsDxe: loading Boot0001 "UEFI QEMU DVD-ROM QM00013 " from PciRoot(0x0)/Pci(0x5,0x0)/Sata(0x0,0xFFFF,0x0)
WinApps | BdsDxe: starting Boot0001 "UEFI QEMU DVD-ROM QM00013 " from PciRoot(0x0)/Pci(0x5,0x0)/Sata(0x0,0xFFFF,0x0)
WinApps | ❯ Windows started successfully, visit http://127.0.0.1:8006/ to view the screen...
ブラウザで http://127.0.0.1:8006/ を開くと、Windows のインストール画面が見れます。
しばらくするといつもの Windows 画面が表示されます。
時計がズレていたりや画面表示が英語など直したい部分はありますが、今のところはサインアウトしておいて次に進みましょう。
(画面表示を日本語にしてしまうと、Winapps のスクリプトが止まってしまうことがあります。わたしが Virt-manager を利用したときには日本語版 Windows のイメージを利用したため、それではまりました。)
サインアウトしておかないと、Winapp のインストラーが止まってしまうので注意してください。
winapps.conf の作成
winapps.conf ファイルは次のようになっています。
コピーして、~/.config/winapps/winapps.conf を作成してください。
##################################
# WINAPPS CONFIGURATION FILE #
##################################
# INSTRUCTIONS
# - Leading and trailing whitespace are ignored.
# - Empty lines are ignored.
# - Lines starting with '#' are ignored.
# - All characters following a '#' are ignored.
# [WINDOWS USERNAME]
RDP_USER="MyWindowsUser"
# [WINDOWS PASSWORD]
# NOTES:
# - If using FreeRDP v3.9.0 or greater, you *have* to set a password
RDP_PASS="MyWindowsPassword"
# [WINDOWS DOMAIN]
# DEFAULT VALUE: '' (BLANK)
RDP_DOMAIN=""
# [WINDOWS IPV4 ADDRESS]
# NOTES:
# - If using 'libvirt', 'RDP_IP' will be determined by WinApps at runtime if left unspecified.
# DEFAULT VALUE:
# - 'docker': '127.0.0.1'
# - 'podman': '127.0.0.1'
# - 'libvirt': '' (BLANK)
RDP_IP="127.0.0.1"
# [VM NAME]
# NOTES:
# - Only applicable when using 'libvirt'
# - The libvirt VM name must match so that WinApps can determine VM IP, start the VM, etc.
# DEFAULT VALUE: 'RDPWindows'
VM_NAME="RDPWindows"
# [WINAPPS BACKEND]
# DEFAULT VALUE: 'docker'
# VALID VALUES:
# - 'docker'
# - 'podman'
# - 'libvirt'
# - 'manual'
WAFLAVOR="docker"
# [DISPLAY SCALING FACTOR]
# NOTES:
# - If an unsupported value is specified, a warning will be displayed.
# - If an unsupported value is specified, WinApps will use the closest supported value.
# DEFAULT VALUE: '100'
# VALID VALUES:
# - '100'
# - '140'
# - '180'
RDP_SCALE="100"
# [MOUNTING REMOVABLE PATHS FOR FILES]
# NOTES:
# - By default, `udisks` (which you most likely have installed) uses /run/media for mounting removable devices.
# This improves compatibility with most desktop environments (DEs).
# ATTENTION: The Filesystem Hierarchy Standard (FHS) recommends /media instead. Verify your system's configuration.
# - To manually mount devices, you may optionally use /mnt.
# REFERENCE: https://wiki.archlinux.org/title/Udisks#Mount_to_/media
REMOVABLE_MEDIA="/run/media"
# [ADDITIONAL FREERDP FLAGS & ARGUMENTS]
# NOTES:
# - You can try adding /network:lan to these flags in order to increase performance, however, some users have faced issues with this.
# If this does not work or if it does not work without the flag, you can try adding /nsc and /gfx.
# DEFAULT VALUE: '/cert:tofu /sound /microphone +home-drive'
# VALID VALUES: See https://github.com/awakecoding/FreeRDP-Manuals/blob/master/User/FreeRDP-User-Manual.markdown
RDP_FLAGS="/cert:tofu /sound /microphone +home-drive"
# [DEBUG WINAPPS]
# NOTES:
# - Creates and appends to ~/.local/share/winapps/winapps.log when running WinApps.
# DEFAULT VALUE: 'true'
# VALID VALUES:
# - 'true'
# - 'false'
DEBUG="true"
# [AUTOMATICALLY PAUSE WINDOWS]
# NOTES:
# - This is currently INCOMPATIBLE with 'manual'.
# DEFAULT VALUE: 'off'
# VALID VALUES:
# - 'on'
# - 'off'
AUTOPAUSE="off"
# [AUTOMATICALLY PAUSE WINDOWS TIMEOUT]
# NOTES:
# - This setting determines the duration of inactivity to tolerate before Windows is automatically paused.
# - This setting is ignored if 'AUTOPAUSE' is set to 'off'.
# - The value must be specified in seconds (to the nearest 10 seconds e.g., '30', '40', '50', etc.).
# - For RemoteApp RDP sessions, there is a mandatory 20-second delay, so the minimum value that can be specified here is '20'.
# - Source: https://techcommunity.microsoft.com/t5/security-compliance-and-identity/terminal-services-remoteapp-8482-session-termination-logic/ba-p/246566
# DEFAULT VALUE: '300'
# VALID VALUES: >=20
AUTOPAUSE_TIME="300"
# [FREERDP COMMAND]
# NOTES:
# - WinApps will attempt to automatically detect the correct command to use for your system.
# DEFAULT VALUE: '' (BLANK)
# VALID VALUES: The command required to run FreeRDPv3 on your system (e.g., 'xfreerdp', 'xfreerdp3', etc.).
FREERDP_COMMAND=""
# [TIMEOUTS]
# NOTES:
# - These settings control various timeout durations within the WinApps setup.
# - Increasing the timeouts is only necessary if the corresponding errors occur.
# - Ensure you have followed all the Troubleshooting Tips in the error message first.
# PORT CHECK
# - The maximum time (in seconds) to wait when checking if the RDP port on Windows is open.
# - Corresponding error: "NETWORK CONFIGURATION ERROR" (exit status 13).
# DEFAULT VALUE: '5'
PORT_TIMEOUT="5"
# RDP CONNECTION TEST
# - The maximum time (in seconds) to wait when testing the initial RDP connection to Windows.
# - Corresponding error: "REMOTE DESKTOP PROTOCOL FAILURE" (exit status 14).
# DEFAULT VALUE: '30'
RDP_TIMEOUT="30"
# APPLICATION SCAN
# - The maximum time (in seconds) to wait for the script that scans for installed applications on Windows to complete.
# - Corresponding error: "APPLICATION QUERY FAILURE" (exit status 15).
# DEFAULT VALUE: '60'
APP_SCAN_TIMEOUT="60"
# WINDOWS BOOT
# - The maximum time (in seconds) to wait for the Windows VM to boot if it is not running, before attempting to launch an application.
# DEFAULT VALUE: '120'
BOOT_TIMEOUT="120"
# FREERDP RAIL HIDEF
# - This option controls the value of the `hidef` option passed to the /app parameter of the FreeRDP command.
# - Setting this option to 'off' may resolve window misalignment issues related to maximized windows.
# DEFAULT VALUE: 'on'
HIDEF="on"
- | デフォルト値 | 説明 |
RDP_USER | MyWindowsUser | Windows にログインするアカウント名です |
RDP_PASS | MyWindowsPassword | Windows のパスワードです |
RDP_FLAGS | /cert:tofu /sound /microphone +home-drive | /printer を追加しておくと、ホストのプリンターが利用できるようになります。+clipboard を追加すると、ホストとクリップボードが共有できます |
Winapps インストーラーの実行
別のターミナルを開いて次のコマンドを実行します。
bash <(curl https://raw.githubusercontent.com/winapps-org/winapps/main/setup.sh)
Install → Current User → Manual とエンターを押していきます。
問題がなければ、アプリの設定に入ります。
アプリの設定
問題がなければエンターを押していきます。
これで Debian側でのアプリの設定ができました。
ファイル PATH は ~/.local/bin ですので、ターミナルからアプリを実行したい場合は PATH を追加してください。
~/.local/bin にコピーされていない Windowsアプリも実行が可能です。
例えば、Kindle for PC だと次のように実行します。
winapp manual 'C:\Program Files (x86)\Amazon\Kindle\Kindle.exe'
残念ながら Kindle for PC は今のところ単体のアプリとしては起動はしますが、表示ができません。
画面左中央には Windows というアプリもあります。今まではブラウザから入っていましたが、この Windowsアプリで Windowsの画面を呼び出すことも可能です。
日本語の設定
ここでは Windows の日本語化と時計設定をおこないます。
Windowsアプリを開いて、Settings → Time & language → Language & regison を開きます。
Add a language をクリックして 日本語 を追加します。
Set as my Windows display language にチェックを入れて Install をクリックします。
しばらく時間がかかりますので、Google 日本語入力をインストールしましょう。
あと Country or region も Japan に変更しておきましょう。
日本語言語パックのインストールが完了したら、Windows display language も日本語にしておきましょう。
Google 日本語入力の設定 MS IME も使えます
Windowsで https://www.google.co.jp/ime/ にアクセスして Windows版 Mozc をダウンロード&インストールします。
たぶん MS IME も使えますので、 は使えないので(使える方法があれば教えてください)、 Mozc あるいは MS IME のショートカットキーを設定します。
Settings → Time & language → Typing → Advanced keyboard settings → Input language hot keys をクリックします。
To Japanese (Japan) - Google Japanese Input を選択し、Enable Key Sequence にチェックを入れ、OK を押します。 MS IME も同様に Enable Key Sequence にチェックを入れ、ショートカットキーを有効にすると使えます。
これで Winapps で起動した Windowsアプリの日本語入力が Ctrl + Shift + 0 あるいは 1 の後、シフト + Caps で日本語入力が有効になります。
でおこなえるようになったはずですが、有効にするには何度も押さなければならなかったりします。
時計設定
Settings → Time & Language → Date & time へ移動し、Time zone を (UTC+9:00) Osaka, Sapporo, Tokyo に変更し、Set time automatically を Off にし、シャットダウンします。
MSペイントの実行
Winapps を起動するには、MS Office や MSペイントの実行前に次のコマンドで VM を実行しておく必要があります。
docker compose --file ~/.config/winapps/compse.yaml up
VM を止める場合は次の通りです。
docker compose --file ~/.config/winapps/compse.yaml down
それでは mspaint を実行してみましょう。
テキストツールを有効にして、Ctrl + Shift + 0 あるいは 1 を押したあと、シフト + Cpas で日本語が入力できるようになります。
※ ここまで来ておいて、mspaint が起動しなかったので、もういちど Winapps インストーラーの実行 をおこないました。アンインストールは次のコマンドでおこなうことができます。
winaspps-setup --user --uninstall
その他の設定
Windows のデフォルトの設定ではウィンドウの自動リサイズや配置が働いてしまって、うまく操作できない場合があるので、ウィンドウのスナップを無効にしておきましょう。
設定 → システム → マルチタスク → ウィンドウのスナップ を無効にします。
Debian 側の設定
Settings → Ubuntu Desktop → Enhanced Tiling を無効化。
dconf write /org/gnome/muter/edge-tiling false
gnome-extensions disable tiling-assistant@ubuntu.com
また、Windowsアプリが画面最大化してしまって閉じられない場合があるかと思います。
そんな場合はまずは大切なファイルを Altキー等や Ctrl + S で保存してから、Alt + F7 でウィンドウを移動したり、Alt + F8 でリサイズしたり、Alt + F4 でアプリを終了するか、ターミナルから次のコマンドで Windows を終了してください。
docker compose --file ~/.config/winapps/compose.yaml down
参考文献