Linux あれこれ

Linux 関連(一部 Windows11 )の備忘録です。

「Xubuntu 22.04 LTS」で、「VirtualBox 7.0.14」と「Vagrant 2.4.1」にアップデート〈H170-7〉

登録日: 2024-02-05 更新日: 2024-04-20

現在、「Xubuntu 22.04 LTS」のPC で使っている仮想環境は、「VirtualBox 7.0.10」で「Vagrant 2.4.0」を使っています。

-

最新の「VirtualBox 7.0.14」と「Vagrant 2.4.1」が公開されたので、
アップデート(上書きインストール)しました。

その備忘録です。

-

前回、リポジトリを登録して「VirtualBox」と「Vagrant」をインストールしている場合は、こちらの作業は要りません。

-

-

-

使用したPC は「ASUS Chromebox CN60 」で、 プロセッサは第4世代の「Intel Celeron 2955U 」です。

UEFI 立ち上げ」のPC です。

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック
スマホの場合は、「ホーム」ボタンの横の「<」キーをタップ

-

-


目次

-

参考:

  1.  修正版: 「Vagrant」で使い回し可能な「Vagrantfile」:

  2. 「仮想マシン」にて「GuestAdditions」を再インストール:

  3. 「仮想マシン」にて、ログイン時の「エラー通知」の解消、および、「クリップボード共有」機能の改善で行ったこと:

  4. 「仮想マシン」にて「GuestAdditions」の再インストールで成功したことで気づいたこと:

  5.  Vagrant に「vagrant-vbguest」プラグインをインストール:

-

今回の作業:

  1. 「VirtualBox 7.0.14」をダウンロード:

  2. 「VirtualBox 7.0.14」をインストール:

  3. 「VirtualBox Extension Pack」をインストール:

  4. 「Vagrant 2.4.1」をダウンロード:

  5. 「Vagrant 2.4.1」をインストール:

  6. 「仮想マシン」にて「GuestAdditions」を再インストール:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

Xubuntu 22.04 LTS」を起動:

-


インストールした最新の「VirtualBox 7.0.14」を起動:

ヘルプ →「VirtualBox について」:

-

-


最新の「VirtualBox 7.0.14」にて、「仮想マシン」のOpenbox で「リアルタイムの解像度調整」が有効になりました:

→「仮想マシン」を「vmsvga」に設定してから、ウィンドウの右下隅をドラッグして広げると、リアルタイムに解像度が調整され、壁紙が変化しました。なので「Welcome」画面は置いてけぼりです。

-

最新の「VirtualBox 7.0.14」にしたからだけでなく、その他のこと も合わせて行ったから改善されたと思われます:

-

-


現在のバージョンを表示:

-

ホストOS : 「Xubuntu 22.04.3 LTS」

2024-02-05 現在

カーネル:

$ uname -r
5.15.0-92-generic

リリース:

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"

→「Xubuntu 22.04.3 LTS」にアップしています。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

VirtualBox」について:

-

VirtualBox 」は、Oracle が開発している「仮想マシン」を構築するためのソフトウェアです。

-

  • 「VirtalBox」は「仮想的なパソコン」(仮想デバイス)を実現するソフトウェアです。別のパソコンに「Linux」をインストールするのと変わりません。

  • 仮想マシンを使うことで、ハードウェアで問題となりそうなPC でも、最新のLinux ディストリビューションをインストールできる可能性が高くなります。

  • 問題があっても、Linux の情報をそのまま使えるのが強みです。

-

ホストOS とゲストOS でメモリを分割して使うので、メモリのサイズと割当て方は重要です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

1. 「VirtualBox 7.0.10」のゲストOS をすべて、電源オフ:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

2. 「Xubuntu 22.04 LTS」に、最新の「VirtualBox 7.0.14」をインストール:

-

参考:

「Xubuntu 22.04 LTS」で、「VirtualBox 7.0.10」へアップデート〈H169〉

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

2-1. 最新の「VirtualBox 7.0.14」をダウンロード:

-

1). Ubuntu の「コード名」を確認:

$ cat /etc/lsb-release
:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy          ←(コード名)
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"

Xubuntu(フレーバー違い)で使用するイメージファイルは「Ubuntu」と同じです。

-

2). ブラウザで下記を開きました:

Index of /virtualbox/7.0.14/

-

3). 「VirtualBox」のダウンロード:

使用しているホストOS の種類とリリース番号によって、ファイルを選びました:

サイトの一番下にある、

virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb をクリック:

→ファイルを「~/ダウンロード/virtualbox/」フォルダに移動

-

4). 「VirtualBox Extension Pack」のダウンロード:

サイトの上にある、

Oracle_VM_VirtualBox_Extension_Pack-7.0.14-161095.vbox-extpack

→ファイルを「~/ダウンロード/virtualbox/」フォルダに移動しました

-

インストールを行う「VirtualBox」のバージョンと同じバージョンの「拡張パック」をダウンロードしてインストールします:

-

5). 「チェックサム」のダウンロード:

SHA256SUMS

→ブラウザで下記が表示されました:

42cb36fbf439a9ed28c95d2bbc718a0eac902225eb579c884c549af2e94be633 *Oracle_VM_VirtualBox_Extension_Pack-7.0.14-161095.vbox-extpack
:
43aa0932f73433e7a6b450a82708d275ee5f2c98375cfa708a46ecf75b3d4edc *virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb

-

6). 「チェックサム」の確認:

$ cd ~/ダウンロード/virtualbox/

-

$ ls -1
Oracle_VM_VirtualBox_Extension_Pack-7.0.14-161095.vbox-extpack
virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb

-

(1). 「VirtualBox」の確認:
$ sha256sum virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb
43aa0932f73433e7a6b450a82708d275ee5f2c98375cfa708a46ecf75b3d4edc  virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb

-

(2). 「VirtualBox Extension Pack」の確認:
$ sha256sum Oracle_VM_VirtualBox_Extension_Pack-7.0.14-161095.vbox-extpack
42cb36fbf439a9ed28c95d2bbc718a0eac902225eb579c884c549af2e94be633  Oracle_VM_VirtualBox_Extension_Pack-7.0.14-161095.vbox-extpack

-

(3). ホームに移動:
$ cd

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

2-2. 「VirtualBox 7.0.14」をインストール:

-

1). システム更新:

$ sudo apt update
[sudo] パスワード: 
ヒット:1 https://cli.github.com/packages stable InRelease
ヒット:2 http://security.ubuntu.com/ubuntu jammy-security InRelease       
ヒット:3 http://jp.archive.ubuntu.com/ubuntu jammy InRelease              
ヒット:4 http://jp.archive.ubuntu.com/ubuntu jammy-updates InRelease    
ヒット:5 http://jp.archive.ubuntu.com/ubuntu jammy-backports InRelease
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了
状態情報を読み取っています... 完了        
パッケージはすべて最新です。

→ 1行目は個人的に追加したリポジトリなので、通常は表示されません。

-

$ sudo apt upgrade
パッケージリストを読み込んでいます... 完了
依存関係ツリーを作成しています... 完了        
状態情報を読み取っています... 完了        
アップグレードパッケージを検出しています... 完了
Get more security updates through Ubuntu Pro with 'esm-apps' enabled:
  libvlc5 exo-utils vlc-data libvlccore9 libopusfile0 libopenexr25
  libpostproc55 libavcodec58 libavutil56 libswscale5 libexo-2-0 libswresample3
  vlc-plugin-video-output libavformat58 libvlc-bin vlc-plugin-base
  libexo-common libavfilter7
Learn more about Ubuntu Pro at https://ubuntu.com/pro
アップグレード: 0 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。

→「アップグレード:」の行が、すべて 0 かを確認:

その上の数行ある「Ubuntu Pro」関連の表示は、今回は無視

-

2). 「dkms」のインストール:

カーネルの更新があっても自動で依存(カーネルヘッダー等)を解決してもらえます:

$ sudo apt install dkms
:
dkms はすでに最新バージョン (2.8.7-2ubuntu2.2) です。

-

注意:「.deb」ファイルから「VirtualBox」をインストールする場合は、「dkms」でなく、「virtualbox-dkms」をインストールしてはいけません:

apt で「VirtualBox」をインストールする場合に、「virtualbox-dkms」はインストールします:

-

3). 再起動:

「端末」以外のすべてのウィンドウを閉じてから、

$ reboot

-

4). 立ち上がったら、ファイルを確認:

$ cd ~/ダウンロード/virtualbox/

-

$ ls -1
Oracle_VM_VirtualBox_Extension_Pack-7.0.14-161095.vbox-extpack
virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb

-

5). 「.deb」ファイルから「VirtualBox」をインストール:

$ sudo chown _apt /var/lib/update-notifier/package-data-downloads/partial/

-

$ cd ~/ダウンロード/virtualbox/
$ sudo apt install ./virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb
:
以下のパッケージはアップグレードされます:
  virtualbox-7.0
アップグレード: 1 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
:
.../virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb を展開する準備をし
ています ...
virtualbox-7.0 (7.0.14-161095~Ubuntu~jammy) で (7.0.10-158379~Ubuntu~jammy 
に) 上書き展開しています ...
virtualbox-7.0 (7.0.14-161095~Ubuntu~jammy) を設定しています ...
addgroup: グループ `vboxusers' はシステムグループとしてすでに存在しています
。終了します。
:

→パッケージ名が「virtualbox-7.0」でインストールされました

-

ちなみに、「sudo chown _apt ...」は下記の警告が表示されるので、その回避策です:
N: ファイル '/home/ubn/ダウンロード/virtualbox/virtualbox-7.0_7.0.14-161095~Ubuntu~jammy_amd64.deb' がユーザ '_apt' からアクセスできないため、ダウンロードは root でサンドボックスを通さずに行われます。 - pkgAcquire::Run (13: 許可がありません)

→これは既知のバグです (This is a known bug)

-

6). インストールされたか確認:

$ apt search virtualbox-7.0
virtualbox-7.0/now 7.0.14-161095~Ubuntu~jammy amd64 [インストール済み、ローカル]
  Oracle VM VirtualBox

→「ローカル」の表示に注目:

-

コマンドでバージョンを確認:
$ VBoxManage --version
7.0.14r161095

-

7). 「VirtualBox 7.0.14」を起動して確認:

メニュー →「システム」→「Oracle VM VirtualBox

-

ヘルプ →「VirtualBox について」:

-

ヘルプ表示を確認:

VirtualBox グラフィカルユーザーインターフェース
バージョン 7.0.14 r161095 (Qt5.15.3)

→「閉じる」

-

8). ホストOS のログイン時のユーザが「vboxusers」グループに追加されているか確認:

-

「USB 機能」を使えるようにするには、「VirtualBox」のインストール後に「vboxusers」グループに、現在使用しているユーザを追加します:

ちなみに、VirtualBox インストーラは、「Oracle VM VirtualBox」に必要な USB 機能をサポートするため、「VirtualBox」のインストール中にシステムユーザグループ「vboxusers」を作成します。

VirtualBox ゲスト OS から USB デバイスを使用するシステム ユーザは、このグループに参加する必要があります。

VirtualBox」のインストール後にカーネルの更新があると、この「vboxusers」グループへの参加が解除される場合があります。

-

(1). 現在、ログイン時のユーザが属するグループを確認:
$ id
uid=1000(ubn) gid=1000(ubn) groups=1000(ubn),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),132(lxd),133(sambashare)

もしくは、

$ id ubn
uid=1000(ubn) gid=1000(ubn) groups=1000(ubn),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),132(lxd),133(sambashare)

→「ubn」はユーザ名で任意です

-

「vboxusers」グループが含まれていれば(リスクの高い)下記の操作は要りません:

-

(2). 含まれていなかったので、ログイン時のユーザを「vboxusers」グループに追加しました:

このコマンドは誤入力するとリスクが高いので、慎重に入力:

$ sudo usermod -a -G vboxusers ubn

→「ubn」はユーザ名で任意です

「-a -G」は「-aG」と入力できますが、入力漏れを防ぐために、わざと分けています:

-

「-a -G」または「-aG」を「-G」と入力すると新規作成になり、「vboxuser」以外に属していた他のグループが消えてしまい、「sudo」が使えなくなり、最悪(今回は、ホスト側の)OS の再インストールになります。入力時は注意。

-

(3). 再起動後に、ログイン時のユーザが属するグループを確認:

「端末」以外のすべてのウィンドウを閉じてから、

$ reboot

-

$ id
uid=1000(ubn) gid=1000(ubn) groups=1000(ubn),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),132(lxd),133(sambashare),138(vboxusers)

→「vboxusers」グループが追加されました

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

2-3. 任意:「VirtualBox Extension Pack」をインストール:

-

続けて、機能拡張パッケージをインストールしました。

作業は任意です。

-

→「項番 2-1. 4).」で、インストールされている VirtualBox のバージョンと同じバージョンの「拡張パック」をすでにダウンロード済みです:

-


1). 拡張パックで提供される追加機能:

→リモートで使うなら必要だけど、必要がなければ要らない機能です。

-

2). ファイルマネージャで、「~/ダウンロード/virtualbox/」フォルダを開きます:

フォルダ名は任意なので変わります。

-

3). ダウンロードした、緑色で四角のアイコンの「Oracle_VM_VirtualBox_Extension_Pack-7.0.14-161095.vbox-extpack」をダブルクリック:

virtualbox」(「VirtualBox」マネージャ)をインストールしたことで使える機能です:

-

4). 「VirtualBox」マネージャが起動されて、ダイアログが表示:

古いバージョンの機能拡張パッケージがインストールされています。アップグレードしますか?

→「アップグレード」をクリック

-

5). ライセンス画面が表示:

一番下までスクロール:

→「同意します」をクリック

→パスワード入力:

-

6). 「VirtualBox」マネージャの画面に戻りました:

-

7). 「機能拡張」がインストールされたか確認:

左側の「ツール」をクリックして、その右側の「横3本線」ボタンをクリック→「機能拡張」

-

「機能拡張」がインストールされたか確認できます:

→バージョンを確認:

-

左側の「ツール」の右側の「横3本線」ボタンをクリック→「ようこそ」

→元の画面に戻りました:

-

仮想マシン」のひとつをクリック:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

3. 「Xubuntu 22.04 LTS」に、最新の「Vagrant 2.4.1」をインストール:

-

参考:

Vagrant 実践編1:「Ubuntu 22.04」の「仮想マシン」作成と「Box」の共有〈H170-2〉

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

3-1. 最新の「Vagrant 2.4.1」をダウンロード:

-

1). 最新の「Vagrant」をダウンロード:

ダウンロードのサイト:

-

vagrant_2.4.1-1_amd64.deb

vagrant_2.4.1_SHA256SUMS

-

2). チェックサムが同じか確認:

$ cd ~/ダウンロード/
$ sha256sum vagrant_2.4.1-1_amd64.deb
7d379e99eb757b81f31993634b34a3317d2b79607e2a20dab9b7071f4b278810  vagrant_2.4.1-1_amd64.deb

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

3-2. 「Vagrant 2.4.1」をインストール:

-

1). 「.deb」ファイルから「Vagrant」をインストール:

$ sudo chown _apt /var/lib/update-notifier/package-data-downloads/partial/

-

$ cd ~/ダウンロード/
$ sudo apt install ./vagrant_2.4.1-1_amd64.deb
:
以下のパッケージはアップグレードされます:
  vagrant
アップグレード: 1 個、新規インストール: 0 個、削除: 0 個、保留: 0 個。
:
.../vagrant_2.4.1-1_amd64.deb を展開する準備をしています ...
vagrant (2.4.1-1) で (2.4.0-1 に) 上書き展開しています ...
vagrant (2.4.1-1) を設定しています ...

-

ちなみに、「sudo chown _apt ...」は、インストール時に下記の警告が表示されるので、その回避策です:
N: ファイル '/home/ubn/ダウンロード/vagrant_2.4.1-1_amd64.deb' がユーザ '_apt' からアクセスできないため、ダウンロードは root でサンドボックスを通さずに行われます。 - pkgAcquire::Run (13: 許可がありません)

→これは既知のバグです (This is a known bug)

-

2). インストールされたか確認:

$ apt list vagrant -a
vagrant/now 2.4.1-1 amd64 [インストール済み、ローカル]
vagrant/jammy,jammy 2.2.19+dfsg-1ubuntu1 amd64

→「ローカル」の表示に注目:

-

バージョンを確認:
$ vagrant --version
Vagrant 2.4.1

-

3). ホストOS を再起動:

「端末」以外のすべてのウィンドウを閉じてから、

$ reboot

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -

4. 「Vagrant」で「仮想マシン」を立ち上げて確認:

-

1). 「仮想マシン」の立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant up

-

2). 「仮想マシン」が立ち上がったら、「ssh 接続」:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

3). 作成した「mine」ユーザで操作:

[vagrant@vagrant ~]$ su - mine
Password:     ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

4). sudo が使えるか確認:

[mine@vagrant ~]$ sudo date
[sudo] password for mine:      ←(mine ユーザを作成したときのパスワード)
2024年  2月  5日 月曜日 09:21:59 JST

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- --

5. 「仮想マシン」にて「GuestAdditions」を再インストール:

-

「GuestAdditions」を再インストールする手順は「こちら」を参照:

再インストールは、「仮想マシン」の端末から実行しました。

-

→結果が改善。「クリップボードの共有機能」が有効になりました:

-

1). 再インストール後の確認:

-

(1). ホストOS の再起動後、GUI の「ログイン」画面で、ログイン

→デスクトップ画面表示のときに、一瞬だけ表示される、下記のエラー通知が表示されなくなりました:

VBoxClient: the VirtualBox kernel service is not running. Exiting.

-

(2). Windows+Enter で「端末」を起動:
[mine@vagrant ~]$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos
(3). 上記の表示を、マウスで範囲選択 →右クリック→「コピー」を選ぶか「C」キー

-

(4). ホストOS のテキストエディタで、Ctrl+V 、または、マウスの中央ボタンで貼付け:
[mine@vagrant ~]$ ls
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos

→上記がテキストファイルに貼付けできました

-

(5). 「仮想マシン」の「端末」にて動作を確認:

-

仮想マシン」のホームを確認:
[mine@vagrant ~]$ ls -1Ap
.Xauthority
.anthy/
.bash_history
.bash_logout
.bash_profile
.bashrc
.cache/
.config/
.dmrc
.gtkrc-2.0
.local/
.mozilla/
.themes/
.vboxclient-clipboard-tty7-control.pid          ←(動作しました)
.vboxclient-clipboard-tty7-service.pid          ←(動作しました)
.vboxclient-display-svga-x11-tty7-control.pid   ←(動作しました)
.vboxclient-display-svga-x11-tty7-service.pid   ←(動作しました)
.vboxclient-draganddrop-tty7-control.pid        ←(動作しました)
.vboxclient-draganddrop-tty7-service.pid        ←(動作しました)
.vboxclient-hostversion-tty7-control.pid        ←(動作しました)
.vboxclient-seamless-tty7-control.pid           ←(動作しました)
.vboxclient-seamless-tty7-service.pid           ←(動作しました)
.vboxclient-vmsvga-session-tty7-control.pid     ←(動作しました)
.xprofile
.xsession-errors
.xsession-errors.old
Desktop/
Documents/
Downloads/
Music/
Pictures/
Public/
Templates/
Videos/

-

仮想マシン」の id を確認:
[mine@vagrant ~]$ id
uid=1001(mine) gid=1001(mine) groups=1001(mine),3(sys),981(rfkill),998(wheel)

-

(6). 「ホストOS」の「端末」にて確認:
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ id
uid=1000(ubn) gid=1000(ubn) groups=1000(ubn),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),122(lpadmin),132(lxd),133(sambashare),138(vboxusers)

→「vboxusers」に注目:

「vboxusers」グループは、ホストOS に接続された「USB」デバイスをゲストOS で認識するときに必要です

なので、「クリップボードの共有機能」とは直接関係ないみたいな気がします

-

-


2). 「エラー通知」の解消、および、「クリップボード共有」機能の改善で行ったこと:

たぶん、「エラー通知」の解消で「クリップボード機能」が改善されたと思います:

-

ホストOS 側:
  1. 「ホストOS」のシステム更新で、たまたま、「カーネルの更新」があったこと:

  2. VirtualBox 7.0.14」と「VirtualBox Extension Pack」のアップデート:

  3. Vagrant 2.4.1」にアップデート:

  4. 「vboxusers」グループをログインユーザに追加:

-

仮想マシン」側:
  1. 仮想マシン」のシステム更新で、たまたま、「カーネルの更新」があったこと:

  2. 仮想マシン」にて「GuestAdditions」のビルドのためのツールを再インストール:

  3. 仮想マシン」にて「GuestAdditions」を再インストール:

-

  • すべての作業完了後に、ホストOS の再起動:

-

行った項目が多すぎて、どれが有効だったか、わかりません:

わかっているのは、「仮想マシン」にて「GuestAdditions」を再インストールしただけでは、改善されなかったということ:

-

合わさっての効果みたいなので、確実なやり方がわからないのがつらいところ:
→「ホストOS」と「仮想マシン」のシステム更新で、たまたま、両方で「カーネルの更新」があったのは、大きそう

もし、タイミングを合わせるなら、更新が長い、ホストOS 側の「LTS のカーネル」の更新に合わせて、他の項目を保留して、すべて合わせて実行するのが(気が長い話で難しいけど)確実かな。

-

-


3). 追記: 確実に「GuestAdditions」をインストールできるやり方が見つかりました:

-

ホストOS 側の「Vagrant」のインストール時に、「vagrant-vbguest」プラグインをインストールしておくと、 (自動でバージョンをチェックして)「GuestAdditions」をインストールしてくれます。

-

(1). 「vagrant-vbguest」プラグインのインストール:
$ vagrant plugin install vagrant-vbguest

-

(2). プラグインをインストールすると、「vagrant up」や「vagrant reload」時、及び「vagrant vbguest」実行時に

「Guest Additions」のバージョンをチェックして、 自動で「Guest Additions」のインストールが行われます

なので、手動でインストールしなくても簡単に「クリップボードの共有」機能などが動くと思います。

-

(3). プラグインをインストールしていれば、今までの作業(投稿)はだいぶ楽だったろうと思います。

→苦労したから、ありがたみがわかるのかな。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ---

6. 「仮想マシン」の「GuestAdditions」の再インストールに成功したことで気づいたこと:

-

「GuestAdditions」のインストールが成功して、下記の「エラー通知」が表示されず、うまく機能すると、

クリップボードの共有」機能だけでなく、「リアルタイムの自動解像度の調整」ができるようになりました:

VBoxClient: the VirtualBox kernel service is not running. Exiting.

→上記が表示されなくなると、「VBoxClient」が機能するからみたい:

-

ただし、「仮想マシン」の「Vagrantfile」を修正 して、「vboxsvga」から、「vmsvga」に設定しておきます:

-

-


まとめ

VirtualBox 7.0.14」と「Vagrant 2.4.1」にアップデートしたときに、たまたま、「ホストOS」と「仮想マシン」の両方で「カーネルの更新」があったのは、より多くの項目が実行できたので運が良かったみたい。

おかげで、「クリップボードの共有」機能だけでなく、「リアルタイムの自動解像度の調整」ができるようになりました。

-

いつもうまく行くとは限らないので、この「仮想マシン」を「Box」にして、活用するのが良さそうな気がします。

-

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-

Vagrant 実践編5: 「EndeavourOS」の「Box」で、「OpenBox」をインストール〈H170-6〉

登録日: 2024-02-02 更新日: 2024-03-14

Xubuntu 22.04 LTS」および「Windows11」(22H2) の「VirtualBox 7.0」の仮想マシンに、色々なLinux ディストリビューションをインストールして、自分に最適なものはないか試しています。

開発環境では、それらの仮想マシン(ボックス)の管理に「Vagrant」(ベイグラント) というツールが、よく使われています。

-

実践編1 の投稿で、「Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて「Vagrant」を使えるようにしました。

実践編3実践編4 の投稿で、コミュニティ版のベースとなる、「EndeavourOS」(デスクトップ環境なし) の英語の環境(ユーザ名は vagrant で、日本語キーボード)の「Box」(Endeav-base-jp) を作成しました。

-

(実践編5):

今回は、その作成した「Box」(Endeav-base-jp) を使って、 コミュニティ版の「OpenBox」を追加インストールしました。
ssh 接続できる、土台となる「仮想マシン」がすでにあるので、試しながらのインストールが楽にできたと思います。

-

その備忘録です。

-

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック
スマホの場合は、「ホーム」ボタンの横の「<」キーをタップ

-

-


目次

-

Vagrant」での参考:

  1. 「Vagrant」コマンドについて:

  2. 「Vagrant」コマンドの使用例:

  3. 「Vagrant」コマンドの使用例:(目次)

  4.  修正版3: 使い回し可能な「Vagrantfile」:

  5.  もし、PC のディスクに余裕がない場合:

  6. 「ssh 接続」で使うテキストエディタ「nano」:

  7. 「ssh 接続」で、日本語表示にするには:

 →事前に「デスクトップの日本語化」が必要です

-

「EndeavourOS」での参考:

  1.  ミラーの更新:

  2. 「Welcome」画面に、「個人用コマンド」(Personal Commands) タブを追加:

  3. 「仮想マシン」にて、「GuestAdditions」を再インストール:

  4. 「仮想マシン」にて、ログイン時の「エラー通知」の解消、および、「クリップボード共有」機能が改善:

-

今回の作業:

  1. 「Vagrantfile」の修正:

  2. 「仮想マシン」の作成と立ち上げ:

  3.  GUI のみで使うユーザ「mine」を作成:

  4. 「Openbox」のインストール:

  5. 「AUR ヘルパー」を「paru」に変更:

  6.  デスクトップ周りの設定:

  7.  テキストエディタの「featherpad」をインストール:

  8.  ESR 版の「Firefox」をインストール:

  9. 「アプリ」や「フォント」をインストール:

  10.  デスクトップの日本語化:

  11.  日本語入力:「ibus-anthy」の場合:

  12.  日本語入力:「ibus-mozc」の場合:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

Vagrant で「EndeavourOS」の「仮想マシン」を立ち上げ:

-

1). 「デスクトップ環境なし」でインストールしているので、コンソール画面が立ち上がりました:

-

2). 「デスクトップ環境」をインストールしてのログイン:

→英語の表示です

-

自動起動で設定されたアプリが重複して起動されています:

パネル:

→「Welcom」アプリ、「ファイアウォール」、「スピーカ」のアイコンが重複しています

-

3). 上記の問題を回避して、日本語化した「デスクトップ環境」:

-

パネル:

→パネルで選択された「1」の番号がオレンジ色に変わっていることに注目

-

-


現在のバージョンを表示:

-

ホストOS : 「Xubuntu 22.04.3 LTS」

2024-02-04 現在

カーネル:

$ uname -r
5.15.0-92-generic

リリース:

$ cat /etc/lsb-release
:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"

→「22.04.3」にアップしています。

-

-

ゲストOS : 「EndeavourOS」

2024-02-04 現在

カーネル:

$ uname -r
6.7.1-arch1-1

リリース:

$ cat /etc/lsb-release
:
DISTRIB_ID="EndeavourOS"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="EndeavourOS Linux"
DISTRIB_CODENAME="rolling"
$ cat /etc/os-release
:
NAME="EndeavourOS"
PRETTY_NAME="EndeavourOS"
ID="endeavouros"
ID_LIKE="arch"
BUILD_ID="2023.11.17"             ←(注目)
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://endeavouros.com"
DOCUMENTATION_URL="https://discovery.endeavouros.com"
SUPPORT_URL="https://forum.endeavouros.com"
BUG_REPORT_URL="https://forum.endeavouros.com/c/arch-based-related-questions/bug-reports"
PRIVACY_POLICY_URL="https://endeavouros.com/privacy-policy-2"
LOGO="endeavouros"

→注目: インストール時に使用したイメージの作成日付だったり、 「BUILD_ID=rolling」の表示だったりします。

-

「Welcome」のバージョン:

$ eos-welcome --version
:
24.2-1

→バージョン表示にて、「ログの登録」の行が表示される場合は「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

VirtualBox」について:

-

VirtualBox」は、Oracle が開発している「仮想マシン」を構築するためのソフトウェアです。

-

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

Vagrant」 (ベイグラント) について:

-

公式サイト:

Vagrant by HashiCorp

-

仮想マシン」の管理や操作をコマンドで使うための「フロントエンド」のソフトウェアです:

-

→詳細は、以前に投稿した「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

「EndeavorOS」について:

-

公式サイト:

-

  • EndeavorOS は、インストールが楽で、使い勝手をよくした「Arch Linux」です。

  • GUI 環境で「Arch Linux」を使いたいときに、オススメします。

-

→詳細は、以前に投稿した「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

「EndeavourOS」(OpenBox) について:

-

1). 公式サイト:

EndeavourOS-Community-Editions/openbox

→サイトに置かれた情報は「こちら 」を参照:

-

その他の詳細は「こちら 」を参照:

-

2). 「OpenBox」のデフォルトのアプリ:

  • 背景画像の処理: nitrogen
  • Gtk3 テーマの処理: obconf
  • ファイルブラウザ: thunar
  • ターミナルエミュレータ: xfce4-terminal
  • テキストエディタ: xed
  • アプリケーションランチャー: rofi

-

3). 「OpenBox」を手動でインストールする場合:

git clone https://github.com/EndeavourOS-Community-Editions/openbox.git
cd openbox
bash openbox-install.sh

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

(前回の作業):

-

Vagrant 実践編4: 「EndeavourOS」に ssh 接続等の設定を追加して「Box」を再作成〈H170-5

-

「EndeavourOS」にて、「デスクトップ環境なし」 の英語の環境(日本語キーボード指定、ユーザ名は vagrant )をインストールして、ssh 接続等の設定を追加後、「Box」を作成しました。

-

-

(その続き):

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

1. ホームの「Box」一覧にて、目的の「Box」を確認:

-

前回の作業で、「Box」一覧に登録済みです:

-

確認:

$ vagrant box list
Endeav-base-00 (virtualbox, 0)
Endeav-base-jp (virtualbox, 0)         ←(注目)

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

2. 「Vagrantfile」の修正:

-

1). 「仮想マシン」を管理する「作業フォルダ」を準備:

別の「作業フォルダ」を準備:

$ mkdir -p ~/ダウンロード/vm/endeavour-base-jp/

→「仮想マシン」を管理する場所になります

-

「作業フォルダ」は使い回すのでなく、新しい名前で作成した方が混乱しないと思います。

-

2). 念の為に、「作業マシン」を削除:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...

→「y」

-

3). 念の為に、「作業フォルダ」をクリア:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ rm -r .vagrant/
$ rm Vagrantfile

-


4). 「Vagrantfile」の作成:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ featherpad Vagrantfile

↓ すべて貼付け:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "Endeav-base-jp"
  #config.vm.boot_timeout = 300
  config.vm.boot_timeout = 60
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxsvga"]
    #vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

→ 「vboxsvga」に修正しました

Crtl+S で、保存

-

参考:「config.vm.box = "Endeav-base-jp"」の行を変更すれば、他の「仮想マシン」でも使い回し出来ます:

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

追記: GUI(デスクトップ環境)を使う場合の設定(修正版):
(1).「Ubuntu」の場合:

vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]」の行を有効にすると、
ウィンドウサイズの拡大で、リアルタイムに解像度が調整されます。

-

(2).「EndeavourOS」で、リアルタイムに解像度が調整される場合:

vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]」の行を有効にすると、
ウィンドウサイズの拡大で、リアルタイムに解像度が調整されます。

-

(3).「EndeavourOS」で、リアルタイムに解像度が調整されない場合:

vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxsvga"]」の行を有効にすると、
ログアウト直前の解像度に調整されます。つまり、仮対応と言えます。

-

リアルタイムに解像度が調整されない場合は、「GuestAdditions」のインストールで失敗している可能性があります:

→例えば、ログイン後、デスクトップ画面で、一瞬だけ下記の「エラー通知」が表示されるときは注意:

VBoxClient: the VirtualBox kernel service is not running. Exiting.

→回避策は、「GuestAdditions」の再インストールですが、 それでもダメなときは「こちら」を参照:

-


5). 作成されたか確認:

$ ls -1Ap
Vagrantfile         ←(注目)

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

3. 「仮想マシン」を作成して立ち上げ:

-

ホストOS の端末にて:

-

1). 「仮想マシン」を作成して立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'Endeav-base-jp'...
Progress: 40%

しばらく待ちます

==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: endeavour-base-jp_default_1706478454111_19314
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/endeavour-base-jp
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ 

→エラーなしで、プロンプトに戻りました。

-

2). 「仮想マシン」が立ち上がりました

→「デスクトップ環境なし」でインストールしているので、コンソール画面が立ち上がりました。

-

現時点では、コンソール画面には、ログインしません。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

4. 「仮想マシン」に「ssh 接続」:

-

ホストOS の端末にて:

-

1). 参考:「ssh 接続」の設定を確認:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/ubn/.vagrant.d/boxes/Endeav-base-jp/0/virtualbox/vagrant_private_key
  IdentitiesOnly yes
  LogLevel FATAL
  PubkeyAcceptedKeyTypes +ssh-rsa
  HostKeyAlgorithms +ssh-rsa

-

2). 「ssh 接続」:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh
Last login: Thu Jan 11 17:09:57 2024 from xx.xx.xx.xx
[vagrant@vagrant ~]$ 

→パスワードなしで自動ログインされました。

-

3). 確認:

[vagrant@vagrant ~]$ date
2024年  1月 29日 月曜日 06:50:41 JST

→ホストOS の「端末」を使っているので、「date」コマンドが文字化けしません。

-

[vagrant@vagrant ~]$ ls -lAp
-rw------- 1 vagrant vagrant 1209  1月 11 17:11 .bash_history
-rw-r--r-- 1 vagrant vagrant   21 11月 23 00:26 .bash_logout
-rw-r--r-- 1 vagrant vagrant   57 11月 23 00:26 .bash_profile
-rwxr-xr-x 1 vagrant vagrant 2691 11月 17 20:33 .bashrc
drwxr-xr-x 3 vagrant vagrant 4096  1月 10 21:29 .config/   ←(注目)
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Desktop/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Documents/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Downloads/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Music/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Pictures/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Public/
drwx------ 2 vagrant vagrant 4096  1月 11 01:53 .ssh/     ←(注目)
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Templates/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Videos/

-

[vagrant@vagrant ~]$ ls -lAp .config
drwxr-xr-x 3 vagrant vagrant 4096 12月 20 17:51 systemd/
-rw------- 1 vagrant vagrant  633  1月 10 21:29 user-dirs.dirs
-rw-r--r-- 1 vagrant vagrant    5  1月 10 21:29 user-dirs.locale

→デフォルトの状態

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -

5. 「仮想マシン」にて、GUI のみで使うユーザ「mine」を作成

-

パスワードなしのユーザ「vagrant」を日常的に使うにはセキュリティでのリスクが高いです。
GUI のみで使うユーザを作成。そのホームで「アプリのインストール」や「GUI 環境の設定」を行いました。

今回のユーザ名は「mine」にしましたが、好みのユーザ名にしてください:

入力の機会が多いので、短めが良いです

-


1). ホストOS の端末にて、「ssh 接続」:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-


2). 「ユーザ」と「ホームディレクトリ」を作成:

$ sudo useradd -m mine

→「mine」はユーザ名です。ユーザ名は好みです。

「-m」はユーザの「ホームフォルダ」(の頭)を作成するオプションです

-


3). パスワードを設定:

$ sudo passwd mine
New password:            ←(任意のパスワード)
Retype new password:     ←(再入力)
passwd: password updated successfully

→「mine」はユーザ名です。作成したユーザ名にしてください。

-

確認:

$ id mine
uid=1001(mine) gid=1001(mine) groups=1001(mine)

-


4). sudo が使える「wheel」グループに参加:

-

(1).「wheel」グループに参加:
$ sudo usermod -G wheel mine

→「mine」はユーザ名です。作成したユーザ名にしてください。

-

確認:

$ id mine
uid=1001(mine) gid=1001(mine) groups=1001(mine),998(wheel)

-

「EndeavourOS」の場合は、「sys」と「rfkill」のグループも必要です:

→参加するグループを追加する場合は、操作する前に、既存の設定を id で確認しておくのがオススメ:

-

(2).「sys」グループに追加で参加:
$ sudo usermod -aG sys mine

→注意:「-aG」としています:

-

(3).「rfkill」グループに追加で参加:
$ sudo usermod -aG rfkill mine

→注意:「-aG」としています:

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考: 「-aG」とせずに、「-G」と誤入力した場合の操作例:

新規になるので既存の「wheel」が消えます:

確認のみで、操作しないで下さい:

$ sudo usermod -G sys mine

-

$ id mine
uid=1001(mine) gid=1001(mine) groups=1001(mine),3(sys)

既存の「wheel」が消えて、「sys」のみになりました:
→もし、「vagrant」ユーザが作成されていない場合、sudo が使えなくなり、OS の再インストールとなるので注意:

逆に、既存のグループが多すぎて、参加するグループをやり直したい場合には、使えます:

-


5). 参加しているグループを確認:

$ id mine
uid=1001(mine) gid=1001(mine) groups=1001(mine),3(sys),998(wheel),981(rfkill)

→「rfkill」は無線デバイスを使うのに必要なグループです

-


6). 「wheel」グループに所属するユーザが「sudo」を利用できるか、確認:

$ sudo ls /etc/sudoers.d
10-installer

-

設定の確認:

$ sudo cat /etc/sudoers.d/10-installer
%wheel ALL=(ALL) ALL

→ファイル名からして、OS インストール時に自動で設定されたみたい:

「%wheel」とすると、「wheel」グループを指します

-


7). 再起動:

$ sudo reboot

-


8). 「仮想マシン」が立ち上がったら、「ssh 接続」:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-


9). 新しく作成した「mine」ユーザで操作:

[vagrant@vagrant ~]$ su - mine
Password:     ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

(1).「ホームフォルダ」が作成されたか確認:
[mine@vagrant ~]$ pwd
/home/mine

-

[mine@vagrant ~]$ ls -lA
-rw-r--r-- 1 mine mine   21  1月 16 19:48 .bash_logout
-rw-r--r-- 1 mine mine   57  1月 16 19:48 .bash_profile
-rwxr-xr-x 1 mine mine 2691 11月 17 20:33 .bashrc
drwxr-xr-x 3 mine mine 4096 12月 20 17:51 .config

→頭のみで、配下のフォルダは作成されません。

[mine@vagrant ~]$ ls -lA .config
drwxr-xr-x 3 mine mine 4096 12月 20 17:51 systemd

-

(2). sudo が使えるか確認:
[mine@vagrant ~]$ sudo date
[sudo] password for mine:      ←(mine ユーザを作成したときのパスワード)
2024年  1月 30日 火曜日 03:18:45 JST

-


10). mine ユーザを抜けます:

[mine@vagrant ~]$ exit
logout
[vagrant@vagrant ~]$ 

→プロンプトが変わりました

-


11). 「ssh 接続」を終了:

[vagrant@vagrant ~]$ exit
logout

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- --

6. 「仮想マシン」に「Openbox」をインストール:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ---

6-1. 「仮想マシン」の「mine」のホームに、「Openbox」をダウンロード(クローンの作成):

-

1). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:     ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

2). ホームフォルダを作成:

$ mkdir -p {Desktop,Documents,Downloads,Music,Pictures,Public,Templates,Videos}

-

確認:

[mine@vagrant ~]$ ls -lAp
-rw------- 1 mine mine   72  1月 30 03:30 .bash_history
-rw-r--r-- 1 mine mine   21  1月 16 19:48 .bash_logout
-rw-r--r-- 1 mine mine   57  1月 16 19:48 .bash_profile
-rwxr-xr-x 1 mine mine 2691 11月 17 20:33 .bashrc
drwxr-xr-x 3 mine mine 4096 12月 20 17:51 .config/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Desktop/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Documents/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Downloads/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Music/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Pictures/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Public/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Templates/
drwxr-xr-x 2 mine mine 4096  1月 30 16:47 Videos/

-

3). 「~/Downloads/」フォルダに移動:

$ cd ~/Downloads/

-

4). ダウンロード(クローンの作成):

$ git clone https://github.com/EndeavourOS-Community-Editions/openbox.git
Cloning into 'openbox'...
remote: Enumerating objects: 295, done.
remote: Counting objects: 100% (54/54), done.
remote: Compressing objects: 100% (50/50), done.
remote: Total 295 (delta 29), reused 9 (delta 4), pack-reused 241
Receiving objects: 100% (295/295), 91.35 KiB | 1.30 MiB/s, done.
Resolving deltas: 100% (152/152), done.

-

5). 作成されたフォルダに移動:

$ cd ~/Downloads/openbox/
[mine@vagrant openbox]$ ls -lAp
drwxr-xr-x 10 mine mine  4096  1月 30 16:50 .config/
drwxr-xr-x  8 mine mine  4096  1月 30 16:50 .git/
-rw-r--r--  1 mine mine   575  1月 30 16:50 .gtkrc-2.0
-rw-r--r--  1 mine mine 35149  1月 30 16:50 LICENSE
-rw-r--r--  1 mine mine  4396  1月 30 16:50 netinstall.yaml
-rw-r--r--  1 mine mine   420  1月 30 16:50 openbox-install.sh
-rw-r--r--  1 mine mine   589  1月 30 16:50 packages-repository.txt
-rw-r--r--  1 mine mine  1439  1月 30 16:50 README.md
-rwxr-xr-x  1 mine mine   660  1月 30 16:50 setup.sh
drwxr-xr-x  3 mine mine  4096  1月 30 16:50 .themes/
-rw-r--r--  1 mine mine   139  1月 30 16:50 xed.dconf

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----

6-2. 「セットアップ用のスクリプト」を確認:

-

2024-02-02 現在:

-

「openbox-install.sh」の内容を確認:

$ cd ~/Downloads/openbox/
$ cat openbox-install.sh
#!/bin/bash

# Easy setup for testing

mkdir -p ~/.config
mkdir -p ~/.themes
cp -R .config/* ~/.config/
cp -R .themes/* ~/.themes/
cp .gtkrc-2.0 ~/.gtkrc-2.0
chmod -R +x ~/.config/openbox/scripts
chmod +x ~/.config/rofi/powermenu.sh
sudo pacman -Syu --needed --noconfirm - < packages-repository.txt
sudo systemctl enable lightdm.service
# eos-packagelist --install "Openbox Edition"
dbus-launch dconf load / < xed.dconf

→テスト用の簡単なセットアップ:

パッケージ管理に「pacman」を使う(公式リポジトリのアプリをインストールする)ように修正されました:

-

スクリプトの実行で、システム更新がされた後に、 「packages-repository.txt」にある(EndeavourOS の)公式アプリの一覧がインストールされます。

その後、GUI のログイン画面が有効になります。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -----

6-3. インストールを行うアプリの一覧を確認:

-

2024-02-02 現在:

-

「packages-repository.txt」の内容を確認:

$ cd ~/Downloads/openbox/
$ cat packages-repository.txt
acpi
arandr
arc-gtk-theme-eos
archlinux-xdg-menu
default-cursors
dex
dmenu
dunst
eos-lightdm-slick-theme
eos-qogir-icons
feh
gtk-engine-murrine
gvfs
gvfs-afc
gvfs-gphoto2
gvfs-mtp
gvfs-nfs
gvfs-smb
jgmenu
jq
lightdm
lightdm-slick-greeter
lxappearance-gtk3
mpv
network-manager-applet
nitrogen
obconf
openbox
pasystray
picom
polkit-gnome
rofi
scrot
slock
sysstat
thunar
thunar-archive-plugin
thunar-media-tags-plugin
thunar-volman
tint2
tumbler
xbindkeys
xdg-user-dirs-gtk
xed
xfce4-terminal
xorg-xbacklight
capitaine-cursors
python-pyxdg
ttf-nerd-fonts-symbols
xcursor-themes
xorg-xdpyinfo

→つい先日まで、一覧にあるパッケージで多くの重複がありましたが、修正されました:

重複は無駄なだけで問題ありませんが、(AUR に降格したり削除されて)公式リポジトリにないパッケージや、コメント行(#)がひとつでもあるとエラーして、すべてのインストールが実行されません。

「Arch Linux」等でインストールする場合は、「eos-」が付いたパッケージは「EndeavourOS」の公式パッケージなので、その行の削除か、代わりのパッケージに変更が必要です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -

6-4. 「セットアップ用のスクリプト」を実行:

-

ssh 接続」にて、「Openbox」をインストール:

-


1). 「openbox-install.sh」を実行:

$ cd ~/Downloads/openbox/
$ bash openbox-install.sh
[sudo] password for mine: 

:: Synchronizing package databases...
 endeavouros            21.4 KiB  64.8 KiB/s 00:00 [-----------------] 100%
 core is up to date
 extra                   8.3 MiB  5.37 MiB/s 00:02 [-----------------] 100%
 multilib              140.0 KiB   284 KiB/s 00:00 [-----------------] 100%
:

システム更新が含まれているので、時間がかかりました:

:
downloading required keys...
:: Import PGP key B8AC08600F108CDF, "Jan Alexander Steffens (heftig) <heftig@archlinux.org>"? [Y/n] 
:: Import PGP key 001CF4810BE8D911, "Jakub Klinkovský <lahwaacz@archlinux.org>"? [Y/n] 

自動応答され、続行されました:

:
Created symlink /etc/systemd/system/display-manager.service → /usr/lib/systemd/system/lightdm.service.
[mine@vagrant openbox]$ 

→正常終了。プロンプトに戻りました。

-


2). 参考: インストールされたアプリのバージョンを確認:

確認のみで、作業は要りません:

-

(1). ソート:
$ cd ~/Downloads/openbox/
$ sort -u packages-repository.txt > packages-repository.txt-SORT

→「-u」: 重複を排除して昇順で並び変え

-

(2). 再インストールを利用して、バージョン確認:
$ sudo pacman -Syu --needed --noconfirm - < packages-repository.txt-SORT

パッケージがインストール済みだと警告が表示して、スキップされます:

[sudo] password for mine: 

:: Synchronizing package databases...
 endeavouros is up to date
 core is up to date
 extra is up to date
 multilib is up to date
warning: acpi-1.7-3 is up to date -- skipping
warning: arandr-0.1.11-2 is up to date -- skipping
warning: arc-gtk-theme-eos-20221218-1 is up to date -- skipping
warning: archlinux-xdg-menu-0.7.6.6-1 is up to date -- skipping
warning: capitaine-cursors-4-2 is up to date -- skipping
warning: default-cursors-2-1 is up to date -- skipping
warning: dex-0.9.0-1 is up to date -- skipping
warning: dmenu-5.2-1 is up to date -- skipping
warning: dunst-1.9.2-1 is up to date -- skipping
warning: eos-lightdm-slick-theme-3.2-1 is up to date -- skipping
warning: eos-qogir-icons-5-1 is up to date -- skipping
warning: feh-3.10.2-1 is up to date -- skipping
warning: gtk-engine-murrine-0.98.2-4 is up to date -- skipping
warning: gvfs-1.52.2-2 is up to date -- skipping
warning: gvfs-afc-1.52.2-2 is up to date -- skipping
warning: gvfs-gphoto2-1.52.2-2 is up to date -- skipping
warning: gvfs-mtp-1.52.2-2 is up to date -- skipping
warning: gvfs-nfs-1.52.2-2 is up to date -- skipping
warning: gvfs-smb-1.52.2-2 is up to date -- skipping
warning: jgmenu-4.4.1-1 is up to date -- skipping
warning: jq-1.7.1-1 is up to date -- skipping
warning: lightdm-1:1.32.0-5 is up to date -- skipping
warning: lightdm-slick-greeter-2.0.3-1 is up to date -- skipping
warning: lxappearance-gtk3-0.6.3-4 is up to date -- skipping
warning: mpv-1:0.37.0-2 is up to date -- skipping
warning: network-manager-applet-1.36.0-1 is up to date -- skipping
warning: nitrogen-1.6.1-4 is up to date -- skipping
warning: obconf-2.0.4-8 is up to date -- skipping
warning: openbox-3.6.1-10 is up to date -- skipping
warning: pasystray-0.8.2-1 is up to date -- skipping
warning: picom-11-4 is up to date -- skipping
warning: polkit-gnome-0.105-10 is up to date -- skipping
warning: python-pyxdg-0.28-2 is up to date -- skipping
warning: rofi-1.7.5-2 is up to date -- skipping
warning: scrot-1.10-1 is up to date -- skipping
warning: slock-1.5-1 is up to date -- skipping
warning: sysstat-12.7.5-1 is up to date -- skipping
warning: thunar-4.18.10-1 is up to date -- skipping
warning: thunar-archive-plugin-0.5.2-1 is up to date -- skipping
warning: thunar-media-tags-plugin-0.4.0-1 is up to date -- skipping
warning: thunar-volman-4.18.0-1 is up to date -- skipping
warning: tint2-17.0.2-3 is up to date -- skipping
warning: ttf-nerd-fonts-symbols-3.1.1-1 is up to date -- skipping
warning: tumbler-4.18.2-1 is up to date -- skipping
warning: xbindkeys-1.8.7-4 is up to date -- skipping
warning: xcursor-themes-1.0.7-1 is up to date -- skipping
warning: xdg-user-dirs-gtk-0.11-2 is up to date -- skipping
warning: xed-3.4.5-1 is up to date -- skipping
warning: xfce4-terminal-1.1.1-2 is up to date -- skipping
warning: xorg-xbacklight-1.2.3-3 is up to date -- skipping
warning: xorg-xdpyinfo-1.3.4-1 is up to date -- skipping
:: Starting full system upgrade...
 there is nothing to do

システム更新があると、その他のパッケージも更新されます。

ちなみに、「eos-」が付いたパッケージは「endeavouros」リポジトリにある公式パッケージです。

-


3). システム更新したので、再起動:

-

(1). ログアウト(ssh 接続を中断):
[mine@vagrant openbox]$ exit
logout
[vagrant@vagrant ~]$ exit
logout
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ 

→ログアウトが 2回必要です

-

(2). 電源オフ:
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ vagrant halt
==> default: Attempting graceful shutdown of VM...
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ 

-

(3). ホストOS を再起動:

ホストOS で、端末以外のすべてのウィンドウを閉じてから、

ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ reboot

→「共有フォルダ」を有効にします

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- --

6-5. 「仮想マシン」の立ち上げ:

-

ホストOS の端末にて:

-


1). 「仮想マシン」を立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/endeavour-base-jp
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ 

-


2). 「仮想マシン」が立ち上がり、GUI のログイン画面が表示:

→あれれ、以前と壁紙が違います:

-


3). 「仮想マシン」のログイン画面にて、パスワード入力してみる:

ユーザ名: vagrant (自動で選ばれています)

-

「↑」キーにて、

→「mine」を選んで、

パスワード: 「mine」のパスワードを入力

-


4). デスクトップ画面が表示:

→デスクトップ画面が表示され、「Welcome」画面も起動:

気になるのは、パネルのアイコンが 2ずつあること:

「Welcome」x2 、「ファイヤーウォール」x2 、「スピーカ」x2

-

つまり、「Welcome」アプリが 2つ起動しています:

→アプリの自動起動が重複しているみたい。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ---

6-6. 参考: インストール用のスクリプトがすべて実行されたか、確認:

-

1). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-


1). フォルダが追加されたか確認:

[mine@vagrant ~]$ ls -lAp ~/
-rw-------  1 mine mine   599  1月 30 17:04 .bash_history
-rw-r--r--  1 mine mine    21  1月 16 19:48 .bash_logout
-rw-r--r--  1 mine mine    57  1月 16 19:48 .bash_profile
-rwxr-xr-x  1 mine mine  2691 11月 17 20:33 .bashrc
drwx------  5 mine mine  4096  1月 30 17:24 .cache/
drwxr-xr-x 13 mine mine  4096  1月 30 17:24 .config/
drwxr-xr-x  2 mine mine  4096  1月 30 16:47 Desktop/
-rw-r--r--  1 mine mine    26  1月 30 17:24 .dmrc
drwxr-xr-x  2 mine mine  4096  1月 30 16:47 Documents/
drwxr-xr-x  3 mine mine  4096  1月 30 16:50 Downloads/
-rw-r--r--  1 mine mine   575  1月 30 16:55 .gtkrc-2.0 ←(追加)
drwx------  3 mine mine  4096  1月 30 17:24 .local/
drwxr-xr-x  2 mine mine  4096  1月 30 16:47 Music/
drwxr-xr-x  2 mine mine  4096  1月 30 16:47 Pictures/
drwxr-xr-x  2 mine mine  4096  1月 30 16:47 Public/
drwxr-xr-x  2 mine mine  4096  1月 30 16:47 Templates/
drwxr-xr-x  3 mine mine  4096  1月 30 16:55 .themes/   ←(追加)
drwxr-xr-x  2 mine mine  4096  1月 30 16:47 Videos/
-rw-------  1 mine mine    52  1月 30 17:24 .Xauthority
-rw-------  1 mine mine 11478  1月 30 17:30 .xsession-errors

→新規のフォルダも作成されています。

-


2). 「~/.config」の確認:

[mine@vagrant ~]$ ls -lAp ~/.config/
drwx------ 2 mine mine 4096  1月 30 16:56 dconf/
drwxr-xr-x 2 mine mine 4096  1月 30 16:55 dunst/
-rw-r--r-- 1 mine mine  290  1月 30 17:24 EOS-greeter.conf
-rw-r--r-- 1 mine mine   75  1月 30 17:24 eos-update-notifier.first_init
drwxr-xr-x 2 mine mine 4096  1月 30 17:24 gtk-3.0/
drwxr-xr-x 2 mine mine 4096  1月 30 16:55 jgmenu/
drwxr-xr-x 2 mine mine 4096  1月 30 16:55 nitrogen/
drwxr-xr-x 3 mine mine 4096  1月 30 16:55 openbox/
-rw-r--r-- 1 mine mine 7888  1月 30 16:55 picom.conf.example
drwx------ 2 mine mine 4096  1月 30 17:24 pulse/
drwxr-xr-x 2 mine mine 4096  1月 30 16:55 rofi/
drwxr-xr-x 3 mine mine 4096 12月 20 17:51 systemd/           ←(既存)
drwxr-xr-x 2 mine mine 4096  1月 30 16:55 tint2/
-rw------- 1 mine mine  633  1月 30 17:24 user-dirs.dirs     ←(既存)
-rw-r--r-- 1 mine mine    5  1月 30 17:24 user-dirs.locale   ←(既存)
drwxr-xr-x 4 mine mine 4096  1月 30 16:55 xfce4/

→「設定ファイル」等は落ちています。

-


3). 「chmod -R +x ~/.config/openbox/scripts」の確認:

[mine@vagrant ~]$ ls -lA ~/.config/openbox/scripts
-rwxr-xr-x 1 mine mine  208  1月 30 16:55 brightness-control
-rwxr-xr-x 1 mine mine 1419  1月 30 16:55 low_bat_notifier.sh
-rwxr-xr-x 1 mine mine  496  1月 30 16:55 screenshot.sh
-rwxr-xr-x 1 mine mine  495  1月 30 16:55 volume-control

→ファイル属性は変更されています。

-


4). 「chmod +x ~/.config/rofi/powermenu.sh」の確認:

[mine@vagrant ~]$ ls -lA ~/.config/rofi/powermenu.sh
-rwxr-xr-x 1 mine mine 1010  1月 30 16:55 /home/mine/.config/rofi/powermenu.sh

→ファイル属性は変更されています。

-


5). アプリがインストールされているか確認:

抜粋:

[mine@vagrant ~]$ pacman -Ss xed
extra/xed 3.4.5-1 (x-apps) [installed]
    A small and lightweight text editor. X-Apps Project.

→アプリはインストールされています:

-


6). スクリプトの最終行が実行されて、設定が反映されているか確認:

確認する行なので、実行は要りません:

dbus-launch dconf load / < xed.dconf

→最終行は、「xed」がインストールされていれば確認できます:

-


7). 「~/Downloads/openbox/xed.dconf」の確認:

[mine@vagrant ~]$ cd ~/Downloads/openbox/
[mine@vagrant ~]$ cat  xed.dconf
[org/x/editor/preferences/editor]
bracket-matching=false
display-line-numbers=true
prefer-dark-theme=true
scheme='cobalt'
wrap-mode='none'

→「xed」の設定項目です

-


8). デスクトップで起動しないと、「ssh 接続」では、アプリは起動できません:

[mine@vagrant openbox]$ xed
(xed:3635): Gtk-WARNING **: 17:36:52.829: cannot open display: 

display の指定が必要みたい。

-


9). 仮想マシンのデスクトップで「端末」を起動:

「xed」を起動:

[mine@vagrant ~]$ xed 

-

→行番号が表示され、背景が「コバルトブルー」であることを確認しました:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----

7. 任意: 「AUR ヘルパー」をメッセージ表示が自然な「paru」に変更:

-

「Arch Linux」は、コミュニティで管理されている非公式のリポジトリ(AUR)が使えるのが特徴です。 そのAUR パッケージを含めた管理を行える「AUR ヘルパー」のひとつが「paru」です。

「paru」はメッセージ表示が自然なので、違和感なく使えます。 また、「paru」は、「EndeavourOS」の公式リポジトリに登録があるのでインストールも楽です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -----

7-1. 「paru」のインストール:

-

1). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

2). 公式リポジトリにあるか確認:

[mine@vagrant ~]$ pacman -Ss yay
endeavouros/yay 12.2.0-1 [installed]
    Yet another yogurt. Pacman wrapper and AUR helper written in go.
extra/ruby-yard 0.9.34-1
    YARD is a Ruby Documentation tool. The Y stands for "Yay!"

→「yay」がインストール済みです

-

[mine@vagrant ~]$ pacman -Ss paru
endeavouros/paru 2.0.1-1
    Feature packed AUR helper

→「paru」は公式リポジトリからインストールできます

-

3). 「paru」のインストール:

[mine@vagrant ~]$ sudo pacman -S paru
Package (1)       New Version  Net Change  Download Size
endeavouros/paru  2.0.1-1        8.59 MiB       2.79 MiB

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- -

7-2. 「paru」で、システム更新:

-

使用時に「sudo」もパラメータ指定の「-Syu」も要りません(付けても OK):

-

1). システム更新:

[mine@vagrant ~]$ paru
[sudo] password for mine: 

-

2). システム更新がないときの表示:

[mine@vagrant ~]$ paru
[sudo] password for mine: 
:: Synchronizing package databases... ←(データベースの同期中)
 endeavouros is up to date            ←(endeavouros: EndeavourOSの公式リポジトリ)
 core is up to date                   ←(core/extra/multilib: ArchLinuxの公式リポジトリ)
 extra            8.3 MiB  3.70 MiB/s 00:02 [-----------------] 100%
 multilib is up to date
:: Starting full system upgrade...
 there is nothing to do               ←(pacman では: 何も行うことがありません)
:: Looking for PKGBUILD upgrades...   ←(PKGBUILD の更新を確認)
:: Looking for AUR upgrades...        ←(AUR の更新を確認)
:: Looking for devel upgrades...      ←(開発の更新を確認)
 there is nothing to do               ←(paru では: 何も行うことがありません)

→「EndeavourOS」の公式リポジトリの更新をチェック後、AUR リポジトリの更新がチェックされます。

pacman」を補完する形で「paru」が動きます。

-

3). システム更新後の再起動:

[mine@vagrant ~]$ sudo reboot
:
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ 

→「ssh 接続」で「仮想マシン」を再起動するには「sudo」が必要です

ssh 接続」は切断されますが、「仮想マシン」は自動で再立ち上げされるので、 立ち上がるまで待ちます。

-

4). ログイン画面が表示:

→ログインせずに、「ssh 接続」します

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- --

7-3. 「Welcome」アプリで「paru」を使うように修正:

-

GUI の「Welcome」画面の「システムの更新」メニューでは「AUR ヘルパー」の機能が使われています。

「eos-update-notifier 」スクリプトで、「paru」を使うように変更しました:

-

1). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

1). 「/etc/eos-script-lib-yad.conf」を修正:

ssh 接続」で修正できるように、「nano」を使いました:

[mine@vagrant ~]$ sudo nano /etc/eos-script-lib-yad.conf
[sudo] password for mine: 

-

Ctrl+W で検索 →Search:「EOS_AUR_HELPER」Enter

## EOS_AUR_HELPER contains the AUR helper program name.
## Supported values are yay and paru, but other helpers may work as well.
## The program must support options -Qua and -Sua.
## For the Welcome app you can also set another AUR helper with
## variable EOS_AUR_HELPER_OTHER.
## Both apps must support the options mentioned above.
#
EOS_AUR_HELPER="yay"
EOS_AUR_HELPER_OTHER=""   # for example: "paru"

-

一番下から 2行目を修正:

EOS_AUR_HELPER="yay"
EOS_AUR_HELPER_OTHER=""   # for example: "paru"

↓ 修正:

EOS_AUR_HELPER="paru"
EOS_AUR_HELPER_OTHER=""   # for example: "paru"

Ctrl+O (小文字のオー)で、保存

Ctrl+X で、終了

-

2). 再起動:

[mine@vagrant ~]$ sudo reboot

-

3). GUI の「ログイン」画面が表示:

→「mine」を選んで、パスワード入力

-

4). 「Welcome」画面が表示:

起動されないとき:

Windows+ Enter で、端末を起動:

[mine@vagrant ~]$ eos-welcome --once

-

5). 「After Install」(インストール後)タブ

「システムの更新」のメニューが、「paru」に変更されました:

-

こちらは日本語化された場合の画面ですが、同じです

抜粋:

「システムの更新 (paru)」       ←(変更されました)

英語なら、

「Update System (paru)」      ←(変更されました)

-

Windows+Q で、アプリを閉じます。

「Welcome」画面は 2つ起動されているので、2つとも閉じました。

-

6). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-


7). 「yay」を削除:

[mine@vagrant ~]$ paru -R yay
Package (1)  Old Version  Net Change
yay          12.2.0-1      -9.12 MiB

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ---

8. 任意: テキストエディタの「featherpad」をインストール:

-

1). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

2). インストール:

[mine@vagrant ~]$ paru -S featherpad
[sudo] password for mine: 

Package (1)       New Version  Net Change
extra/featherpad  1.4.1-1        3.60 MiB

-

3). 参考: 「ssh 接続」でバージョンを確認すると、コアダンプに落ちるので注意:

ssh 接続」の場合:

[mine@vagrant ~]$ featherpad --version
:
Aborted (core dumped)

-

デスクトップ画面にて、Windows+Enter で「端末」を起動:

[mine@vagrant ~]$ featherpad --version
Featerpad 1.4.1

-

4). 「featherpad」の設定:

GUI のログイン画面で「mine」を選んで、パスワード入力:

-

デスクトップ画面にて、Windows+Enter で「端末」を起動:

-

設定メニューが英語だと難しいので、下記のようにして日本語で起動:

[mine@vagrant ~]$ LANG=ja_JP.UTF-8 featerpad

-

設定:

→「こちら 」を参照:

-

5). 設定後に起動して確認:

[mine@vagrant ~]$ featerpad

-

6). パネルのランチャーを「featherpad」に変更:

[mine@vagrant ~]$ nano ~/.config/tint2/tint2rc

Ctrl+W で検索 →Search: 「xed」Enter で検索:

launcher_item_app = /usr/share/applications/xed.desktop

↓ 下記のように修正:

#launcher_item_app = /usr/share/applications/xed.desktop
launcher_item_app = /usr/share/applications/featherpad.desktop

もし、どちらも表示したいときは、行頭の「#」を削除します

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----

9. 任意: ESR 版の「Firefox」をインストール:

-

仮想マシン」のデスクトップ環境でダウンロード後、「ssh 接続」でインストールします:

-

参考:

Boxes に「EndeavourOS」(Xfce) をインストールして「Worm」wm を追加(1/2)〈H160-2

19-1. ESR 版の「Firefox」をインストール

-

1). 「仮想マシン」を立ち上げ:

-

2). ログイン画面で、「mine」ユーザにログイン:

-

3). ブラウザにて、「Firefox ESR」をダウンロード:

-

(1). 「仮想マシン」のブラウザで「firefox esr download」で検索:

-

(2). 画面下のリンク「Firefox ESR のダウンロードページ からダウンロードできます。」をクリック

-

(3). 言語の選択で、「English (US)」もしくは、「Japanese ー 日本語」を選択:

-

(4). 「Downlod Now」(今すぐダウンロード)をクリック

→「~/Downloads/firefox-115.7.0esr.tar.bz2」

-

4). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-


5). ダウンロードしたファイルを展開:

[mine@vagrant ~]$ cd ~/Downloads/
[mine@vagrant Downloads]$ tar xjf firefox-*.tar.bz2

→少し時間がかかります。

-


6). 展開した Firefox フォルダを「/opt」に移動:

[mine@vagrant Downloads]$ sudo mv firefox /opt
[mine@vagrant Downloads]$ ls /opt
firefox

-


7). Firefox の実行ファイルへのシンボリックリンクを作成:

[mine@vagrant ~]$ sudo mkdir -p /usr/local/bin/
[sudo] password for mine: 

-

[mine@vagrant ~]$ sudo ln -s /opt/firefox/firefox /usr/local/bin/firefox

-

8). 「firefox」のデスクトップファイルを置くフォルダを作成:

[mine@vagrant ~]$ sudo mkdir -p /usr/local/share/applications/
[sudo] password for mine: 

-

9). 「firefox」の「デスクトップファイル」を作成:

[mine@vagrant ~]$ sudo nano /usr/local/share/applications/firefox.desktop
[Desktop Entry]
Version=1.0
Name=Firefox Web Browser
Comment=Browse the World Wide Web
GenericName=Web Browser
Keywords=Internet;WWW;Browser;Web;Explorer
Exec=firefox %u
Terminal=false
X-MultipleArgs=false
Type=Application
Icon=/opt/firefox/browser/chrome/icons/default/default128.png
Categories=GNOME;GTK;Network;WebBrowser;
MimeType=text/html;text/xml;application/xhtml+xml;application/xml;application/rss+xml;application/rdf+xml;image/gif;image/jpeg;image/png;x-scheme-handler/http;x-scheme-handler/https;x-scheme-handler/ftp;x-scheme-handler/chrome;video/webm;application/x-xpinstall;
StartupNotify=true

→Ctrl+O で「保存」: 保存先を確認して、Enter

→Ctrl+X で、終了

-


10). 問題点: ESR 版の firefox をインストールしても、起動しません:

端末から起動してみると、エラー:

[mine@vagrant ~]$ which firefox
/usr/local/bin/firefox

-

[mine@vagrant ~]$ firefox
XPCOMGlueLoad error for file /opt/firefox/libxul.so:
libdbus-glib-1.so.2: cannot open shared object file: No such file or directory
Couldn't load XPCOM.

→共有ライブラリが足りないみたい。

-

回避策:
(1). ファイルデータベースを同期:
[mine@vagrant ~]$ sudo pacman -Fy

-

(2). ファイルを含むパッケージを検索:
[mine@vagrant ~]$ pacman -F libdbus-glib-1.so.2
extra/dbus-glib 0.112-3
    usr/lib/libdbus-glib-1.so.2
multilib/lib32-dbus-glib 0.112-2
    usr/lib32/libdbus-glib-1.so.2

-

(3). インストール:
[mine@vagrant ~]$ sudo pacman -S dbus-glib
Package (1)      New Version  Net Change  Download Size
extra/dbus-glib  0.112-3        0.80 MiB       0.13 MiB

-

(4). 再起動:
[mine@vagrant ~]$ sudo reboot

-

11). ログイン画面で、「mine」ユーザにログイン:

-

12). Ctrl+Enter にて、「端末」を起動:

firefox」を起動して確認:

[mine@vagrant ~]$ firefox

→日本語のESR版の「firefox」が起動

-


13). 問題点: アプリメニューやパネルのアイコンをクリックすると、以前の「firefox」が起動します:

-

回避策:
(1). パネルの設定ファイルを修正:

パネルのランチャーにある「firefox」を ESR 版に修正:

[mine@vagrant ~]$ nano ~/.config/tint2/tint2rc

Ctrl+W で検索 →Search:「firefox」Enter

launcher_item_app = firefox.desktop

↓ 下記のように修正:

launcher_item_app = /usr/local/share/applications/firefox.desktop

→Ctrl+O で「保存」: 保存先を確認して、Enter

→Ctrl+X で、終了

-

(2). 再起動:
[mine@vagrant ~]$ sudo reboot

-

(3). パネルから起動して、ヘルプで「ESR」の正式名称「Extended Support Release」が含まれていることを確認:

-


14). 参考: 以前の「Firefox」を削除:

-

(1). インストールの確認:
[mine@vagrant ~]$ paru -Ss firefox | grep Installed
extra/firefox 122.0-1 [0 B 229.65 MiB] [Installed]
(2). 削除:
[mine@vagrant ~]$ paru -R firefox
Package (1)  Old Version  Net Change 
firefox      122.0-1      -229.65 MiB

-


15). 問題点: 以前の「Firefox」アプリを削除すると、パネルの「Firefox」のアイコンが表示されません:

以前使われていたアイコン:

「/usr/share/icons/hicolor/scalable/apps/firefox.svg

-

ESR 版の「Firefox」アプリのアイコンは下記にあるので、パスの指定がないと認識されません:

「/opt/firefox/browser/chrome/icons/default/default128.png

-

回避策:

→「項番 9). 」で、「デスクトップファイル」にパスを指定しました:

-

デスクトップ画面で確認:

パネル:

→パネルに「firefox」のアイコンが表示されていることに注目

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- -----

10. デスクトップ周りの設定:

-

使い勝手が良くなるように変更:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- -

10-1. 問題点:「仮想マシン」の起動で、パネルのアイコンが重複するので対応:

-

デスクトップを追加したら、自動起動のアプリが重複して起動されます:

実際のパネルの表示:

→「Welcom」アプリ、「ファイアウォール」、「スピーカ」のアイコンが重複して表示:

というか、重複してアプリが起動しています

-

1). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

2). 自動起動アプリの設定ファイルを修正:

たぶん、下記以外に自動起動の設定があるのですが、どこかわからないので下記で対応:

[mine@vagrant ~]$ nano ~/.config/openbox/autostart

-

抜粋:

# Autostart
dex -a -s /etc/xdg/autostart/:~/.config/autostart/ &

↓ 下記のように、コメント行に変更:

# Autostart
# dex -a -s /etc/xdg/autostart/:~/.config/autostart/ &

→Ctrl+O で「保存」: 保存先を確認して、Enter

→Ctrl+X で、終了

-

3). 再起動:

[mine@vagrant ~]$ sudo reboot

-

4). GUI の「ログイン」画面にて、「mine」を「↑」キーで選んで、パスワード入力:

-

5). デスクトップ画面にて、パネルが正常か確認:

パネルの表示:

→パネルにて、アプリの重複がなくなりました

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- --

10-2. 「端末」で表示されるディレクトリの色が「暗い紺色」で見づらいので対応:

-

1). 「仮想マシン」を立ち上げ:

-

2). ログイン画面で、「mine」ユーザを選んで、パスワード入力:

-

3). Windows + Enter で、「端末」を起動:

[mine@vagrant ~]$ ls -1
Desktop
Documents
Downloads
Music
Pictures
Public
Templates
Videos

-

実際の画面:

→見づらいです

-

4). 「端末」のウィンドウの空きで、右クリック→「Preferences…」(設定...)

「Colors」(配色)タブ

Palette(パレット)

「Show bold text in bright colors:」(ボールドのテキストを明るい色で表示する:)にチェック

-

→「Close」(閉じる)

-

5). 「端末」の表示を確認:

変更後:

→マシになりました

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ---

10-3. パネルの時計の表示を変更:

-

1). パネルの設定ファイルを修正:

[mine@vagrant ~]$ nano ~/.config/tint2/tint2rc

Ctrl+W で検索 →Search:「Clock」Enter で検索:

# Clock
time1_format = %H:%M
time2_format = %a %d %b

↓ 置換:

# Clock
time1_format = %H:%M
time2_format = %m/%d %a

→Ctrl+O で「保存」: 保存先を確認して、Enter

→Ctrl+X で「終了」

-

2). 再起動:

[mine@vagrant ~]$ sudo reboot
[sudo] password for mine: 

-

3). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

-

4). デスクトップ画面で確認:

パネルの表示:

→パネルにて、右にある「時計」の表示に違和感がありません

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----

10-4. 任意: パネルで、アクティブな「ディスクトップの番号」を見やすいようにカラー化:

-

1). パネルの設定ファイルを修正:

-

[mine@vagrant ~]$ nano ~/.config/tint2/tint2rc

Ctrl+W で検索 →Search:「taskbar_name_active_font_color」Enter で検索:

-

169 行目:(Ctrl+C で現在のカーソル位置を表示)

taskbar_name_active_font_color = #ffffff 100

↓ 置換: Ctrl+K 後、Ctrl+U を 2回、「↑」キーで行に戻って修正

# taskbar_name_active_font_color = #ffffff 100
taskbar_name_active_font_color = #f57900 100

→Ctrl+O で「保存」: 保存先を確認して、Enter

→Ctrl+X で「終了」

-

2). 再起動:

[mine@vagrant ~]$ sudo reboot
[sudo] password for mine: 

-

3). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

-

4). デスクトップ画面で確認:

パネルの表示:

→パネルの左の「選択」されている「1」の番号が「白色」から「オレンジ色」になりました

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- -----

10-5. 「スクリーンショット」が使えるか確認:

-

1). 対応するスクリプトの内容を確認:

[mine@vagrant ~]$ cat ~/.config/openbox/scripts/screenshot.sh
#!/bin/bash

# options to be displayed
option0="screen"
option1="area"
option2="window"

# options to be displyed
options="$option0\n$option1\n$option2"

selected="$(echo -e "$options" | rofi -lines 3 -dmenu -p "scrot")"
filename="Screenshot-%Y-%m-%d_%H:%M:%S.png"
case $selected in
    $option0)
        cd ~/Pictures/ && sleep 1 && scrot "$filename";;
    $option1)
        cd ~/Pictures/ && scrot -s "$filename";;
    $option2)
        cd ~/Pictures/ && sleep 1 && scrot -u "$filename";;
esac

-

2). ショートカットキーの割当を確認:

[mine@vagrant ~]$ nano ~/.config/openbox/rc.xml

Ctrl+W で検索 →Search:「scrot」Enter で検索:

    <!-- Take a screenshot, say "Cheeeese!" -->
    <keybind key="Print">
      <action name="Execute">
        <command>scrot ~/Pictures/Screenshot-%Y-%m-%d_%H:%M:%S.png</command>
      </action>
    </keybind>
    <keybind key="W-Print">
      <action name="Execute">
        <command>~/.config/openbox/scripts/screenshot.sh</command>
      </action>
    </keybind>

→Ctrl+X で、終了

-

2つのショートカットキーが定義されています:
  • 「PrintScreen」→ダイアログなしで、全画面の保存:

  •  Windows+「PrintScreen」→ダイアログ表示からモードを選んで、保存:

-

3). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

-

4). デスクトップ画面が表示:

-

5). Windows + Enter で、「端末」を起動:

ssh 接続」ではスクリプトは起動できません:

-

6). スクリプトが動作するか確認:

[mine@vagrant ~]$ ~/.config/openbox/scripts/screenshot.sh

ダイアログが表示:

screen
area
window

→Enter(「screen」指定になります)

-

実際の画面:

-

7). 「PrintScreen」や、 Windows+「PrintScreen」のキーを押してみます:

→手応えがないのが難点:

-

8). ファイルが保存されたか確認:

[mine@vagrant ~]$ ls -1 ~/Pictures/
Screenshot-2024-01-31_13:43:15.png
Screenshot-2024-01-31_13:43:30.png
Screenshot-2024-01-31_13:43:31.png
Screenshot-2024-01-31_13:46:25.png

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- -

10-6. 「ショートカットキー」の割当を「i3-wm」と同じキーに変更:

-

残りの設定:

  • 「ファイルマネージャ」のショートカットキーを「Windows+N」に変更:

  •  エディタの「featherpad」のショートカットキーを「Windows+E」に変更:

-

1). 「ショートカットキー」の割当を修正:

$ nano ~/.config/openbox/rc.xml

Ctrl+W で検索 →Search:「thunar」Enter で検索:

    <keybind key="W-e">
      <action name="Execute">
        <command>thunar</command>  ←(注目)
      </action>
    </keybind>

↓ 置換: 最初に下の部分に数行の改行をしてから、コピー後に修正すると楽。

    <keybind key="W-e">
      <action name="Execute">
        <command>featherpad</command>
      </action>
    </keybind>

    <keybind key="W-n">
      <action name="Execute">
        <command>thunar</command>
      </action>
    </keybind>

余分な空行を Ctrl+K で削除:

→Ctrl+O(小文字のオー)で保存: 保存先を確認して、Enter

-

2). 修正後の「ショートカットキー」の割当を確認:

Ctrl+W で検索 →Search:「applications -->」Enter で検索:

    <!-- Keybindings for running applications -->
    <keybind key="W-Return">
      <action name="Execute">
        <command>xfce4-terminal</command>
      </action>
    </keybind>
    <keybind key="W-w">
      <action name="Execute">
        <command>firefox</command>
      </action>
    </keybind>
    <keybind key="W-e">
      <action name="Execute">
        <command>featherpad</command>
      </action>
    </keybind>
    <keybind key="W-n">
      <action name="Execute">
        <command>thunar</command>
      </action>
    </keybind>
    <keybind key="W-g">
      <action name="Execute">
        <command>geany</command>
      </action>
    </keybind>
    <keybind key="W-v">
      <action name="Execute">
        <command>pavucontrol</command>
      </action>
    </keybind>
    <!-- Take a screenshot, say "Cheeeese!" -->

→Ctrl+X で終了

セーブするか聞いてきたら、Y

保存先を確認して、Enter

-

4). 再起動:

[mine@vagrant ~]$ sudo reboot
[sudo] password for mine: 

-

5). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

-

6). デスクトップ画面が表示:

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

7).「ショートカットキー」の割当を確認:

-

(1). Windows+Enter で、「端末」が起動するか確認:

Windows+Q で、閉じます

-

(2). Windows+W で、「firefox」が起動するか確認:

Windows+Q で、閉じます

-

(3). Windows+E で、「featherpad」が起動するか確認:

Windows+Q で、閉じます

-

(4). Windows+N で、「ファイルマネージャ」が起動するか確認:

Windows+Q で、閉じます

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- --

11. 任意: 個人的によく使う「フォント」や「アプリ」をインストール:

-

設定の修正に使った「テキストエディタ」:

ssh 接続」で修正できるように、端末画面で使える「nano」を使いました:

-

大昔の互換アプリが元で、馴染みのないショートカットキーなのが難点ですが、
ssh 接続」であれば、マウスで範囲指定して、マウスの「中央ボタン」で貼付けできます:

  • Ctrl+W で検索 →Search:「検索文字列」Enter

  • Ctrl+C で現在のカーソル位置を表示

  • Ctrl+K でクリップボードに「行を切取り」: コピー後、その行が削除されます

  • Ctrl+U でクリップボードから「行を貼付け」: 2回で「貼付け」になります

  • Ctrl+O (小文字のオー)で、「保存」: 保存先を確認して、Enter

  • Ctrl+X で、終了

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

インストール手順:

Boxes に「EndeavourOS」(Xfce) をインストールして「Worm」wm を追加(1/2)〈H160-2〉より抜粋:

-

18.「フォント」のインストール:

 →「MiguMix」フォントは、サイトからダウンロードできないのでインストール出来なくなりました:
  「源ノ角ゴシック Code JP」フォントは、インストールできます:

-

19.「アプリ」のインストール:

→「Featherpad」は「項番 8.」で、ESR版の「Firefox」は「項番 9.」でインストールしました:

-

20.「ゲーム」のインストール:

 →以前は成功したけど、現時点では、パッケージのアップデートや、AUR から依存が削除されたりで、状況が変わっているかも:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ---

12. 参考: デスクトップの日本語化:

-

システム全体の日本語化はせず、GUI ユーザのみ日本語化しました:

-

1). ホストOS の端末にて「ssh 接続」してから、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

2). 作業前のロケールの確認:

[mine@vagrant ~]$ locale
LANG=en_US.UTF-8               ←(注目)
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=ja_JP.UTF-8
LC_TIME=ja_JP.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=ja_JP.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=ja_JP.UTF-8
LC_NAME=ja_JP.UTF-8
LC_ADDRESS=ja_JP.UTF-8
LC_TELEPHONE=ja_JP.UTF-8
LC_MEASUREMENT=ja_JP.UTF-8
LC_IDENTIFICATION=ja_JP.UTF-8
LC_ALL=

→OS のインストール時に「英語」と「日本語キーボード」としたら、上記に設定されました

ロケールが混在しています

-

[mine@vagrant ~]$ cat /etc/locale.conf
LANG=en_US.UTF-8
LC_ADDRESS=ja_JP.UTF-8
LC_IDENTIFICATION=ja_JP.UTF-8
LC_MEASUREMENT=ja_JP.UTF-8
LC_MONETARY=ja_JP.UTF-8
LC_NAME=ja_JP.UTF-8
LC_NUMERIC=ja_JP.UTF-8
LC_PAPER=ja_JP.UTF-8
LC_TELEPHONE=ja_JP.UTF-8
LC_TIME=ja_JP.UTF-8

-

[mine@vagrant ~]$ cat /etc/default/locale
LANG=en_US.UTF-8
LC_ADDRESS=ja_JP.UTF-8
LC_IDENTIFICATION=ja_JP.UTF-8
LC_MEASUREMENT=ja_JP.UTF-8
LC_MONETARY=ja_JP.UTF-8
LC_NAME=ja_JP.UTF-8
LC_NUMERIC=ja_JP.UTF-8
LC_PAPER=ja_JP.UTF-8
LC_TELEPHONE=ja_JP.UTF-8
LC_TIME=ja_JP.UTF-8

-

3). 日本語関連のパッケージをインストール:

日本語フォントの確認:

[mine@vagrant ~]$ pacman -Ss noto-font
extra/noto-fonts 1:24.1.1-1 [installed]
    Google Noto TTF fonts
extra/noto-fonts-cjk 20230817-1 [installed]
    Google Noto CJK fonts
extra/noto-fonts-emoji 1:2.042-1 [installed]
    Google Noto emoji fonts
extra/noto-fonts-extra 1:24.1.1-1 [installed]
    Google Noto TTF fonts - additional variants

→インストール済みです

-

4). 「~/.xprofile」の作成:

[mine@vagrant ~]$ nano ~/.xprofile

下記を追記:

export LANG=ja_JP.UTF-8

Ctrl+O (小文字のオー)で、「保存」: 保存先を確認して、Enter

Ctrl+X で、終了

-

5). 再起動:

[mine@vagrant ~]$ sudo reboot
[sudo] password for mine: 

-

6). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

-

7). 「デスクトップ」画面が表示:

-

GUI でログインすると、日本語化されました:

→「Welcome」画面が日本語で表示されました:

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

ssh 接続」の場合に、日本語化するには:

ssh 接続」だと「.xprofile」ファイルが読み込まれないので、日本語化されません:

なので、「.xprofile」ファイルを読み込みます:

[mine@vagrant ~]$ source ~/.xprofile

または、

[mine@vagrant ~]$ source .xprofile

→ピリオド「.」があるので注意

-

ロケールの確認:
[mine@vagrant ~]$ locale
LANG=ja_JP.UTF-8          ←(注目)
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC=ja_JP.UTF-8
LC_TIME=ja_JP.UTF-8
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY=ja_JP.UTF-8
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER=ja_JP.UTF-8
LC_NAME=ja_JP.UTF-8
LC_ADDRESS=ja_JP.UTF-8
LC_TELEPHONE=ja_JP.UTF-8
LC_MEASUREMENT=ja_JP.UTF-8
LC_IDENTIFICATION=ja_JP.UTF-8
LC_ALL=

-

日本語化されたか確認:
[mine@vagrant ~]$ pacman -Ss paru
endeavouros/paru 2.0.1-1 [インストール済み]
    Feature packed AUR helper

→「Installed」の部分が日本語表示になりました

-

なので、日本語化したときに検索するときは:
[mine@vagrant ~]$ paru -Ss paru | grep 済
endeavouros/paru 2.0.1-1 [0 B 8.59 MiB] [インストール済み]
aur/paru 2.0.1-1 [+847 ~28.08] [インストール済み]

→「公式リポジトリ」と「AUR リポジトリ」の両方に登録があります

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ----

13. 参考: 日本語入力:

-

ssh 接続」であれば、ホストOS の入力メソッドが使われるので、 デスクトップ環境で「日本語入力」しないなら作業は要りません。

デスクトップ環境で「日本語入力」する場合は、好みや使用頻度で入力メソッドを選べます。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- -----

13-a. 日本語入力に、「ibus-anthy」を使う場合:

-

ibus-anthy」は「公式リポジトリ」に登録がある(ビルド済みのバイナリな)ので、簡単にインストールできます。 ただし、ヒット率はそこそこです:

-

検索:

[mine@vagrant ~]$ pacman -Ss ibus-anthy
extra/ibus-anthy 1.5.15-1
    Japanese input method Anthy IMEngine for IBus Framework

→日本語入力が少ないときにオススメ

-

1). 表示メッセージの日本語化:

[mine@vagrant ~]$ source .xprofile

-

2). インストール:

[mine@vagrant ~]$ paru -S ibus-anthy
パッケージ (2)    新しいバージョン  最終的な変化  ダウンロード容量
extra/anthy       9100h-6              23.58 MiB          5.31 MiB
extra/ibus-anthy  1.5.15-1              9.09 MiB          0.97 MiB

-

3). 設定ファイルの作成:

-

(1). 「~/.xprofile」の作成:
[mine@vagrant ~]$ nano ~/.xprofile

↓ ファイルの最後に下記の 3行を追記:

export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus

→Ctrl+O (小文字のオー)で「保存」: 保存先を確認して、Enter

→Ctrl+X で終了:

-

(2). 自動起動に設定:
[mine@vagrant ~]$ nano ~/.config/openbox/autostart

↓ ファイルの最後に下記の 2行を追記:

# Start Japanese Input Daemon
ibus-daemon -r -d -x &

→Ctrl+O (小文字のオー)で「保存」: 保存先を確認して、Enter

→Ctrl+X で終了:

-

4). 再起動:

[mine@vagrant ~]$ sudo reboot
[sudo] mine のパスワード:

-

5). 「仮想マシン」のログイン画面にて、「mine」ユーザを選んで、パスワード入力:

GUI でログインすると、日本語化されました:

-

6). 「ibus-anthy」の設定:

-


6-1). デフォルトの入力メソッドを切り替えるキーを「半角/全角」キーに割当て:

-

(1). メニュー →設定 →「IBus の設定」

→「IBus の設定」画面表示:

-

(2). 設定の変更:

-

「一般」タブ

次の入力メソッド: 「space」

その右の「…」→「削除」をクリック

-

「Super」のチェックを外します

「space」の右の「…」→「無効」をクリック→「新しいアクセレータ」→「半角/全角」キー

→「Zenkaku_Hankaku」に変わりました

→「追加」→「OK」

次の入力メソッド: 「Zenkaku_Hankaku」に変わりました

-

「閉じる」をクリックせずに、下記の作業へ:

-


6-2). 日本語オンとオフを別々のキーに割り当て:

- 「ひらがな」にて日本語オン(日本語入力)
- 「無変換」にて日本語オフ(英文字入力)

-

(1). 「入力メソッド」タブ

→青色の「日本語 - Anthy」を選んで、「設定」ボタンをクリック

→「IBus-Anthy の設定」画面表示

-

(2). 「半角英数」キーの割り当て:

「キー割り当て」タブ

-

latin_mode [] を選んで、「編集」

キーコード右の「…」→「無変換」キー→「Muhenkan」→「追加」→「OK」

-

下記の表示に変わりました:

latin_mode       [Muhenkan]

-

(3). 「ひらがな」キーの割り当て

hiragana_mode [] を選んで、「編集」

キーコード右の「…」→「ひらがな」キー→「Hiragana_Katakana」→「追加」→「OK」

-

下記の表示に変わりました:

hiragana_mode  [Hiragana_Katakana] 

→「閉じる」

-

ibus-anthy」は、パネルのアイコン「あ」が水色です

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ----- -

13-b. 日本語入力に、「ibus-mozc」を使う場合:

-

「EndeavourOS」だと「公式リポジトリ」でなく、「AUR リポジトリ」で提供されています:

-

AUR パッケージで、依存パッケージの「mozc」も含めてビルドが実行されるので、インストールに時間がかかります:

ヒット率は上がりますが、インストールや更新に 2時間?ほどかかるのが難点です:

なので、自動更新しない設定にして、手動で更新する運用にしています:

-

個人的に思うこと:

「mozc」は google の技術を利用しており、google なのでセキュリティでの更新が多く、なかなかバイナリ化できないみたい。 使用される頻度がもっと上がれば「公式リポジトリ」への登録がありそうですが、更新のたびに時間をかけてまでビルドする人は少ないので、それは期待できません。

ちなみに、他のLinux ディストリビューションでパッケージ化(バイナリ化)されているのは、依存が複雑で、簡単にビルドできないから。

-

検索:

[mine@vagrant ~]$ paru -Ss ibus-mozc
aur/ibus-mozc 2.29.5346.102-2 [+16 ~0.03]
    Mozc module for IBus

→日本語入力が多いときや、「mozc」が好みの人にオススメ

-

ibus-mozc」のインストールは、

CPU パワーと時間がかかるので、PC を使わない、時間に余裕があるときに実施:

-

1). メッセージの日本語化:

[mine@vagrant ~]$ source .xprofile

-

2). 応答を省略してインストール:

[mine@vagrant ~]$ paru -S --noconfirm ibus-mozc

途中の、数字の入力、「Y/n」と PKGBUILD のレビューはスキップされます。
ただし、パスワード入力は必要です:

-

3). 途中のパスワード入力を見逃した場合:

:
[sudo] mine のパスワード:
sudo: パスワードの読み込みがタイムしました
sudo: パスワードが必要です
エラー: パッケージのビルドに失敗しました: ibus-mozc-2.29.5346.102-2

-

再実行:

[mine@vagrant ~]$ paru -S --noconfirm ibus-mozc

パスワード入力は、3回あるので、
2回ほど見逃して、何度か再実行しています。少しづつ時間は短くなります。

-

完了後の確認:

[mine@vagrant ~]$ paru -Ss ibus-mozc | grep 済
aur/ibus-mozc 2.29.5346.102-2 [+16 ~0.03] [インストール済み]

-

4). 設定ファイルの作成:

-

(1). 「~/.xprofile」の作成:
[mine@vagrant ~]$ nano ~/.xprofile

↓ ファイルの最後に下記の 3行を追記:

export GTK_IM_MODULE=ibus
export XMODIFIERS=@im=ibus
export QT_IM_MODULE=ibus

→Ctrl+O (小文字のオー)で「保存」: 保存先を確認して、Enter

→Ctrl+X で終了:

-

(2). 自動起動に設定:
[mine@vagrant ~]$ nano ~/.config/openbox/autostart

↓ ファイルの最後に下記の行を追記:

# Start Japanese Input Daemon
ibus-daemon -r -d -x &

→Ctrl+O (小文字のオー)で「保存」: 保存先を確認して、Enter

→Ctrl+X で終了:

-

5). 再起動:

[mine@vagrant ~]$ sudo reboot
[sudo] mine のパスワード:

-

6). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

GUI でログインすると、日本語化されました:

-

7). 「ibus-mozc」の設定:

-


7-1). パネルのキーボードアイコン「JA」をクリックすると、ゴミが表示されるので修正:

日本語 - Mozc
日本語 - Mozc:&#x3042  ←ゴミ表示
日本語 - Japanese

-

(1). メニュー →「設定」→「IBus の設定」→「IBus の設定」画面:

-

「入力メソッド」タブ

日本語 - Mozc
日本語 - Mozc:&#x3042  ←(ゴミ: これ以外もあったりします)
日本語 - 日本語

-

(2). 「日本語 - Mozc:&#x3042」を選んで、「削除」

最終的に下記だけ残します:

日本語 - Mozc
日本語 - 日本語

-


7-2). 任意:「Windows+スペース」では面倒なので、「半角/全角」キーに割当てを変更:

-

(1). 引き続き、

-

「一般」タブ

「キーボードショートカット」

-

(2). 「次の入力メソッド: space」の右にある「…」をクリック

「Super」のチェックを外して、キーコード「space」の右にある「…」をクリック

→「無効」をクリック→「新しいアクセレータ」で「半角/全角」キーを押します。

「追加」ボタンを押します。

-

→「Zenkaku_Hankaku」に変わりました。

→「OK」

→「閉じる」

-

もし、「 space」が残っていたら、「削除」

-

(3). これで、「半角/全角」キーで、「JA」、「あ」の切り替えができます。

-


7-3). 任意:「日本語 キーボード」の個別のキーに割当てを定義:

「半角/全角」キーだけで日本語オン・オフするなら、この作業は不要です。

-

(1). パネルの「JA」または、「あ」を左クリック → ツール →プロパティ →「Mozc プロパティ」画面

-

「一般」タブ

-

(2). 左下の「初期値に戻す」 →OK

-

(3). キー設定の選択: →「カスタム」を選んで右の「編集…」

→「Mozc キー設定」画面

-

(4). 左下の「編集」→「定義済みのキーマップからインポート」→「MS-IME

-

(5). 「Mozc キー設定」画面(ウィンドウはマウスで縦に広げておくと、作業しやすいです)

上段にある表題の「入力キー」の項目名をクリックして、ソート

-

(6). 下記のキーのコマンドを修正:
モード 入力キー コマンド 備考
変換前入力中 Hiragana IME を有効化
変換中 Hiragana IME を有効化
直接入力 Hiragana IME を有効化
入力文字なし Hiragana IME を有効化
:
変換前入力中 Muhenkan IME を無効化
変換中 Muhenkan IME を無効化
直接入力 Muhenkan IME を無効化 エントリーの追加が必要
入力文字なし Muhenkan IME を無効化

-

→OK →OK

→適用 →OK

→「閉じる」

-

(7). これで「あ」を見なくても操作できます:
  • 「ひらがな」キー(Hiragana)で「IME オン」→日本語
  • 「無変換」キー(Muhenkan)で「IME オフ」→英語

(mozc は入力メソッドのオン、オフを別々のキーに簡単に割当てできるので便利です)

-

ibus-mozc」は、パネルのアイコン「あ」がオレンジ色です

-


8). システム更新から「ibus-mozc」を除外:

→手順は「こちら」を参照:

-

9). システム更新から除外している「ibus-mozc」を、3ヶ月ぶりに手動で更新:

-

ibus-mozc」の更新がありました:
$ paru
[sudo] パスワード:
:: パッケージデータベースの同期中...
 endeavouros は最新です
 core は最新です
 extra は最新です
 multilib は最新です
:: システム全体の更新を開始...
 何も行うことがありません
:: AUR の更新を確認しています...
:: 開発の更新を確認しています...
警告: ibus-mozc: パッケージのアップグレードを無視 (2.29.5160.102-1 => 2.29.5268.102-1) ←(注目)
警告: mozc: パッケージのアップグレードを無視 (2.29.5160.102-1 => 2.29.5268.102-1)      ←(注目)
 何も行うことがありません

→警告があっても 3ヶ月ほど無視。使い勝手は変わりません。

-

時間がかかるので、時間の余裕があるときに実施:
[mine@vagrant ~]$ paru
[mine@vagrant ~]$ paru -S --noconfirm ibus-mozc

→たぶん、パスワード入力を見逃すと思います。再実行。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ----- --

14. 任意:「Welcome」画面に、「個人用コマンド」(Personal Commands) タブを追加:

-

手順は「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ----- ---

15. 参考: 「Openbox」のファイルの構成を確認:

-

確認のみ。修正前の設定です:

2024-02-02 現在:

-

1). 「ホーム」フォルダの確認:

[mine@vagrant ~]$ ls -1Ap
.bash_history
.bash_logout
.bash_profile
.bashrc
.cache/
.config/
Desktop/
.dmrc
Documents/
Downloads/
.gtkrc-2.0
.local/
Music/
Pictures/
Public/
Templates/
.themes/
Videos/
.Xauthority
.xsession-errors
.xsession-errors.old

-

2). 「.config」フォルダの確認:

[mine@vagrant ~]$ ls -1Ap .config/
dconf/
dunst/
EOS-greeter.conf
eos-update-notifier.first_init
featherpad/
gtk-3.0/
jgmenu/
nitrogen/
openbox/
picom.conf.example
pulse/
rofi/
systemd/
tint2/
user-dirs.dirs
user-dirs.locale
xed/
xfce4/

-


3). 「openbox」の設定ファイルを確認:

-

(1).「~/.config/openbox/」フォルダの確認:
[mine@vagrant ~]$ ls -1Ap .config/openbox/
autostart
menu.xml
menu.xml.bak
rc.xml
scripts/

-

(2).「openbox/scripts/」の確認:
[mine@vagrant ~]$ ls -1Ap ~/.config/openbox/scripts/
brightness-control
low_bat_notifier.sh
screenshot.sh
volume-control

-

(3).「openbox/autostart」の確認:

自動起動アプリの設定:

Openbox セッションが開始したときにどのアプリケーションを起動するか記述:

コマンドはアンパサンド (&) を付けて終了する必要があります:

[mine@vagrant ~]$ cat ~/.config/openbox/autostart
# compositor - background process + disable shadowing effects during session
#picom -CGb &
# edit: (27 nov. 2022) picom now starts automatic vie xdg autostart (dex is enabled here) 
# it will read config under:
# ~/.config/picom.conf  see ~/.config/picom.conf.example for reference or copy default one there 
# and edit to your needs:
# cp /etc/xdg/picom.conf.example ~/.config/picom.conf

# notifications
/usr/bin/dunst &

# panel - taskbar, system tray, battery, clock
tint2 &

# network manager
nm-applet &

# Autostart
dex -a -s /etc/xdg/autostart/:~/.config/autostart/ &

# Set display from arandr saved script
sh ~/.screenlayout/monitor.sh &

# Polkit
/usr/lib/polkit-gnome/polkit-gnome-authentication-agent-1 &

# Wallpaper
nitrogen --restore &

# Low battery notifier
~/.config/openbox/scripts/low_bat_notifier.sh &

-

(4).「openbox/menu.xml」の確認:

右クリック「メニュー」の設定:

[mine@vagrant ~]$ cat ~/.config/openbox/menu.xml
<?xml version="1.0" encoding="UTF-8"?>
<openbox_menu
    xmlns="http://openbox.org/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://openbox.org/
    file:///usr/share/openbox/menu.xsd">
    <menu id="root-menu" label="Openbox 3">
        <item label="Terminal emulator">
            <action name="Execute">
                <execute>xfce4-terminal</execute>
            </action>
        </item>
        <item label="Web browser">
            <action name="Execute">
                <execute>firefox</execute>
            </action>
        </item>
        <separator />
        <menu execute="xdg_menu --format openbox3-pipe --root-menu /etc/xdg/menus/arch-applications.menu" id="apps" label="Applications"/>
        <menu id="client-list-menu" />
        <separator />
        <item label="Configurations">
            <action name="Execute">
                <execute>obconf</execute>
            </action>
        </item>
        <item label="Reconfigure">
            <action name="Reconfigure" />
        </item>
        <separator />
        <menu id="exit" label="Exit" >
            <item label="Logout">
                <action name="Exit" />
            </item>
            <item label="Suspend">
                <action name="Execute">
                    <execute>systemctl suspend</execute>
                </action>
            </item>
            <item label="Hibernate">
                <action name="Execute">
                    <execute>systemctl hibernate</execute>
                </action>
            </item>
            <item label="Reboot">
                <action name="Execute">
                    <execute>systemctl reboot</execute>
                </action>
            </item>
            <item label="Shutdown">
                <action name="Execute">
                    <execute>systemctl poweroff</execute>
                </action>
            </item>
        </menu>
    </menu>
</openbox_menu>

-

(5).「openbox/rc.xml」の確認:
[mine@vagrant ~]$ cat ~/.config/openbox/rc.xml
<?xml version="1.0" encoding="UTF-8"?>
<openbox_config xmlns="http://openbox.org/3.4/rc" xmlns:xi="http://www.w3.org/2001/XInclude">
  <resistance>
    <strength>5</strength>
    <screen_edge_strength>5</screen_edge_strength>
  </resistance>
  <focus>
    <focusNew>yes</focusNew>
    <!-- Always try to focus new windows when they appear. other rules do apply -->
    <followMouse>no</followMouse>
    <!-- Move focus to a window when you move the mouse into it -->
    <focusLast>yes</focusLast>
    <!-- Focus the last used window when changing desktops, instead of the one 
        under the mouse pointer. when followMouse is enabled -->
    <underMouse>no</underMouse>
    <!-- Move focus under the mouse, even when the mouse is not moving -->
    <focusDelay>200</focusDelay>
    <!-- When followMouse is enabled, the mouse must be inside the window for
        this many milliseconds (1000 = 1 sec) before moving focus to it -->
    <raiseOnFocus>yes</raiseOnFocus>
    <!-- When followMouse is enabled, and a window is given focus by moving the 
        mouse into it, also raise the window -->
  </focus>
  <placement>
    <policy>Smart</policy>
    <!-- 'Smart' or 'UnderMouse' -->
    <center>yes</center>
    <!-- Whether to place windows in the center of the free area found or 
        the top left corner -->
    <monitor>Primary</monitor>
    <!-- With Smart placement on a multi-monitor system, try to place new windows 
        on: 'Any' - any monitor, 'Mouse' - where the mouse is, 'Active' - where 
        the active window is, 'Primary' - only on the primary monitor -->
    <primaryMonitor>1</primaryMonitor>
    <!-- The monitor where Openbox should place popup dialogs such as the 
        focus cycling popup, or the desktop switch popup.   It can be an index 
        from 1, specifying a particular monitor.    Or it can be one of the 
        following: 'Mouse' - where the mouse is, or 'Active' - where 
        the active window is -->
  </placement>
  <theme>
    <name>Arc-Darker</name>
    <titleLayout>LIMC</titleLayout>
    <!--
        Available characters are NDSLIMC, each can occur at most once.
        N: window icon
        L: window label (AKA title).
        I: iconify
        M: maximize
        C: close
        S: shade (roll up/down)
        D: omnipresent (on all desktops).
        -->
    <keepBorder>yes</keepBorder>
    <animateIconify>yes</animateIconify>
    <font place="ActiveWindow">
      <name>UbuntuMono</name>
      <size>10</size>
      <!-- font size in points -->
      <weight>Normal</weight>
      <!-- 'bold' or 'normal' -->
      <slant>Normal</slant>
      <!-- 'italic' or 'normal' -->
    </font>
    <font place="InactiveWindow">
      <name>UbuntuMono</name>
      <size>10</size>
      <!-- font size in points -->
      <weight>Normal</weight>
      <!-- 'bold' or 'normal' -->
      <slant>Normal</slant>
      <!-- 'italic' or 'normal' -->
    </font>
    <font place="MenuHeader">
      <name>UbuntuMono</name>
      <size>10</size>
      <!-- font size in points -->
      <weight>Normal</weight>
      <!-- 'bold' or 'normal' -->
      <slant>Normal</slant>
      <!-- 'italic' or 'normal' -->
    </font>
    <font place="MenuItem">
      <name>UbuntuMono</name>
      <size>10</size>
      <!-- font size in points -->
      <weight>Normal</weight>
      <!-- 'bold' or 'normal' -->
      <slant>Normal</slant>
      <!-- 'italic' or 'normal' -->
    </font>
    <font place="ActiveOnScreenDisplay">
      <name>UbuntuMono</name>
      <size>10</size>
      <!-- font size in points -->
      <weight>Normal</weight>
      <!-- 'bold' or 'normal' -->
      <slant>Normal</slant>
      <!-- 'italic' or 'normal' -->
    </font>
    <font place="InactiveOnScreenDisplay">
      <name>UbuntuMono</name>
      <size>10</size>
      <!-- font size in points -->
      <weight>Normal</weight>
      <!-- 'bold' or 'normal' -->
      <slant>Normal</slant>
      <!-- 'italic' or 'normal' -->
    </font>
  </theme>
  <desktops>
    <!-- this stuff is only used at startup, pagers allow you to change them
        during a session. these are default values to use when other ones are not
        already set by other applications, or saved in your session.
        Use obconf if you want to change these without having to log out
        and back in -->
    <number>9</number>
    <firstdesk>1</firstdesk>
    <names>
      <name>1</name>
      <name>2</name>
      <name>3</name>
      <name>4</name>
      <name>5</name>
      <name>6</name>
      <name>7</name>
      <name>8</name>
      <name>9</name>
    </names>
    <popupTime>1000</popupTime>
    <!-- The number of milliseconds to show the popup for when switching
        desktops. Set this to 0 to disable the popup. -->
  </desktops>
  <resize>
    <drawContents>yes</drawContents>
    <popupShow>Nonpixel</popupShow>
    <!-- 'Always', 'Never', or 'Nonpixel' (xterms and such) -->
    <popupPosition>Center</popupPosition>
    <!-- 'Center', 'Top', or 'Fixed' -->
    <popupFixedPosition>
      <!-- these are used if popupPosition is set to 'Fixed' -->
      <x>10</x>
      <!-- positive number for distance from left edge, negative number for
            distance from right edge, or 'Center' -->
      <y>10</y>
      <!-- positive number for distance from top edge, negative number for
            distance from bottom edge, or 'Center' -->
    </popupFixedPosition>
  </resize>
  <!-- You can reserve a portion of your screen where windows will not cover when
    they are maximized, or when they are initially placed.
    Many programs reserve space automatically, but you can use this in other
    cases. -->
  <margins>
    <top>0</top>
    <bottom>0</bottom>
    <left>0</left>
    <right>0</right>
  </margins>
  <dock>
    <position>Bottom</position>
    <!-- (Top|Bottom)(Left|Right|)|Top|Bottom|Left|Right|Floating -->
    <floatingX>0</floatingX>
    <floatingY>0</floatingY>
    <noStrut>no</noStrut>
    <stacking>Above</stacking>
    <!-- 'Above', 'Normal', or 'Below' -->
    <direction>Horizontal</direction>
    <!-- 'Vertical' or 'Horizontal' -->
    <autoHide>no</autoHide>
    <hideDelay>300</hideDelay>
    <!-- in milliseconds (1000 = 1 second) -->
    <showDelay>300</showDelay>
    <!-- in milliseconds (1000 = 1 second) -->
    <moveButton>Middle</moveButton>
    <!-- 'Left', 'Middle', 'Right' -->
  </dock>
  <keyboard>
    <chainQuitKey>C-g</chainQuitKey>
    <!-- Keybindings for desktop switching -->
    <keybind key="C-A-Left">
      <action name="GoToDesktop">
        <to>left</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="C-A-Right">
      <action name="GoToDesktop">
        <to>right</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <!-- Sent window to next or previous workspace -->
    <keybind key="W-S-Left">
      <action name="SendToDesktop">
        <to>left</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-Right">
      <action name="SendToDesktop">
        <to>right</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <!-- Switch to another workspace -->
    <keybind key="W-1">
      <action name="GoToDesktop">
        <to>1</to>
      </action>
    </keybind>
    <keybind key="W-2">
      <action name="GoToDesktop">
        <to>2</to>
      </action>
    </keybind>
    <keybind key="W-3">
      <action name="GoToDesktop">
        <to>3</to>
      </action>
    </keybind>
    <keybind key="W-4">
      <action name="GoToDesktop">
        <to>4</to>
      </action>
    </keybind>
    <keybind key="W-4">
      <action name="GoToDesktop">
        <to>4</to>
      </action>
    </keybind>
    <keybind key="W-5">
      <action name="GoToDesktop">
        <to>5</to>
      </action>
    </keybind>
    <keybind key="W-6">
      <action name="GoToDesktop">
        <to>6</to>
      </action>
    </keybind>
    <keybind key="W-7">
      <action name="GoToDesktop">
        <to>7</to>
      </action>
    </keybind>
    <keybind key="W-8">
      <action name="GoToDesktop">
        <to>8</to>
      </action>
    </keybind>
    <keybind key="W-9">
      <action name="GoToDesktop">
        <to>9</to>
      </action>
    </keybind>
    <!-- Sent window to worspace number -->
    <keybind key="W-S-1">
      <action name="SendToDesktop">
        <to>1</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-2">
      <action name="SendToDesktop">
        <to>2</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-3">
      <action name="SendToDesktop">
        <to>3</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-4">
      <action name="SendToDesktop">
        <to>4</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-5">
      <action name="SendToDesktop">
        <to>5</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-6">
      <action name="SendToDesktop">
        <to>6</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-7">
      <action name="SendToDesktop">
        <to>7</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-8">
      <action name="SendToDesktop">
        <to>8</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <keybind key="W-S-9">
      <action name="SendToDesktop">
        <to>9</to>
        <wrap>no</wrap>
      </action>
    </keybind>
    <!-- Keybindings for Aero Snap -->
    <keybind key="W-Right">
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo">
        <x>-0</x>
        <y>+0</y>
        <width>50/100</width>
        <height>100/100</height>
      </action>
    </keybind>
    <keybind key="W-Left">
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo">
        <x>+0</x>
        <y>+0</y>
        <width>50/100</width>
        <height>100/100</height>
      </action>
    </keybind>
    <keybind key="W-Up">
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo">
        <width>75/100</width>
        <height>75/100</height>
      </action>
      <action name="MoveToCenter"/>
    </keybind>
    <keybind key="W-Down">
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo">
        <width>50/100</width>
        <height>50/100</height>
      </action>
      <action name="MoveToCenter"/>
    </keybind>
    <keybind key="W-S-Up">
      <action name="UnmaximizeFull"/>
      <action name="MoveResizeTo">
        <width>75/100</width>
        <height>75/100</height>
      </action>
      <action name="MoveToCenter"/>
    </keybind>
    <!-- Keybindings for moving window to edge -->
    <keybind key="W-C-Right">
      <action name="MoveToEdge">
        <direction>east</direction>
      </action>
    </keybind>
    <keybind key="W-C-Left">
      <action name="MoveToEdge">
        <direction>west</direction>
      </action>
    </keybind>
    <keybind key="W-C-Up">
      <action name="MoveToEdge">
        <direction>north</direction>
      </action>
    </keybind>
    <keybind key="W-C-Down">
      <action name="MoveToEdge">
        <direction>south</direction>
      </action>
    </keybind>
    <keybind key="W-a">
      <action name="MoveToCenter"/>
    </keybind>
    <!-- Keybindings for undecorate, fullscreen, minimize,
        roll-up, stick, resize, move, close, and window menu -->
    <keybind key="W-t">
      <action name="ToggleDecorations"/>
    </keybind>
    <keybind key="W-f">
      <action name="ToggleMaximize"/>
    </keybind>
    <keybind key="W-z">
      <action name="Iconify"/>
    </keybind>
    <keybind key="W-u">
      <action name="ToggleShade"/>
    </keybind>
    <keybind key="W-s">
      <action name="ToggleOmnipresent"/>
    </keybind>
    <keybind key="W-r">
      <action name="Resize"/>
    </keybind>
    <keybind key="W-m">
      <action name="Move"/>
    </keybind>
    <keybind key="A-F4">
      <action name="Close"/>
    </keybind>
    <keybind key="W-q">
      <action name="Close"/>
    </keybind>
    <keybind key="A-space">
      <action name="ShowMenu">
        <menu>client-menu</menu>
      </action>
    </keybind>
    <!-- Keybindings for window switching -->
    <keybind key="A-Tab">
      <action name="NextWindow">
        <dialog>list</dialog>
        <bar>no</bar>
        <finalactions>
          <action name="Focus"/>
          <action name="Raise"/>
          <action name="Unshade"/>
        </finalactions>
      </action>
    </keybind>
    <keybind key="A-S-Tab">
      <action name="PreviousWindow">
        <dialog>list</dialog>
        <bar>no</bar>
        <finalactions>
          <action name="Focus"/>
          <action name="Raise"/>
          <action name="Unshade"/>
        </finalactions>
      </action>
    </keybind>
    <keybind key="C-A-Down">
      <action name="NextWindow">
        <dialog>list</dialog>
        <bar>yes</bar>
        <raise>yes</raise>
        <finalactions>
          <action name="Focus"/>
          <action name="Raise"/>
          <action name="Unshade"/>
        </finalactions>
      </action>
    </keybind>
    <keybind key="C-A-Up">
      <action name="NextWindow">
        <dialog>list</dialog>
        <bar>yes</bar>
        <raise>yes</raise>
        <finalactions>
          <action name="Focus"/>
          <action name="Raise"/>
          <action name="Unshade"/>
        </finalactions>
      </action>
    </keybind>
    <!-- Keybindings for window switching with the arrow keys -->
    <keybind key="W-A-Right">
      <action name="DirectionalCycleWindows">
        <direction>right</direction>
        <dialog>no</dialog>
      </action>
    </keybind>
    <keybind key="W-A-Left">
      <action name="DirectionalCycleWindows">
        <direction>left</direction>
        <dialog>no</dialog>
      </action>
    </keybind>
    <keybind key="W-A-Up">
      <action name="DirectionalCycleWindows">
        <direction>up</direction>
        <dialog>no</dialog>
      </action>
    </keybind>
    <keybind key="W-A-Down">
      <action name="DirectionalCycleWindows">
        <direction>down</direction>
        <dialog>no</dialog>
      </action>
    </keybind>
    <!-- Keybindings for startmenu   -->
    <keybind key="W-d">
      <action name="Execute">
        <command>rofi -modi drun -show drun -line-padding 4 \
                -columns 2 -padding 50 -hide-scrollbar -terminal termite \
                -show-icons -drun-icon-theme "Arc-X-D" -font "Droid Sans Regular 10"</command>
      </action>
    </keybind>
    <keybind key="W-Tab">
      <action name="Execute">
        <command>rofi -modi drun -show window -line-padding 4 \
                -columns 2 -padding 50 -hide-scrollbar -terminal termite \
                -show-icons -drun-icon-theme "Arc-X-D" -font "Droid Sans Regular 10"</command>
      </action>
    </keybind>
    <keybind key="W-space">
      <action name="ShowMenu">
        <menu>root-menu</menu>
      </action>
    </keybind>
    <!-- Keybindings for running applications -->
    <keybind key="W-Return">
      <action name="Execute">
        <command>xfce4-terminal</command>
      </action>
    </keybind>
    <keybind key="W-w">
      <action name="Execute">
        <command>firefox</command>
      </action>
    </keybind>
    <keybind key="W-e">
      <action name="Execute">
        <command>thunar</command>
      </action>
    </keybind>
    <keybind key="W-g">
      <action name="Execute">
        <command>geany</command>
      </action>
    </keybind>
    <keybind key="W-v">
      <action name="Execute">
        <command>pavucontrol</command>
      </action>
    </keybind>
    <!-- Take a screenshot, say "Cheeeese!" -->
    <keybind key="Print">
      <action name="Execute">
        <command>scrot ~/Pictures/Screenshot-%Y-%m-%d_%H:%M:%S.png</command>
      </action>
    </keybind>
    <keybind key="W-Print">
      <action name="Execute">
        <command>~/.config/openbox/scripts/screenshot.sh</command>
      </action>
    </keybind>
    <!-- Multimedia keys-->
    <keybind key="XF86AudioStop">
      <action name="Execute">
        <command>mpc stop</command>
      </action>
    </keybind>
    <keybind key="XF86AudioPlay">
      <action name="Execute">
        <command>mpc toggle</command>
      </action>
    </keybind>
    <keybind key="XF86AudioPrev">
      <action name="Execute">
        <command>mpc prev</command>
      </action>
    </keybind>
    <keybind key="XF86AudioNext">
      <action name="Execute">
        <command>mpc next</command>
      </action>
    </keybind>
    <keybind key="XF86MonBrightnessDown">
      <action name="Execute">
     <command>~/.config/openbox/scripts/brightness-control down</command>
      </action>
    </keybind>
    <keybind key="XF86MonBrightnessUp">
      <action name="Execute">
     <command>~/.config/openbox/scripts/brightness-control up</command>
      </action>
    </keybind>
    <keybind key="XF86AudioRaiseVolume">
      <action name="Execute">
     <command>~/.config/openbox/scripts/volume-control up</command>
      </action>
    </keybind>
    <keybind key="XF86AudioLowerVolume">
      <action name="Execute">
     <command>~/.config/openbox/scripts/volume-control down</command>
      </action>
    </keybind>
    <keybind key="XF86AudioMute">
      <action name="Execute">
     <command>~/.config/openbox/scripts/volume-control toggle</command>
      </action>
    </keybind>
    <!-- Reload and Exit keybinds -->
    <keybind key="W-S-e">
      <action name="Execute">
        <command>bash -c ~/.config/rofi/scripts/powermenu.sh</command>
      </action>
    </keybind>
    <keybind key="W-S-r">
      <action name="Reconfigure"/>
    </keybind>
    <keybind key="W-F1">
      <action name="Execute">
        <command>slock</command>
      </action>
    </keybind>
  </keyboard>
  <mouse>
    <dragThreshold>1</dragThreshold>
    <!-- number of pixels the mouse must move before a drag begins -->
    <doubleClickTime>500</doubleClickTime>
    <!-- in milliseconds (1000 = 1 second) -->
    <screenEdgeWarpTime>0</screenEdgeWarpTime>
    <!-- Time before changing desktops when the pointer touches the edge of the
        screen while moving a window, in milliseconds (1000 = 1 second).
        Set this to 0 to disable warping -->
    <screenEdgeWarpMouse>false</screenEdgeWarpMouse>
    <!-- Set this to TRUE to move the mouse pointer across the desktop when
        switching due to hitting the edge of the screen -->
    <context name="Desktop">
      <mousebind button="W-Down" action="Click">
        <action name="GoToDesktop">
          <to>right</to>
          <wrap>no</wrap>
        </action>
      </mousebind>
      <mousebind button="W-Up" action="Click">
        <action name="GoToDesktop">
          <to>left</to>
          <wrap>no</wrap>
        </action>
      </mousebind>
    </context>
    <context name="Frame">
      <mousebind button="W-Down" action="Click">
        <action name="GoToDesktop">
          <to>right</to>
          <wrap>no</wrap>
        </action>
      </mousebind>
      <mousebind button="W-Up" action="Click">
        <action name="GoToDesktop">
          <to>left</to>
          <wrap>no</wrap>
        </action>
      </mousebind>
    </context>
    <context name="Frame">
      <!--
      <mousebind button="W-Left" action="Drag">
        <action name="Move"/>
      </mousebind>
      //-->
      <mousebind button="W-Left" action="Drag">
        <action name="if">
          <maximized>yes</maximized>
          <then>
            <action name="UnmaximizeFull"/>
            <action name="MoveResizeTo">
              <x>center</x>
              <y>current</y>
            </action>
            <action name="Move"/>
          </then>
          <else>
            <action name="Move"/>
          </else>
        </action>
      </mousebind>
      <mousebind button="W-Right" action="Drag">
        <action name="Resize"/>
      </mousebind>
    </context>
    <context name="Titlebar">
      <!--
      <mousebind button="Left" action="Drag">
        <action name="Move"/>
      </mousebind>
      //-->
      <mousebind button="Left" action="Drag">
        <action name="if">
          <maximized>yes</maximized>
          <then>
            <action name="UnmaximizeFull"/>
            <action name="MoveResizeTo">
              <x>center</x>
              <y>current</y>
            </action>
            <action name="Move"/>
          </then>
          <else>
            <action name="Move"/>
          </else>
        </action>
      </mousebind>
      <mousebind button="Left" action="DoubleClick">
        <action name="ToggleMaximizeFull"/>
      </mousebind>
      <mousebind button="Up" action="Click">
        <action name="if">
          <shaded>no</shaded>
          <then>
            <action name="Shade"/>
          </then>
        </action>
      </mousebind>
      <mousebind button="Down" action="Click">
        <action name="if">
          <shaded>yes</shaded>
          <then>
            <action name="Unshade"/>
            <action name="Raise"/>
          </then>
        </action>
      </mousebind>
    </context>
    <context name="Titlebar Top Right Bottom Left TLCorner TRCorner BRCorner BLCorner">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
      </mousebind>
      <mousebind button="Right" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="ShowMenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
    </context>
    <context name="Top">
      <mousebind button="Left" action="Drag">
        <action name="Resize">
          <edge>top</edge>
        </action>
      </mousebind>
    </context>
    <context name="Left">
      <mousebind button="Left" action="Drag">
        <action name="Resize">
          <edge>left</edge>
        </action>
      </mousebind>
    </context>
    <context name="Right">
      <mousebind button="Left" action="Drag">
        <action name="Resize">
          <edge>right</edge>
        </action>
      </mousebind>
    </context>
    <context name="Bottom">
      <mousebind button="Left" action="Drag">
        <action name="Resize">
          <edge>bottom</edge>
        </action>
      </mousebind>
      <mousebind button="Right" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="ShowMenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
    </context>
    <context name="TRCorner BRCorner TLCorner BLCorner">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="Unshade"/>
      </mousebind>
      <mousebind button="Left" action="Drag">
        <action name="Resize"/>
      </mousebind>
    </context>
    <context name="Client">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
      </mousebind>
      <mousebind button="Right" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
      </mousebind>
    </context>
    <context name="Icon">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="Unshade"/>
        <action name="ShowMenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
      <mousebind button="Right" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="ShowMenu">
          <menu>client-menu</menu>
        </action>
      </mousebind>
    </context>
    <context name="AllDesktops">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="Unshade"/>
      </mousebind>
      <mousebind button="Left" action="Click">
        <action name="ToggleOmnipresent"/>
      </mousebind>
    </context>
    <context name="Shade">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
      </mousebind>
      <mousebind button="Left" action="Click">
        <action name="ToggleShade"/>
      </mousebind>
    </context>
    <context name="Iconify">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
      </mousebind>
      <mousebind button="Left" action="Click">
        <action name="Iconify"/>
      </mousebind>
    </context>
    <context name="Maximize">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="Unshade"/>
      </mousebind>
      <mousebind button="Left" action="Click">
        <action name="ToggleMaximize"/>
      </mousebind>
    </context>
    <context name="Close">
      <mousebind button="Left" action="Press">
        <action name="Focus"/>
        <action name="Raise"/>
        <action name="Unshade"/>
      </mousebind>
      <mousebind button="Left" action="Click">
        <action name="Close"/>
      </mousebind>
    </context>
    <context name="Desktop">
      <mousebind action="Click" button="Left">
        <action name="Focus"/>
      </mousebind>
      <mousebind action="Click" button="A-Up">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind action="Click" button="A-Down">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
      <!-- Mouse Middle Scroll to Switch Workspace on Desktop //-->
      <mousebind action="Click" button="Up">
        <action name="GoToDesktop">
          <to>previous</to>
        </action>
      </mousebind>
      <mousebind action="Click" button="Down">
        <action name="GoToDesktop">
          <to>next</to>
        </action>
      </mousebind>
    </context>
    <context name="Root">
      <!-- Menus -->
      <mousebind button="Right" action="Press">
        <action name="ShowMenu">
          <menu>root-menu</menu>
        </action>
      </mousebind>
      <mousebind button="Left" action="DoubleClick">
        <action name="ShowMenu">
          <menu>client-list-combined-menu</menu>
        </action>
      </mousebind>
      <mousebind action="Press" button="Middle">
        <action name="ToggleShowDesktop"/>
      </mousebind>
    </context>
  </mouse>
  <menu>
    <file>menu.xml</file>
    <hideDelay>200</hideDelay>
    <!-- if a press-release lasts longer than this setting (in milliseconds), 
        the menu is hidden again -->
    <middle>no</middle>
    <!-- center submenus vertically about the parent entry -->
    <submenuShowDelay>100</submenuShowDelay>
    <!-- time to delay before showing a submenu after hovering over the parent entry.
        if this is a negative value, then the delay is infinite and the
        submenu will not be shown until it is clicked on -->
    <submenuHideDelay>400</submenuHideDelay>
    <!-- time to delay before hiding a submenu when selecting another entry in parent menu
        if this is a negative value, then the delay is infinite and the
        submenu will not be hidden until a different submenu is opened -->
    <showIcons>Yes</showIcons>
    <!-- controls if icons appear in the client-list-(combined-)menu -->
    <manageDesktops>yes</manageDesktops>
    <!-- show the manage desktops section in the client-list-(combined-)menu -->
  </menu>
</openbox_config>

ウィンドウ画面のタイトルバーの設定:

-

(6).「~/.config/tint2/tint2rc」の確認:

パネルの設定:

[mine@vagrant ~]$ cat ~/.config/tint2/tint2rc
#---- Generated by tint2conf 6077 ----
# See https://gitlab.com/o9000/tint2/wikis/Configure for 
# full documentation of the configuration options.
#-------------------------------------
# Gradients
# Gradient 1
gradient = vertical
start_color = #000000 80
end_color = #000000 80
color_stop = 70.000000 #1c1c1c 80

#-------------------------------------
# Backgrounds
# Background 1: Active desktop name, Battery, Default task, Panel, Systray, Tooltip
rounded = 0
border_width = 0
border_sides = 
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #383c4a 100
border_color = #3b1cb2 0
gradient_id = 0
background_color_hover = #553078 80
border_color_hover = #9242da 80
gradient_id_hover = 0
background_color_pressed = #1500ce 80
border_color_pressed = #0004e4 80
gradient_id_pressed = 1

# Background 2: Inactive taskbar, Normal task
rounded = 0
border_width = 2
border_sides = B
border_content_tint_weight = 100
background_content_tint_weight = 25
background_color = #777777 0
border_color = #777777 100
background_color_hover = #464646 100
border_color_hover = #cccccc 30
background_color_pressed = #1e1e1e 100
border_color_pressed = #777777 30

# Background 3: Active task
rounded = 0
border_width = 2
border_sides = B
border_content_tint_weight = 100
background_content_tint_weight = 100
background_color = #ffffff 100
border_color = #d9d9d9 100
background_color_hover = #ffffff 73
border_color_hover = #d9d9d9 100
background_color_pressed = #989898 73
border_color_pressed = #d9d9d9 100

# Background 4: Urgent task
rounded = 0
border_width = 0
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #aa4400 100
border_color = #aa7733 100
background_color_hover = #aa4400 100
border_color_hover = #aa7733 100
background_color_pressed = #aa4400 100
border_color_pressed = #aa7733 100

# Background 5: 
rounded = 2
border_width = 1
border_sides = TBLR
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #ffffaa 100
border_color = #999999 100
background_color_hover = #ffffaa 100
border_color_hover = #999999 100
background_color_pressed = #ffffaa 100
border_color_pressed = #999999 100

# Background 6: Iconified task
rounded = 0
border_width = 2
border_sides = B
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #777777 0
border_color = #777777 0
background_color_hover = #bdbdbd 21
border_color_hover = #cccccc 100
background_color_pressed = #777777 21
border_color_pressed = #777777 100

# Background 7: 
rounded = 0
border_width = 2
border_sides = B
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #ffffff 21
border_color = #d9d9d9 100
background_color_hover = #ffffff 21
border_color_hover = #d9d9d9 100
background_color_pressed = #a9a9a9 21
border_color_pressed = #d9d9d9 100

# Background 8: Active taskbar, Launcher, Launcher icon
rounded = 0
border_width = 0
border_sides = 
border_content_tint_weight = 0
background_content_tint_weight = 0
background_color = #383c4a 100
border_color = #3b1cb2 0
gradient_id = 0
background_color_hover = #503434 0
border_color_hover = #bf3f3f 0
gradient_id_hover = 0
background_color_pressed = #1500ce 80
border_color_pressed = #0004e4 80
gradient_id_pressed = 0

#-------------------------------------
# Panel
panel_items = PFLTSBCP
panel_size = 100% 35
panel_margin = 0 0
panel_padding = 0 0 15
panel_background_id = 1
wm_menu = 1
panel_dock = 1
panel_pivot_struts = 1
panel_position = bottom center horizontal
panel_layer = top
panel_monitor = all
panel_shrink = 0
autohide = 0
autohide_show_timeout = 10
autohide_hide_timeout = 0.5
autohide_height = 1
strut_policy = follow_size
panel_window_name = tint2
disable_transparency = 0
mouse_effects = 1
font_shadow = 0
mouse_hover_icon_asb = 100 0 35
mouse_pressed_icon_asb = 100 10 14
scale_relative_to_dpi = 4
scale_relative_to_screen_height = 1

#-------------------------------------
# Taskbar
taskbar_mode = multi_desktop
taskbar_hide_if_empty = 0
taskbar_padding = 0 0 0
taskbar_background_id = 2
taskbar_active_background_id = 8
taskbar_name = 1
taskbar_hide_inactive_tasks = 0
taskbar_hide_different_monitor = 0
taskbar_hide_different_desktop = 0
taskbar_always_show_all_desktop_tasks = 0
taskbar_name_padding = 4 0
taskbar_name_background_id = 0
taskbar_name_active_background_id = 1
taskbar_name_font = Cantarell 9
taskbar_name_font_color = #dddddd 100
taskbar_name_active_font_color = #ffffff 100
taskbar_distribute_size = 1
taskbar_sort_order = none
task_align = left

#-------------------------------------
# Task
task_text = 1
task_icon = 1
task_centered = 1
urgent_nb_of_blink = 100000
task_maximum_size = 120 35
task_padding = 4 3 4
task_font = Sans 8
task_tooltip = 1
task_thumbnail = 1
task_thumbnail_size = 210
task_font_color = #c6c6c6 100
task_active_font_color = #ffffff 100
task_urgent_font_color = #ffd3d3 100
task_icon_asb = 100 0 5
task_normal_icon_asb = 100 0 -10
task_iconified_icon_asb = 100 0 0
task_background_id = 1
task_normal_background_id = 2
task_active_background_id = 3
task_urgent_background_id = 4
task_iconified_background_id = 6
mouse_left = toggle_iconify
mouse_middle = none
mouse_right = close
mouse_scroll_up = prev_task
mouse_scroll_down = next_task

#-------------------------------------
# System tray (notification area)
systray_padding = 2 0 4
systray_background_id = 1
systray_sort = ascending
systray_icon_size = 22
systray_icon_asb = 100 0 0
systray_monitor = 1
systray_name_filter = 

#-------------------------------------
# Launcher
launcher_padding = 4 0 8
launcher_background_id = 8
launcher_icon_background_id = 8
launcher_icon_size = 22
launcher_icon_asb = 100 0 0
launcher_icon_theme_override = 0
startup_notifications = 1
launcher_tooltip = 1
launcher_item_app = firefox.desktop
launcher_item_app = /usr/share/applications/thunar.desktop
launcher_item_app = /usr/share/applications/xed.desktop
launcher_item_app = /usr/share/applications/xfce4-terminal.desktop
launcher_apps_dir = rofi

#-------------------------------------
# Clock
time1_format = %H:%M
time2_format = %a %d %b
time1_font = sans Bold 8
time1_timezone = 
time2_timezone = 
time2_font = sans 7
clock_font_color = #eeeeee 100
clock_padding = 1 0
clock_background_id = 0
clock_tooltip = 
clock_tooltip_timezone = 
clock_lclick_command = zenity --calendar --text ""
clock_rclick_command = 
clock_mclick_command = 
clock_uwheel_command = 
clock_dwheel_command = 

#-------------------------------------
# Battery
battery_tooltip = 1
battery_low_status = 0
battery_low_cmd = 
battery_full_cmd = 
bat1_font = sans 8
bat2_font = sans 6
battery_font_color = #eeeeee 100
bat1_format = 
bat2_format = 
battery_padding = 1 0
battery_background_id = 1
battery_hide = 101
battery_lclick_command = 
battery_rclick_command = 
battery_mclick_command = 
battery_uwheel_command = 
battery_dwheel_command = 
ac_connected_cmd = 
ac_disconnected_cmd = 

#-------------------------------------
# Button 1
button = new
button_icon = /usr/share/endeavouros/EndeavourOS-icon.png
button_text = 
button_tooltip = Launch jgmenu
button_lclick_command = jgmenu
button_rclick_command = jgmenu
button_mclick_command = jgmenu
button_uwheel_command = 
button_dwheel_command = 
button_font_color = #000000 100
button_padding = 8 1
button_background_id = 2
button_centered = 0
button_max_icon_size = 0

#-------------------------------------
# Button 2
button = new
button_icon = /usr/share/icons/Qogir/scalable/apps/gnome-logout.svg
button_text = 
button_tooltip = Powemenu
button_lclick_command = bash -c ~/.config/rofi/powermenu.sh
button_rclick_command = bash -c ~/.config/rofi/powermenu.sh
button_mclick_command = bash -c ~/.config/rofi/powermenu.sh
button_uwheel_command = 
button_dwheel_command = 
button_font_color = #000000 100
button_padding = 6 6
button_background_id = 0
button_centered = 0
button_max_icon_size = 0

#-------------------------------------
# Tooltip
tooltip_show_timeout = 0.5
tooltip_hide_timeout = 0.1
tooltip_padding = 2 2
tooltip_background_id = 1
tooltip_font_color = #fffafa 100
tooltip_font = sans 9

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ----- ----

16. 回避策1:「仮想マシン」で「クリップボードの共有」機能が使えないので「spice-vdagent」を試す:(失敗)

-

GNOME Boxes」ではこの手順で回避できました:

「spice-vdagent」のデーモンが動作していないのが原因か、確認:

→今回の「クリップボードの共有」機能の回避策としては、失敗

-

参考:

Boxes の「クリップボードの共有」機能を「一時的に」使えるように設定:

-

1). 「spice-vdagent」をインストール:

$ sudo pacman -S spice-vdagent

→「-S」は大文字です

Package (1)          New Version  Net Change  Download Size
extra/spice-vdagent  0.22.1-3       0.14 MiB       0.05 MiB

-

2). ホストOS まで再起動:

[mine@vagrant ~]$ exit
logout
[vagrant@vagrant ~]
[vagrant@vagrant ~]$ exit
logout
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ vagrant halt
==> default: Attempting graceful shutdown of VM...

-

ホストOS で、端末以外のすべてのウィンドウを閉じてから、

ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ reboot

-

3). ホストOS の端末にて、「仮想マシン」を起動:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant up

-

4). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

5). 「spice-vdagentd」デーモンの起動:

[mine@vagrant ~]$ spice-vdagent
[mine@vagrant ~]$ 

→「spice-vdagent」はデーモンを起動するトリガーのコマンドです。

手動でデーモンを起動したので、ログアウトしない限り、「クリップボードの共有」機能が有効のはずです。

-

6). GUI の「ログイン」画面にて、「mine」を選んで、パスワード入力:

→デスクトップ画面が表示

-

7). Windows+Enter で「端末」を起動:

→「クリップボードの共有」機能が(一時的に)有効になるはずでしたが、貼付けできませんでした。

もし、成功なら、自動起動ファイルに定義すれば解決できたのに、残念。

-

似たような「仮想環境」ですが、「GNOME Boxes」と「VirtualBox 」では仕組みが異なるようです:

-

8). 参考: 以前、CD イメージからインストールした「EndeavourOS」(OpenBox) では「クリップボードの共有」機能は有効です:

[ubn@ubn-box ~]$ ls -1Ap
.Xauthority
.bash_history
.bash_logout
.bash_profile
.bashrc
.cache/
.config/
.dmrc
.fehbg
.gtkrc-2.0
.local/
.mozilla/
.themes/
.vboxclient-clipboard-tty7-control.pid     ←(注目)
.vboxclient-clipboard-tty7-service.pid     ←(注目)
.vboxclient-draganddrop-tty7-control.pid   ←(注目)
.vboxclient-draganddrop-tty7-service.pid   ←(注目)
.vboxclient-hostversion-tty7-control.pid   ←(注目)
.vboxclient-seamless-tty7-control.pid      ←(注目)
.vboxclient-seamless-tty7-service.pid      ←(注目)
.xdg_menu_cache/
.xprofile
.xsession-errors
.xsession-errors.old
LANG-select-run.sh
LANG-select.dat
LANG-select.sh
LANG-select01.sh
xed.dconf
ダウンロード/
テンプレート/
デスクトップ/
ドキュメント/
ビデオ/
音楽/
画像/
公開/

→注目: 「クリップボードの共有」機能がうまく動いている場合は、これらのファイルが作られます:

これを見ると、Virtualbox の「GuestAdditions」の機能であることがわかります。

「GuestAdditions」の再インストールが必要かも。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ----- -----

16-2. 回避策2:「仮想マシン」にて「GuestAdditions」を再インストール:

-

今回の「クリップボードの共有」機能の回避策としては、失敗

-

1). 「仮想マシン」を立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant up

-

2). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

3). システム更新:

[mine@vagrant ~]$ paru
:: Synchronizing package databases...
 endeavouros is up to date
 core is up to date
 extra is up to date
 multilib is up to date
:: Starting full system upgrade...
 there is nothing to do
:: Looking for PKGBUILD upgrades...
:: Looking for AUR upgrades...
:: Looking for devel upgrades...
 there is nothing to do

-

4). 再起動:

[mine@vagrant ~]$ sudo reboot

-

5). ホストOS の端末にて「ssh 接続」後に、作成した「mine」ユーザに変更:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh

-

[vagrant@vagrant ~]$ su - mine
Password:          ←(mine ユーザを作成したときのパスワード)
[mine@vagrant ~]$ 

→プロンプトが変わりました

-

6). カーネルバージョンの確認:

[mine@vagrant ~]$ uname -r
6.7.2-arch1-2

-

7). カーネルヘッダーのインストールを確認:

[mine@vagrant ~]$ pacman -Ss linux-headers
core/linux-headers 6.7.2.arch1-2 [installed]
    Headers and scripts for building modules for the Linux kernel

カーネルとバージョンが合っていることを確認

-

8). 必要なツールの再インストール:

「EndeavourOS」の場合:

[mine@vagrant ~]$ sudo pacman -S dkms gcc make perl
Package (4)  Old Version  New Version  Net Change
extra/dkms   3.0.12-1     3.0.12-1       0.00 MiB
core/gcc     13.2.1-4     13.2.1-4       0.00 MiB
core/make    4.4.1-2      4.4.1-2        0.00 MiB
core/perl    5.38.1-1     5.38.1-1       0.00 MiB

-

追加で確認:

[mine@vagrant ~]$ pacman -Ss bzip2
core/bzip2 1.0.8-5 [installed]
    A high-quality data compression program

-

9). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

GUI でログインすると、日本語化されました:

-

10). 「仮想マシン」の画面にて操作:

-

(1). 「Devices」 →「Insert Guest Additions Upgrade CD Image ...」をクリック

-

(2). Windows+N にて、「ファイルマネージャ」を起動:

左側のデバイス「VBox_GAs7.0....」をクリック

→「/run/media/mine/VBox_GAs7.0.10/」がマウントされて開きます:

-

(3). 「ファイルマネージャ」の空きで右クリック→「Open Treminal Here」

-

(4). スクリプトの確認:
[mine@vagrant VBox_GAs7.0.10]$ ls -1 *.run
VBoxLinuxAdditions.run

-

(5). スクリプトの実行:

上記にてファイル名だけ、マウスでクリックしてから、中央ボタンで貼付けできます:

[mine@vagrant VBox_GAs7.0.10]$ sudo ./VBoxLinuxAdditions.run install
[sudo] mine のパスワード:
(6). FATAL メッセージがなく、プロンプトに戻ったら完了:
[mine@vagrant VBox_GAs7.0.10]$ 

-

(7). Windows+Q で「端末」を閉じます:

-

参考:

スクリプトの実行を「sudo ./VBoxLinuxAdditions.run」でなく、

「sudo ./VBoxLinuxAdditions.run install」にしてみましたが、結果は同じでした:

-

スクリプト実行時のログは、「/var/log/vboxadd-setup.log」に登録されるみたい。

-

(8). 「ファイルマネージャ」の左側のデバイス「VBox_GAs7.0....」のイジェクトボタンをクリック

→ [光学ドライブ]に挿入した「Guest Additions のCD イメージ(.iso)」を取り外し:

-

(9). Windows+Q で「ファイルマネージャ」を閉じます:

-

11). 「ssh 接続」を終了:

ssh 接続」の端末にて、

[mine@vagrant ~]$ exit
[vagrant@vagrant ~]$ exit

-

12). 電源オフ:

ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ vagrant halt

-

13). ホストOS を再起動:

「端末」以外のウィンドウを閉じてから、

ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ reboot

-

14). 「仮想マシン」を立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant up

-

15). 「仮想マシン」のログイン画面で、「mine」ユーザを選んで、パスワード入力:

GUI でログインすると、日本語化されました:

-

16). 問題点: 「クリップボードの共有」機能が有効になりません:

もしかしたら、下記の影響かも。

-

17). 問題点: ログインしてデスクトップが表示された時に、下記の通知が右下隅に一瞬表示されます:

VBoxClient: the VirtualBox kernel service is not running. Exiting.

和訳:

VBoxClient: VirtualBox カーネル サービスが実行されていません。終了中。

-

考えられる原因:
  • Guest Additions のインストールに失敗した

  • 必要なパッケージが不足している

  • インストール後、Kernel を update した

  • 前のバージョンの VirtualBox のサービス起動スクリプト等が残っている(完全削除 purge が必要)

-

18). 今のところ、回避策は見つかりません:

「共有フォルダ」は有効なので、それを使うか、ブラウザ経由、ネット経由も使えます。
もしくは、「ssh 接続」であればクリップボード経由が使えます。

-

以前の「EndeavourOS」(OpenBox) であれば「共有フォルダ」は有効なので、設定の違いや、アプリの不足とか、どこかに違いがあるはずですが、わかりません。

「EndeavourOS」(xfce) をインストール後に、「OpenBox」を追加するのが、一番確実かも。 でも、それだと「xfce」を使えばいいとなりそう。

-

どちらにしても「仮想マシン」でなく、「実機」へのインストールであれば関係ありません。

-

19). スクリプト実行後のログを確認:

[mine@vagrant ~]$ cat /var/log/vboxadd-setup.log
Building the main Guest Additions 7.0.10 module for kernel 6.7.2-arch1-2.
Building the shared folder support module.

: (省略)

      | 
/tmp/vbox.0/utils.c:747:9: error: too few arguments to function ‘generic_fillattr’
  747 |         generic_fillattr(idmap, dentry->d_inode, kstat);
      |         ^~~~~~~~~~~~~~~~
./include/linux/fs.h:3085:6: note: declared here
 3085 | void generic_fillattr(struct mnt_idmap *, u32, struct inode *, struct kstat *);
      |      ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:243: /tmp/vbox.0/utils.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1911: /tmp/vbox.0] Error 2
make: *** [/tmp/vbox.0/Makefile-footer.gmk:133: vboxsf] Error 2
kernel modules and services were not reloaded

カーネルモジュールとサービスはリロードされていません:

「utils.c」ファイルに注目

-

-


20). 追記: Linux 起動時のエラーの確認:

-

(1). カーネルによる初期化処理までなら、「dmesg」コマンドで確認:
$ sudo dmesg | less

または、

$ sudo dmesg > boot-msg.txt

テキストエディタで確認:

$ nano boot-msg.txt

→Ctrl+X で表示を終了

-

(2). カーネルによる初期化処理が終了した後は、「/var/log/」にあるファイルを確認:

本日の日付で抜粋:

[mine@vagrant ~]$ ls -l /var/log/ | grep "2月  4"
-rw-rw-r--  1 root utmp        292292  2月  4 19:02 lastlog
drwx--x--x  2 root lightdm       4096  2月  4 19:02 lightdm
-rw-r--r--  1 root root         18426  2月  4 19:02 vboxadd-setup.log
-rw-rw-r--  1 root utmp        113280  2月  4 19:02 wtmp
-rw-r--r--  1 root root         27581  2月  4 19:02 Xorg.0.log

-

表示関連のログ:
$ sudo cat /var/log/Xorg.0.log | less

「q」で表示を終了

-

Guest Additions 関連のログ:
$ sudo cat /var/log/vboxadd-setup.log | less
:
cc1: some warnings being treated as errors
make[2]: *** [scripts/Makefile.build:243: /tmp/vbox.0/utils.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:1911: /tmp/vbox.0] Error 2
make: *** [/tmp/vbox.0/Makefile-footer.gmk:133: vboxsf] Error 2
kernel modules and services were not reloaded
(END)

→「スペース」で改ページ
「q」で表示を終了

-

-


21). 次回の投稿では、ホストOS 側の「virtualbox」と「vagrant」のバージョンを最新に上げてみる予定:

  • virtualbox」:「7.0.10」 →「7.0.14」
  • vagrant」 :「2.4.0」→「2.4.1」

-

2024-02-04 現在:
ゲストOS 側のバージョンを確認:
[mine@vagrant ~]$ pacman -Ss virtualbox | grep install
core/linux 6.7.2.arch1-2 [installed]
extra/virtualbox-guest-utils 7.0.14-2 [installed]    ←(バージョンに注目)

-

[mine@vagrant ~]$ pacman -Ss linux-headers | grep install
core/linux-headers 6.7.2.arch1-2 [installed]

-

ホストOS 側のバージョンを確認:
$ apt list virtualbox* | grep 済
virtualbox-7.0/now 7.0.10-158379~Ubuntu~jammy amd64 [インストール済み、ローカル]

→ゲストOS 側のバージョンが先行しています。
ホストOS 側の「virtualbox」のバージョンを「7.0.14」に上げて、双方のバージョンを合わせた方が良さそう。

-

ちなみに、「ssh 接続」時に、vagrant のバージョンアップの通知が来ています:
$ vagrant ssh
==> vagrant: A new version of Vagrant is available: 2.4.1 (installed version: 2.4.0)!
==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html

Last login: Tue Jan 30 17:55:23 2024 from xx.xx.xx.xx
[vagrant@vagrant ~]$ 

→いつも表示されるわけでなく、時々表示されます

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- ----- ----- -

16-3. 追記: 「仮想マシン」にて、ログイン時の「エラー通知」の解消、および、「クリップボード共有」機能が改善:

-

詳細は、下記を参照:

Xubuntu 22.04 LTS」で、「VirtualBox 7.0.14」と「Vagrant 2.4.1」にアップデート〈H170-7

-

抜粋:

  1. 「仮想マシン」にて、ログイン時の「エラー通知」の解消、および、「クリップボード共有」機能の改善で行ったこと:

  2. 「仮想マシン」にて「GuestAdditions」の再インストールで成功したことで気づいたこと:

-

-


まとめ

今回は、前回作成した「Box」(Endeav-base-jp) から作成した「仮想マシン」に、コミュニティ版の「OpenBox」を追加でインストールしました。

-

普段あまりやらない、デスクトップ環境の追加作業につき、何度かやり直しました。

Vagrant だと、「ssh 接続」でクリップボード経由の貼付けができることと、ホスト側の「端末」が使えるので文字化けしないこと、やり直したいときに簡単に初期状態に戻せることが便利でした。

-

GUI がなかったり、「クリップボードの共有」ができない「Linux ディストリビューション」、例えば、Arch Linux 等のインストール時の設定のときに、公式の「Box」を利用するか、インストール直後に「ssh 接続」の設定を行って「Box」を作成すれば、作業効率がアップ しそうです。

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-

Vagrant 実践編4: 「EndeavourOS」に ssh 接続等の設定を追加して「Box」を再作成〈H170-5〉

登録日: 2024-01-11 更新日: 2024-03-14

Xubuntu 22.04 LTS」および「Windows11」(22H2) の「VirtualBox 7.0」の仮想マシンに、色々なLinux ディストリビューションをインストールして、自分に最適なものはないか試しています。

開発環境では、それらの仮想マシン(ボックス)の管理に「Vagrant」(ベイグラント) というツールが、よく使われています。

-

実践編1 の投稿で、「Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて「Vagrant」を使えるようにしました。

実践編3 の投稿で、コミュニティ版のベースとなる、「EndeavourOS」(デスクトップ環境なし) の英語の環境(日本語キーボード指定、ユーザ名は vagrant )の「Box」を作成しました。

-

(実践編4):

今回は、その作成した「Box」を使って、

(公開はしませんが、)「Vagrant」の「Box」の公開を前提にした ssh 接続等の設定を加えて、「Box」ファイルを作成しました。

-

その備忘録です。

-

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック
スマホの場合は、「ホーム」ボタンの横の「<」キーをタップ

-

-


目次

-

Vagrant」での参考:

  1. 「Vagrant」コマンドについて:

  2. 「Vagrant」コマンドの使用例:

  3. 「Vagrant」コマンドの使用例:(目次)

  4.  修正版3: 使い回し可能な「Vagrantfile」:

  5.  もし、PC のディスクに余裕がない場合:

-

今回の作業:

  1. 「仮想マシン」の立ち上げ:

  2.  余分なグループから「vagrant」ユーザを削除:

  3. 「vagrant」で sudo が使えるように設定:

  4.  Vagrant 用公開鍵認証キーを取得:

  5.  sshd サービスの有効化:

  6.  sshd サービス(ssh サーバー)の起動:

  7. 「仮想マシン」に「ssh 接続」:

  8. 「VirtualBox Guest Additions」を追加:

  9.  設定した「仮想マシン」から、「Box」を作成:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

Vagrant で「EndeavourOS」の「仮想マシン」を立ち上げ:

-

1). 「デスクトップ環境なし」でインストールしているので、コンソール画面が立ち上がりました:

→早めに「ssh 接続」の設定をすると設定作業が楽になります:

コンソール画面を直接操作するよりも、「ssh 接続」して操作した方がホストOS 側の端末が使えるので、マウス操作での範囲指定や貼付けが使え、また、日本語が文字化けしません。

-

2). 「共有フォルダ」は自動設定されます:

VirtualBox Guest Additions」をインストール、および「ssh 接続」できるように設定、

vagrant up」して「仮想マシン」を作成すると、自動で「共有フォルダ」が作成されました:

→下から 2番目の「共有フォルダー」をクリック:

-

設定内容が表示:

→「vagrant up」するときの「作業フォルダ」がデフォルトの「共有フォルダ」となります。

-

「共有フォルダ」を自動設定するには、パスワードなしのsudo を使える設定が必要でした。

Vagrant は内部的に「ssh 接続」での通信を使い、プロバイダー(VirutalBox)を制御しているようです。

-

-


現在のバージョンを表示:

-

ホストOS : 「Xubuntu 22.04.3 LTS」

2024-01-28 現在

カーネル:

$ uname -r
5.15.0-92-generic

リリース:

$ cat /etc/lsb-release
:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"

→「22.04.3」にアップしています。

-

-

ゲストOS : EndeavourOS

2024-01-28 現在

カーネル:

$ uname -r
6.6.7-arch1-1

リリース:

$ cat /etc/lsb-release
:
DISTRIB_ID="EndeavourOS"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="EndeavourOS Linux"
DISTRIB_CODENAME="rolling"
$ cat /etc/os-release
:
NAME="EndeavourOS"
PRETTY_NAME="EndeavourOS"
ID="endeavouros"
ID_LIKE="arch"
BUILD_ID=rolling             ←(注目)
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://endeavouros.com"
DOCUMENTATION_URL="https://discovery.endeavouros.com"
SUPPORT_URL="https://forum.endeavouros.com"
BUG_REPORT_URL="https://forum.endeavouros.com/c/arch-based-related-questions/bug-reports"
PRIVACY_POLICY_URL="https://endeavouros.com/privacy-policy-2"
LOGO="endeavouros"

→インストール時に使用したイメージの作成日付でしたが、 再び、「BUILD_ID=rolling」の表示に戻っています。

-

「Welcome」のバージョン:

$ eos-welcome --version
:
3.85-1

→バージョン表示にて、「ログの登録」の行が表示される場合は「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

VirtualBox」について:

-

VirtualBox」は、Oracle が開発している「仮想マシン」を構築するためのソフトウェアです。

-

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

Vagrant」 (ベイグラント) について:

-

公式サイト:

Vagrant by HashiCorp

-

仮想マシン」の管理や操作をコマンドで使うための「フロントエンド」のソフトウェアです:

-

→詳細は、以前に投稿した「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

「EndeavorOS」について:

-

公式サイト:

-

  • EndeavorOS は、インストールが楽で、使い勝手をよくした「Arch Linux」です。

  • GUI 環境で「Arch Linux」を使いたいときに、オススメします。

-

→詳細は、以前に投稿した「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

「EndeavourOS」(OpenBox) について:

-

公式サイト:

EndeavourOS-Community-Editions/openbox

→サイトに置かれた情報は「こちら 」を参照:

-

その他の詳細は「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

公開する「Box」の元となる「仮想マシン」を作成するときの留意点:

-

インストールする環境は、基本「英語」の環境:

-

言語は「英語」指定、キーボードは「日本語キーボート」指定、でインストールしました:

言語を「日本語」にすると、「ホーム」フォルダが日本語になることと、デフォルトのコンソールでは日本語が文字化けして、設定作業が面倒です:

-

→詳細は、以前に投稿した「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

(前回の作業):

-

Vagrant 実践編3: 新規に「EndeavourOS」(デスクトップなし) の「Box」を作成〈H170-4

-

「EndeavourOS」にて、「デスクトップ環境なし」 の英語の環境(日本語キーボード指定、ユーザ名は vagrant )をインストールして、「Box」を作成しました。

-

-

(前回の作業の続き):

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

1. 「仮想マシン」のクリア:

-

前回の投稿をした後に、「仮想マシン」を色々といじったので、「仮想マシン」を作成し直しました:

-

1). 「仮想マシン」の状態を確認:

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant status
Current machine states:

default                   running (virtualbox)
:

→「仮想マシン」の「default」が、「起動中」です。

-

VirtualBox」に作成された仮想マシン名は、「作業フォルダ」名と「default」と任意の数字の組合せになります:

例: 「endeavour-base_default_1704888667727_61081」

-

Vagrant」から見える仮想マシン名は「default」です。

-

2). 「仮想マシン」の停止(電源オフ):

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: Guest communication could not be established! This is usually because
    default: SSH is not running, the authentication information was changed,
    default: or some other networking issue. Vagrant will force halt, if
    default: capable.
==> default: Forcing shutdown of VM...

和訳:

==> default: 「仮想マシン」の正常なシャットダウンを試みています...
    default: ゲスト通信が確立できませんでした。
    default: これは通常、SSH が実行されていない、認証情報が変更された、
    default: またはその他のネットワークの問題が原因です。
    default: 可能であれば、Vagrant は強制的に停止します。
==> default: 「仮想マシン」を強制的にシャットダウンします...

ssh 接続の設定がされていないので、警告が表示されますが無視。

-

3). 「仮想マシン」の削除:

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...

和訳:

    default: 「仮想マシン」の「default」を削除してもよろしいですか? [y/N] y
==> default: 「仮想マシン」と関連ドライブを削除しています...

→「y」Enter にて、削除

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

2. 「仮想マシン」の作成と立ち上げ:

-

仮想マシン」の立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'Endeav-base-00'...
Progress: 70%

しばらく待ちます:

==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: endeavour-base_default_1704888667727_61081
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...

前回、ssh 接続のループ回避の設定 を行っているので、プロンプトに戻り、端末が開放されました:

-

赤色の警告表示:

Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
ubn@ubn-box:~/ダウンロード/vm/endeavour-base$ 

-

実際の「端末」画面:

ssh 接続は未設定なので、警告は無視

-

仮想マシン」が立ち上がりました:

→「デスクトップ環境なし」でインストールしているので、コンソール画面が立ち上がりました。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

3. 現在の「仮想マシン」の状態を確認:

-

「ホストOS」の端末にて確認:

-


1). 参考: 現在、Vagrant で管理されている「仮想マシン」:

$ vagrant global-status
id       name    provider   state    directory                           
-------------------------------------------------------------------------
5d12367  default virtualbox poweroff /home/ubn/ダウンロード/vm/ubn2204         
f104680  default virtualbox running  /home/ubn/ダウンロード/vm/endeavour-base  ←(注目)

→「仮想マシン」の「id」と、その管理に使われている「作業フォルダ」名がわかります。

-


2). VirtualBox の「仮想マシン」の実際のフォルダ:

$ ls -1Ap ~/'VirtualBox VMs'
EndeavourOS_OpenBox/
EndeavourOS_base/
endeavour-base_default_1704888667727_61081/  ←(Vagrant で管理)
ubn2204_default_1703902769818_14280/         ←(Vagrant で管理)

→上記のすべてのフォルダ名が、VirtualBox で見える「仮想マシン」名です。

下の 2つのフォルダ名に含まれている「default」が、Vagrant で見える「仮想マシン」名です。

-


3). Vagrant に登録(ローカルのホームに保存)されている「Box」:

$ vagrant box list
Endeav-base-00     (virtualbox, 0)                 ←(注目)
generic/ubuntu2204 (virtualbox, 4.3.8, (amd64))

Vagrant で見える「仮想マシン」のベース(元)として使える(使われた)「Box」です。

各「作業フォルダ」の Vagrantfile で利用されるベースが指定されています。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -

4. 「仮想マシン」にて、「vagrant」ユーザでログイン:

-

仮想マシン」のコンソール画面にて操作:

ssh 接続の設定が済んでいないので、直接、コンソール画面で操作します:

-

vagrant」ユーザでログイン:

EndeavourOS Linux 6.6.7-arch1-1 (tty1)

vagrant login:

→ユーザ名に「vagrant」を入力

-

password:

→パスワードに「vagrant」を入力

-

[vagrant@vagrant ~]$

コマンドプロンプトが変わりました。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- --

4-2. 参考: 「vagrant」ユーザが追加されていない場合:

-

他のユーザにログイン後に 「vagrant」ユーザを追加:

-


1). 「root」になります:

$ su -
Password:

→パスワードは、ログインしたユーザのパスワード

-


2). 「vagrant」ユーザの作成:

# useradd -m vagrant

-


3). 「vagrant」ユーザのパスワード設定:

# passwd vagrant

→パスワードは「vagrant

-


4). 「vagrant」でログイン:

# su - vagrant

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ---

5. 「仮想マシン」の「vagrant」ユーザで操作:

-

仮想マシン」のコンソール画面にて操作:

-


1). 確認:

[vagrant@vagrant ~]$ pwd
/home/vagrant
[vagrant@vagrant ~]$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant),3(sys),981(rfkill),998(wheel)

→「ベースボックス」にするには、余分なグループがあります。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考: 「wheel」グループについて:

「wheel」グループに属すると、コマンドに関しては「root」と同等の権限を持ちます:

-

「root」のパスワードを知っていれば、直接、コンソールを操作して「root」でログインできます。 また、「su」コマンドで「root」ユーザにスイッチできます。

ただし、「/etc/pam.d/su」の設定次第では、「wheel」グループに属していない人は、「root」のパスワードを知っていても「su」コマンドで「root」になれません。

また、ネット経由の ssh だと「root」でログインできないのが普通です。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考: 「rfkill」について:

Power_Management_Guide/RFKill から抜粋:

多くのコンピュータが、Wi-FiBluetooth、及び 3G のデバイスを含む電波発信器を内蔵しています。 これらのデバイスは電力を消費し、 使用されない時は無駄になります。

-

Rfkill は、システム上の RFKill 対応のデバイスをクエリ、変更できるコマンドラインツール(rfkill パッケージ)です。 RFkill をサポートしたカーネルドライバーは、この API を使用してカーネルに登録し、デバイスを有効にしたり無効にできます。

-

バイスの一覧を確認するには:

$ rfkill list
$

-


2). sudo が使えるか確認:

[vagrant@vagrant ~]$ sudo ls
[sudo] password for vagrant:
Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos

-

「/etc/sudoers*」の確認:

[vagrant@vagrant ~]$ sudo ls /etc/sudoers*
/etc/sudoers

/etc/sudoers.d:
10-installer

-

「/etc/sudoers」の確認:

[vagrant@vagrant ~]$ sudo cat /etc/sudoers
:
## Read dop-in files from /etc/sudoers.d
@includedir /etc/sudoers.d

→設定ファイルの最後に「外部ファイル」を取り込むフォルダの定義がありました。

-

「/etc/sudoers.d/10-installer」の確認:

[vagrant@vagrant ~]$ sudo cat /etc/sudoers.d/10-installer
%wheel ALL=(ALL) ALL

外部ファイルに「wheel」グループの権限の定義がありました。

ファイル名からして、OS のインストールのユーザ作成時に追加されたと思われます。

-


3). 余分なグループから「vagrant」ユーザを削除:

「Box」を公開しないのであれば、要らない作業です:

-

(1). 「root」になります:
[vagrant@vagrant ~]$ su -
Password:

→パスワードは「vagrant

[root@vagrant ~]#

→プロンプトが「root」になりました。

-

(2). 「sys」グループから、「vagrant」ユーザを削除:
[root@vagrant ~]# gpasswd -d vagrant sys

-

(3). 「rfkill」グループから、「vagrant」ユーザを削除:
[root@vagrant ~]# gpasswd -d vagrant rfkill

-

(4). 「wheel」グループから、「vagrant」ユーザを削除:
[root@vagrant ~]# gpasswd -d vagrant wheel

-

(5). 確認:
[root@vagrant ~]# id vagrant
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant)

→削除できました。完全に反映させるには再起動が必要。

-


4). 「wheel」グループから抜けたので、「vagrant」で sudo が使えるように設定:

「wheel」グループから抜けて、そのままだと、「vagrant」で sudo が使えなくなります:

-

「/etc/sudoers」の修正:
[root@vagrant ~]# visudo

「nano」でなく、「vi」が起動されました。

-

「↓」キーでファイルの最後の行に移動

「End」キーで行末に移動

「Esc」「Esc」「a」

最後の行の行末で、キー入力が可能になるので、2回、改行してから、下記を入力:

## Allow root to run any commands anywhere
root    ALL=(ALL)   ALL
Defaults:vagrant    !requiretty
vagrant ALL=(ALL)   NOPASSWD: ALL

大きなすき間は、半角スペース x 4つ にすると良いです

-

説明:

下から 2行目:

 全ユーザではなく、特定の「vagrant」ユーザだけに「tty なしでの sudo」を認めます:
 →sudo エラーの回避
 
下から 1行目:

 「vagrant」ユーザが、sudo をパスワードなしで実行できるようにします:

-

「Esc」「Esc」「:wq」Enter

→書き込み後に、終了しました:

[root@vagrant ~]#

→「visudo」にて入力ミスがあると、やり直さないとコマンドプロンプトに戻りません。

コマンドプロンプトに戻ったということは、構文のミスはなかったということ。

-


5). 「vagrant」に抜けます:

[root@vagrant ~]# exit
logout
[vagrant@vagrant ~]$ 

→プロンプトが「vagrant」に戻りました:

-

[vagrant@vagrant ~]$ pwd
/home/vagrant

-


6). sudo が使えるかの確認と、修正されたかの確認:

[vagrant@vagrant ~]$ sudo cat /etc/sudoers

パスワードなしで、下記が表示:

:
## Read dop-in files from /etc/sudoere.d
@includedir /etc/sudoers.d

## Allow root to run any commands anywhere
root    ALL=(ALL)   ALL
Defaults:vagrant    !requiretty
vagrant ALL=(ALL)   NOPASSWD: ALL

→OK

-

ファイルの最終行に記述すれば、外部ファイルの定義を取り込んでも、上書きして、最優先になります。

-


7). 再起動:

[vagrant@vagrant ~]$ reboot

-


8). 「vagrant」ユーザでログイン:

EndeavourOS Linux 6.6.7-arch1-1 (tty1)

vagrant login:

→ユーザ名に「vagrant」を入力

-

password:

→パスワードに「vagrant」を入力

-

[vagrant@vagrant ~]$

コマンドプロンプトが変わりました。

-


9). 確認:

-

[vagrant@vagrant ~]$ ls

水色表示:

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos

-

[vagrant@vagrant ~]$ sudo ls

パスワードを聞いてきません:

白色表示:

Desktop  Documents  Downloads  Music  Pictures  Public  Templates  Videos

-

[vagrant@vagrant ~]$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant)

→余分なグループが表示されません。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----

6. ssh 関連の設定:

-

仮想マシン」のコンソール画面にて操作:

-


1). 確認:

-

[vagrant@vagrant ~]$ ls -1Ap

色分けして表示:

.bash_history
.bash_logout
.bash_Profile
.bashrc
.config/
Desktop/
Documents/
Downloads/
Music/
Pictures/
Public/
Templates/
Videos/

→「~/.ssh」はありません

-


2). Vagrant 用公開鍵認証キーを取得:

$ mkdir -p /home/vagrant/.ssh
$ chmod 700 /home/vagrant/.ssh

$ cd /home/vagrant/.ssh 
$ curl -k -L -o authorized_keys 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub'
$ chmod 600 /home/vagrant/.ssh/authorized_keys
$ chown -R vagrant:vagrant /home/vagrant/.ssh

-


3). ホームに移動:

[vagrant@vagrant ~]$ cd

-


4). 確認:

[vagrant@vagrant ~]$ ls -lAp /home/vagrant/ | grep ssh
:
drwx------   2 vagrant vagrant   4096 1■ 10 23:42 .ssh/

→ファイル属性は「700」で、「vagrant:vagrant」の所有

-

[vagrant@vagrant ~]$ ls -lAp /home/vagrant/.ssh
:
-rw-------   1 vagrant vagrant   409 1■ 10 23:42 authorized_keys

→ファイル属性は「600」で、「vagrant:vagrant」の所有

-


5). ssh 関連のアプリがインストールされているかを確認:

「EndeavourOS」の場合:

$ pacman -Ss ssh | grep installed
:
core/libssh2 1.11.0-1 [installed]
core/openssh 9.6p1-1 [installed] ←(注目)
extra/libssh 0.10.6-1 [installed]

→「openssh」がインストールされています。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考: 「Ubuntu」の場合:

$ apt list *ssh* --installed
:
libssh-4/jammy-updates,jammy-security,now 0.9.6-2ubuntu0.22.04.1 amd64 [installed,automatic]
openssh-client/jammy-updates,now 1:8.9p1-3ubuntu0.4 amd64 [installed,automatic]  ←(注目)
openssh-server/jammy-updates,now 1:8.9p1-3ubuntu0.4 amd64 [installed]  ←(注目)
openssh-sftp-server/jammy-updates,now 1:8.9p1-3ubuntu0.4 amd64 [installed,automatic]
ssh-import-id/jammy,now 5.11-0ubuntu1 all [installed]

→「openssh-client」と「openssh-server」がインストールされています。

-

Linux ディストリビューションによって、パッケージ名や機能の分割のやり方は異なります。

-


6). ssh 関連のサービスが起動されているか確認:

$ sudo systemctl status sshd
○ sshd.service - OpenSSH Daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; disabled; preset: disabled)
     Active: inactive (dead)

-


7). sshd サービスの有効化:

$ sudo systemctl enable sshd
Created symlink /etc/systemd/system/multi-user.target.wants/sshd.service → /usr/lib/systemd/system/sshd.service.

→サービス名に付く(.service) は省略できます

-


8). sshd サービス(ssh サーバー)の起動:

$ sudo systemctl start sshd
$

→サービス名に付く(.service) は省略できます

-


9). sshd サービスが起動されたか確認:

$ sudo systemctl status sshd
● ssh.service - OpenSSH Daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; preset: disabled)
     Active: active (running) since Thu 2024-01-11 00:22:02 JST; 1min 39S ago
   Main PID: 655 (sshd)
      Tasks: 1 (limit: 4642)
     Memory: 2.1M (peak: 2.3M)
        CPU: 22ms
     CGroup: /system.slice/sshd.service
             └─655 "sshd: /usr/bin/sshd -D [listener] 0 of 10-100 startups"

:

「q」で表示の終了

-


10). 再起動:

[vagrant@vagrant ~]$ reboot

-


11). ログイン画面にて、ログインせずにそのまま:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -----

7. 「仮想マシン」に「ssh 接続」:

-

ホストOS の端末にて:

-


1). 「仮想マシン」が起動していることを確認:

$ pwd
/home/ubn/ダウンロード/vm/endeavour-base

-

$ vagrant status
Current machine states:

default                   running (virtualbox)

-


2). 「ssh-config」の確認:

$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/ubn/.vagrant.d/insecure_private_keys/vagrant.key.ed25519
  IdentityFile /home/ubn/.vagrant.d/insecure_private_keys/vagrant.key.rsa
  IdentitiesOnly yes
  LogLevel FATAL
  PubkeyAcceptedKeyTypes +ssh-rsa
  HostKeyAlgorithms +ssh-rsa

-


3). 「ssh 接続」:

$ vagrant ssh
Last login: Wed Jan 10 23:19:24 2024
[vagrant@vagrant ~]$ 

→パスワードなしで自動ログインされました。

[vagrant@vagrant ~]$ date
2024年  1月 11日 木曜日 00:43:55 JST

→「date」コマンドが文字化けしません。

-

[vagrant@vagrant ~]$ ls -lAp
:
-rw------- 1 vagrant vagrant  808  1月 11 00:32 .bash_history
-rw-r--r-- 1 vagrant vagrant   21 11月 23 00:26 .bash_logout
-rw-r--r-- 1 vagrant vagrant   57 11月 23 00:26 .bash_profile
-rwxr-xr-x 1 vagrant vagrant 2691 11月 17 20:33 .bashrc
drwxr-xr-x 3 vagrant vagrant 4096  1月 10 21:29 .config/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Desktop/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Documents/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Downloads/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Music/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Pictures/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Public/
drwx------ 2 vagrant vagrant 4096  1月 10 23:42 .ssh/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Templates/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Videos/

-


4). ssh サーバー設定で 「UseDNS」設定を no に設定:

サーバーへ ssh 接続を行うと、サーバー側で接続元IPアドレスの逆引きを行うため、 DNS サーバーへの問い合わせを行います。

-

マシンまたは Vagrant マシンがインターネットに接続されていない場合(ローカルネットワーク上のサーバーへのSSH接続)でも ssh の速度を維持するには、 ssh サーバー設定で 「UseDNS」設定を no(SSHサーバーの逆引きを無効)に設定することで、 接続している ssh クライアントで何秒もかかる可能性がある「逆引き DNS ルックアップ」が回避されます。

-

「/etc/ssh/sshd_config」の修正:
$ sudo nano /etc/ssh/sshd_config

Ctrl+W で、検索

Search: DNS

-

修正:

#UseDNS no

↓ コメント行を解除:

UseDNS no

Ctrl+O で、保存

Ctrl+X で、終了

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -

8. 「仮想マシン」にて、「VirtualBox Guest Additions」を追加:

-

仮想マシン」に「ssh 接続」したままで操作:

-

「EndeavourOS」の公式のデスクトップ環境には、標準で(専用にカスタマイズした)「VBoxGuestAdditions」がインストールされていますが、デスクトップなしの環境には「VBoxGuestAdditions」はインストールされていません。

-


1). 必要なツールのインストール:

「EndeavourOS」の場合:

[vagrant@vagrant ~]$ sudo pacman -S dkms
resolving dependencies...
looking for conflicting packages...

Package (1)  New Version  Net Change

extra/dkms   3.0.11-1       0.11 MiB

Total Installed Size:  0.11 MiB

:: Proceed with installation? [Y/n] 

→Enter

-

[vagrant@vagrant ~]$ sudo pacman -S gcc make perl

:: Proceed with installation? [Y/n] 

→Enter

インストールされている可能性が高いですが、再インストールでもOK

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考: 「Ubuntu」の場合:
$ sudo apt update
$ sudo apt install linux-headers-$(uname -r) build-essential dkms

→ダイアログ画面が表示されたら、Tab キーで「OK」を選び、Enter

-

$ sudo apt install gcc make perl

-


2). 「仮想マシン」の画面にて、

「Devices」 →「Upgrade Guest Additions...」をクリック

-

「Install Guest Additions CD images...」でなく、「Upgrade Guest Additions...」が選べるならクリックすると、

「CD マウント」と「シェルスクリプトの実行」が自動で行われます:

-

→右の通知領域に「Installing image ...」60% が表示されるので、100% になるまで待ちます。

エラーの表示は無視。

-


3). ホストOS の端末にて、「ssh 接続」からログアウト:

[vagrant@vagrant ~]$ exit
logout
ubn@ubn-box:~/ダウンロード/vm/endeavour-base$ 

→プロンプトが戻りました。

-


4). 「仮想マシン」の停止(電源オフ):

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...

和訳:

==> default: 仮想マシンの正常なシャットダウンを試行しています...
    default: 
    default: Vagrant の安全でないキーが検出されました。
    default: Vagrant は、セキュリティを向上させるために、これを
    default: 新しく生成されたキーペアに自動的に置き換えます。
    default: 
    default: 生成された公開キーをゲスト内に挿入します...
    default: ゲストに安全でないキーが存在する場合はそれを削除します...
    default: キーが挿入されました!新しい SSH キーを使用した切断と再接続...

→「項番 6 - 2) 」でわざと「安全でないキー」を配置しています。

-

「安全でないキー」を検出すると自動で「安全なキーペア」に置換えられます:

(そういうVagrant の仕組みにより、設定時のキーペアの生成をせずにダウンロードできます)

-


5). 「ホストOS」も再起動:

ホストOS にて、起動しているアプリを閉じます:

-

ホストOS の端末にて、

$ reboot

→「共有フォルダ」を有効にするための操作です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- --

9. 「仮想マシン」を立ち上げて確認:

-

仮想マシン」の立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/endeavour-base
ubn@ubn-box:~/ダウンロード/vm/endeavour-base$ 

→「ssh 接続」のリトライエラーが消えました。

「guest additions」のバージョンの整合性のチェックも OK。

-

「共有フォルダ」が自動でマウントされました:
  • 仮想マシンの「/vagrant

  • ホストOS の「~/ダウンロード/vm/endeavour-base」(つまり、作業フォルダ)

-

→「Virtualbox」マネージャの画面でも、「共有フォルダ」が有効になったことが確認できます:

→下から 2番目の「共有フォルダー」をクリック:

-

設定内容が表示:

→「vagrant up」するときの「作業フォルダ」が「共有フォルダ」となります。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ---

10. 設定の完了した「仮想マシン」から、「Box」を作成:

-

参考:「vagrant package」コマンドの使い方:

$ vagrant package [--base 対象の「仮想マシン」の名前]、または[id] --output [ファイル名].box

→「id」は「Vagrant」で管理されている「仮想マシン」のみで使えます:

-


1). 「仮想マシン」の「id」を確認:

$ vagrant global-status
id       name    provider   state    directory                           
-------------------------------------------------------------------------
f104680  default virtualbox running  /home/ubn/ダウンロード/vm/endeavour-base ←(注目) 

→「id」は「f104680」です

-


2). 「仮想マシン」の停止(電源オフ):

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant halt
==> default: Attempting graceful shutdown of VM...

→「ssh 接続」の警告が消えました。

-


3). 「.box」ファイルを作成したい場所を準備:

すでに作成済みです:

$ mkdir -p ~/ダウンロード/vm/box-share/

-


4). 「.box」ファイルを作成:

-

(1). 場所の移動:
$ cd ~/ダウンロード/vm/box-share/
$ ls -lA
:
-rw-rw-r-- 1 ubn ubn 2958974232 12月 20 21:30 pkg-EndeavourOS_base-inst.box

-

(2). 作成:
$ cd ~/ダウンロード/vm/box-share/
$ vagrant package f104680 --output pkg-EndeavourOS_base-jp.box
==> default: Clearing any previously set forwarded ports...
==> default: Exporting VM...
==> default: Compressing package to: /home/ubn/ダウンロード/vm/box-share/pkg-EndeavourOS_base-jp.box

「id」指定にすると、「--base」を付けると実行できませんでした。外すと実行できました。
「id」指定時の書式が違うみたい。

時間がかかります:

-

(3). 確認:
$ ls -lA ~/ダウンロード/vm/box-share/
:
-rw-rw-r-- 1 ubn ubn 2958974232 12月 20 21:30 pkg-EndeavourOS_base-inst.box
-rw-rw-r-- 1 ubn ubn 2979814018  1月 11 17:31 pkg-EndeavourOS_base-jp.box

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----

11. 作成された「Box」ファイルを「Box」の一覧に追加:

-


1). できた「Box」ファイルをホームの「Box」一覧に追加:

$ cd ~/ダウンロード/vm/box-share/
$ vagrant box add --name Endeav-base-jp pkg-EndeavourOS_base-jp.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'Endeav-base-jp' (v0) for provider: 
    box: Unpacking necessary files from: file:///home/ubn/%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89/vm/box-share/pkg-EndeavourOS_base-jp.box
==> box: Successfully added box 'Endeav-base-jp' (v0) for ''!

時間がかかります:

-


2). 「Box」の一覧に追加されたか確認:

$ vagrant box list
Endeav-base-00 (virtualbox, 0)
Endeav-base-jp (virtualbox, 0)             ←(追加)

-


3). 参考: ホームの「Box」の一覧にあるファイルを確認:

$ ls -lA ~/.vagrant.d/boxes/Endeav-base-jp/0/virtualbox/
-rw-rw-r-- 1 ubn ubn        630  1月 11 17:35 Vagrantfile
-rw-rw-r-- 1 ubn ubn 3014952448  1月 11 17:36 box-disk001.vmdk
-rwx------ 1 ubn ubn       9183  1月 11 17:36 box.ovf
-rw-rw-r-- 1 ubn ubn         25  1月 11 17:36 metadata.json
-rw------- 1 ubn ubn        400  1月 11 17:36 vagrant_private_key ←(注目)

-

ホームの「Box」の一覧にある「Vagrantfile」ファイルを確認:
$ cat ~/.vagrant.d/boxes/Endeav-base-jp/0/virtualbox/Vagrantfile
Vagrant::Config.run do |config|
  # This Vagrantfile is auto-generated by `vagrant package` to contain
  # the MAC address of the box. Custom configuration should be placed in
  # the actual `Vagrantfile` in this box.
  config.vm.base_mac = "080027B2BB06"
end

# Load include vagrant file if it exists after the auto-generated
# so it can override any of the settings
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)

Vagrant.configure("2") do |config|
  config.ssh.private_key_path = File.expand_path("../vagrant_private_key", __FILE__)
end

→「Vagrantfile」の元ファイルになります。

MAC アドレスと、「Vagrantfile」の組み込みと、ssh 接続の「private_key」のパスが定義されています。

-

これに、「作業フォルダ」の「Vagrantfile」が 上書き(追加)されます。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -----

12. 「Vagrantfile」の修正:

-

1). 「仮想マシン」を管理する「作業フォルダ」を準備:

別の「作業フォルダ」を準備:

$ mkdir -p ~/ダウンロード/vm/endeavour-base-jp/

→「仮想マシン」を管理する場所になります

-

「作業フォルダ」は使い回すのでなく、新しい名前で作成した方が混乱しないと思います。

-

2). 「Vagrantfile」の作成:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ featherpad Vagrantfile

↓ すべて貼付け:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "Endeav-base-jp"
  #config.vm.boot_timeout = 300
  config.vm.boot_timeout = 60
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    #vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxsvga"]
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

-

参考:「config.vm.box = "Endeav-base-jp"」の行を変更すれば、他の「仮想マシン」でも使い回し出来ます:

-

追記: GUI(デスクトップ環境)を使う場合:

Ubuntu」の場合は、「vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]」を有効にすると、 ウィンドウサイズの拡大で、リアルタイムに解像度が調整されます。

「EndeavourOS」の場合は、「vb.customize ["modifyvm", :id, "--graphicscontroller", "vboxsvga"]」を有効にすると、 再ログインでログアウト直前の解像度に調整されます。

-

3). 確認:

$ ls -1Ap
:
Vagrantfile         ←(追加)

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- -

13. 「仮想マシン」の生成と立ち上げ:

-

1). 「仮想マシン」の生成と立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'Endeav-base-jp'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: endeavour-base-jp_default_1704962773770_3717
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/endeavour-base-jp
ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ 

→エラーなしで、プロンプトに戻りました。

-

2). 「仮想マシン」が立ち上がりました

→「デスクトップ環境なし」なので、コンソール画面が立ち上がりました。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- --

14. 「仮想マシン」に「ssh 接続」:

-

ホストOS の端末にて:

-

1). 「仮想マシン」が起動していることを確認:

$ pwd
/home/ubn/ダウンロード/vm/endeavour-base-jp

-

$ vagrant status
Current machine states:

default                   running (virtualbox)

-

2). 「ssh-config」の確認:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh-config
Host default
  HostName 127.0.0.1
  User vagrant
  Port 2222
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/ubn/.vagrant.d/boxes/Endeav-base-jp/0/virtualbox/vagrant_private_key
  IdentitiesOnly yes
  LogLevel FATAL
  PubkeyAcceptedKeyTypes +ssh-rsa
  HostKeyAlgorithms +ssh-rsa

→「IdentityFile」の行が 1行に変わりました。

-

3). 「ssh 接続」:

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant ssh
Last login: Thu Jan 11 17:09:57 2024 from xx.xx.xx.xx
[vagrant@vagrant ~]$ 

→パスワードなしで自動ログインされました。

[vagrant@vagrant ~]$ date
2024年  1月 11日 木曜日 17:51:29 JST

→「date」コマンドが文字化けしません。

-

[vagrant@vagrant ~]$ ls -lAp
:
-rw------- 1 vagrant vagrant 1209  1月 11 17:11 .bash_history
-rw-r--r-- 1 vagrant vagrant   21 11月 23 00:26 .bash_logout
-rw-r--r-- 1 vagrant vagrant   57 11月 23 00:26 .bash_profile
-rwxr-xr-x 1 vagrant vagrant 2691 11月 17 20:33 .bashrc
drwxr-xr-x 3 vagrant vagrant 4096  1月 10 21:29 .config/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Desktop/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Documents/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Downloads/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Music/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Pictures/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Public/
drwx------ 2 vagrant vagrant 4096  1月 11 01:53 .ssh/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Templates/
drwxr-xr-x 2 vagrant vagrant 4096  1月 10 21:29 Videos/

-

[vagrant@vagrant ~]$ ls -lAp ~/.ssh/
:
-rw------- 1 vagrant vagrant 89  1月 11 01:53 authorized_keys

-

[vagrant@vagrant ~]$ id
uid=1000(vagrant) gid=1000(vagrant) groups=1000(vagrant)

→余計なグループに属していません。

-


4). 参考:「ssh 接続」で再起動する場合:

[vagrant@vagrant ~]$ reboot

ピンク表示:

Call to Reboot failed: Interactive authentication required.

和訳:

再起動の呼び出しが失敗しました: 対話型認証が必要です。

-

再起動する場合は:

[vagrant@vagrant ~]$ sudo reboot

→「ssh 接続」での「reboot」は「sudo」が必要です

-

5). ログアウト:

[vagrant@vagrant ~]$ logout

もしくは、

[vagrant@vagrant ~]$ exit

もしくは、

Ctrl+D

コマンドプロンプトが変わりました:

ubn@ubn-box:~/ダウンロード/vm/endeavour-base-jp$ 

-


6). 「仮想マシン」を停止:

ホストOS の端末にて、

$ cd ~/ダウンロード/vm/endeavour-base-jp/
$ vagrant halt
==> default: Attempting graceful shutdown of VM...

→「仮想マシン」が電源オフ

ssh 接続」の警告は表示されません。

-


7). 参考: 「仮想マシン」についての確認:

-

Vagrant で管理されている「仮想マシン」:
$ vagrant global-status
:
id       name    provider   state    directory                             
---------------------------------------------------------------------------
2483206  default virtualbox poweroff /home/ubn/ダウンロード/vm/endeavour-base-jp 

→「仮想マシン」の「id」と、その管理に使われている「作業フォルダ」名がわかります。

-

VirtualBox の「仮想マシン」の実際のフォルダ:
$ ls -1Ap ~/'VirtualBox VMs'
:
$ ls -1Ap ~/'VirtualBox VMs'
EndeavourOS_OpenBox/
EndeavourOS_base/
endeavour-base-jp_default_1704962773770_3717/  ←(Vagrant で管理)注目
endeavour-base_default_1704914580912_2584/  ←(Vagrant で管理)

→「作業フォルダ」を使い回すと、新しい「仮想マシン」か分かりづらいので、

「作業フォルダ」の名前を変えました。

-

Vagrant に登録(ローカルのホームに保存)されている「Box」:
$ vagrant box list
:
Endeav-base-00 (virtualbox, 0)
Endeav-base-jp (virtualbox, 0)  ←(注目)

Vagrant で見える「仮想マシン」のベース(元)になった「Box」です。

各「作業フォルダ」ごとに、Vagrantfile で利用されるベースが指定されます。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ---

15. 参考: 本来であれば、最低限行うべき「ssh 接続」の設定:

-

作業は要りません。

Vagrant 以外の環境での設定についてです。
鍵の生成を行っているのが違うようです。Vagrant ではダウンロードしています。

-

参考:

新しいサーバ起動後に最低限行うべき SSH 設定

-


1). 最低限のセキュリティ事項:

  • ポート番号の変更:
  • root ユーザへのログインを禁止:
  • パスワードによるログインを禁止:

-


2). ssh 設定ファイルの修正:

-

(1). ssh を 22番ポート以外に変更:

ssh を 22番ポートのまま使用すると、無差別攻撃の的になります

-

(2). ssh 接続では、root ユーザとしてログインできないように設定:

→root ユーザとして作業したい場合は、一旦、一般ユーザとしてログインし、
その後、su コマンドで root ユーザのパスワードを入力してログインします

-

(3). ssh でログインする方法を「鍵のみ」に絞り、「パスワード」によるログインを無効化:

→パスワードによるログインを許可していると、総当たり攻撃の的になります

-


3). 「公開鍵」の配置:

鍵の生成はサーバではなくクライアント(PC)側で行います:
生成された 2つの鍵のうち、pub が付かない「id_rsa」が秘密鍵で、pubが付く「id_rsa.pub」が公開鍵です。

id_rsa.pub(公開鍵)をサーバ側(仮想マシン側)に配置します:
場所は「~/.ssh」直下で、ファイル名は「authorized_keys」とします。

-

(1). ホームディレクトリに「.sshディレクトリを作成:
$ cd
$ mkdir .ssh
$ chmod 700 .ssh
$ cd .ssh

-

(2). 認証される公開鍵リストのファイルを作成:
$ nano authorized_keys

これに、

$ cat [鍵名].pub

で表示される公開鍵の内容を貼り付けて保存

-

(3). パーミッションを設定:
$ chmod 600 authorized_keys

→オーナーのみ読み書き可能に設定します

-


4). 「sshd_config」の書き換え:

公開鍵認証を許可し、パスワードログインを禁止します:

$ sudo nano /etc/ssh/sshd_config
(1). 公開鍵認証を許可(コメント行を解除):
PubkeyAuthentication yes

-

(2). パスワードでのログインを禁止:
PasswordAuthentication no

-


5). ssh 設定ファイルの変更:

★1: Port をデフォルトの 22 番から別の番号に変更。番号は 1024 〜 65535 までの任意の数値
★2: PermitRootLogin を prohibit-password から no に変更
★3: PasswordAuthentication が yes になっている場合は no に変更

$ cat /etc/ssh/sshd_config
# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
- Port 22     ←★1
+ Port 2222
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
- PermitRootLogin prohibit-password     ←★2
+ PermitRootLogin no
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
- #PasswordAuthentication yes     ←★3
+ PasswordAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----

16. 参考: もし、PC のディスクに余裕がない場合:

-

1). 「仮想マシン」を一度、削除:

$ cd ~/ダウンロード/vm/ubn2204
$ vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] 

→「y」

-

2). それでも足りなければ、「Box」ファイルを削除:

$ vagrant box list

→「Box」名を確認:

$ vagrant box remove generic/ubuntu2204

-

-


まとめ

前回は、(学習を兼ねて)「OpenBox」等のベースになる、デスクトップ環境なしの「仮想マシン」を作り、 インストール直後の「仮想マシン」で、「Vagrant」の「Box」ファイルを作成しました。

-

今回は、その作成した「Box」を使って、

Vagrant」の「Box」に公開時に推奨される(ssh 接続等の)設定を加えて、再度「Box」ファイルを作成しました。

-

「日本語キーボード」に設定したのは正解で、設定時の工数が削減できました。

-

次回は、その作成した「Box」(Endeav-base-jp) を使って、コミュニティ版の「OpenBox」をインストールする予定です。

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-

Vagrant 実践編3: 新規に「EndeavourOS」(デスクトップなし) の「Box」を作成〈H170-4〉

登録日: 2023-12-29 更新日: 2024-03-14

Xubuntu 22.04 LTS」および「Windows11」(22H2) の「VirtualBox 7.0」の仮想マシンに、色々なLinux ディストリビューションをインストールして、自分に最適なものはないか試しています。

開発環境では、それらの仮想マシン(ボックス)の管理に「Vagrant」(ベイグラント) というツールが、よく使われています。

-

前々回の実践編1 の投稿で、「Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて「Vagrant」を使えるようにしました。

-

(実践編3):

今回は、「VirtualBox 7.0」にて、新規に「仮想マシン」を作成し、「EndeavourOS」(デスクトップ環境なし) を英語の環境(日本語キーボード指定、ユーザ名は vagrant )でインストールしました。

インストールが完了してすぐに、「仮想マシン」から「Box」ファイルを作成しました。
インストール直後の保存があるので、その後のやり直し(と気持ち)が楽になります。

-

その備忘録です。

-

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック
スマホの場合は、「ホーム」ボタンの横の「<」キーをタップ

-

-


目次

-

Vagrant」での参考:

  1. 「Vagrant」コマンドについて:

  2. 「Vagrant」コマンドの使用例:

  3. 「Vagrant」コマンドの使用例:(目次)

  4.  修正版3: 使い回し可能な「Vagrantfile」:

-

「EndeavourOS」での参考:

  1.  ミラーの更新:

  2. 「Welcome」画面に、「個人用コマンド」(Personal Commands) タブを追加:

  3. 「AUR ヘルパー」について:

-

今回の作業:

  1.  ISO イメージをダウンロード:

  2. 「仮想マシン」の作成:

  3. 「EndeavourOS」のライブ立ち上げ:

  4. 「EndeavourOS」(デスクトップなし) のインストール:

  5. 「仮想マシン」から「Box」ファイルを作成:

  6. 「Box」ファイルを「Box」の一覧に追加:

  7. 「Vagrantfile」の作成:

  8. 「仮想マシン」を(作成して)立ち上げ:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

最新の「EndeavourOS」をライブ立ち上げ:

-

1). 「Welcome」画面から、メニューの 2番目にあった「Install community editions」が消えました:

→つまり、ライブ立ち上げで、コミュニティ版のデスクトップ環境のインストールは出来なくなりました。

-

2). ライブ立ち上げ時のデスクトップ環境は「KDE plasma」 に変更されました:

→起動されるアプリは「KDE」アプリです。

-

3). ライブ立ち上げ時、「Welcome」アプリが日本語で表示出来るようになりました:

-

(1). 「Welcome」画面の左下の「Change Language」タブをクリック

-

(2). 「Select language variation for 'Welcome'」画面が表示されるので、

「Japanese (日本語)」をクリック →「OK」

-

(3). 「Welcome」画面が「日本語」表示に変わりました:

→以前であれば、「コミュニティ版のインストール」メニューが英語だとわかりづらく、見過ごしがちだったので、日本語化する意味がありました。

そのメニューが無い今は、使うのは 1番目だけなので効果は薄いかな。
ただし、「パーティション管理マネージャ」、「ディスプレイの解像度を変更」のメニューはわかりやすくなりました。

-

-


現在のバージョンを表示:

-

ホストOS : 「Xubuntu 22.04.3 LTS」

2024-01-10 現在

カーネル:

$ uname -r
5.15.0-91-generic

リリース:

$ cat /etc/lsb-release
:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.3 LTS"

→「22.04.3」にアップしています。

-

-

ゲストOS : EndeavourOS

2023-12-29 現在

カーネル:

$ uname -r
6.6.7-arch1-1

リリース:

$ cat /etc/lsb-release
:
DISTRIB_ID="EndeavourOS"
DISTRIB_RELEASE="rolling"
DISTRIB_DESCRIPTION="EndeavourOS Linux"
DISTRIB_CODENAME="rolling"
$ cat /etc/os-release
:
NAME="EndeavourOS"
PRETTY_NAME="EndeavourOS"
ID="endeavouros"
ID_LIKE="arch"
BUILD_ID=rolling             ←(注目)
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://endeavouros.com"
DOCUMENTATION_URL="https://discovery.endeavouros.com"
SUPPORT_URL="https://forum.endeavouros.com"
BUG_REPORT_URL="https://forum.endeavouros.com/c/arch-based-related-questions/bug-reports"
PRIVACY_POLICY_URL="https://endeavouros.com/privacy-policy-2"
LOGO="endeavouros"

→インストール時に使用したイメージの作成日付でしたが、 再び、「BUILD_ID=rolling」の表示に戻っています。

-

「Welcome」のバージョン:

$ eos-welcome --version
:
3.85-1

→バージョン表示にて、「ログの登録」の行が表示される場合は「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

VirtualBox」について:

-

VirtualBox」は、Oracle が開発している「仮想マシン」を構築するためのソフトウェアです。

-

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

Vagrant」 (ベイグラント) について:

-

公式サイト:

Vagrant by HashiCorp

-

仮想マシン」の管理や操作をコマンドで使うための「フロントエンド」のソフトウェアです:

-

→詳細は、前回に投稿した「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

「EndeavorOS」について:

-

公式サイト:

-

  • EndeavorOS は、インストールが楽で、使い勝手をよくした「Arch Linux」です。

  • GUI 環境で「Arch Linux」を使いたいときに、オススメします。

  • 追加されたリポジトリはありますが、基本は「Arch Linux」のリポジトリのままにしているのが利点です。

-

インストールについて:

→EndeavorOS では「ライブ立ち上げ」のイメージがひとつあるだけです。「ライブ立ち上げ」するだけで、多くのデスクトップ環境がインストールできます。

-

(1). 「オフライン」を選ぶと、デスクトップ環境として「Xfce」がインストールされます:

→インストール時にネット環境は要りません。

-

(2). 「オンライン」を選ぶと、(ネット経由で)下記のデスクトップ環境が選べます:

Ubuntu フレーバーよりも多く、(Arch では人気の)「i3-wm」があります。

オンラインで「Xfce」をインストールする利点は、インストール後のシステム更新が要らないことです。

-

(3). 下記のデスクトップ環境は、ネットの GitHub にて提供されています:

「コミュニティ版」のデスクトップ環境:

「☆」は現時点(2024-01-10)のサイトの注目度です。
ちなみに「Worm」は EndeavorOS のコミュニティで提供のウィンドウマネージャです。

→「Arch Linux」もしくは「EndeavorOS」(もしかしたら「Manjaro Linux」)に追加インストール出来ます。

-

最新のライブイメージのインストールメニューから「コミュニティ版」のデスクトップ環境が除外されました。
個人的には、完成度の高い「Openbox」が除外されたのは残念。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

「EndeavourOS」(OpenBox) について:

-

1). 公式サイト:

EndeavourOS-Community-Editions/openbox

→サイトに置かれた情報は「こちら 」を参照:

-

その他の詳細は「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

公開する「Box」の元となる「仮想マシン」を作成するときの留意点:

-

1). インストールする環境は、「英語」の環境が基本:

-

公開せず個人で使うにしても、「EndeavourOS」(Arch Linux)のコンソール画面では、日本語は使いづらいです:

「デスクトップ」環境なしでインストールすると、直接、コンソール画面で使うか、ssh 接続して使うかになります。

ssh 接続するにしても、最初に、コンソール画面で設定を行う必要があります。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

例えば、「EndeavourOS」のインストール時に:

-

(1). 使用言語を「日本語」に指定にすると、

ユーザの「ホーム」フォルダが「日本語」のフォルダ名で作成されます。→コンソールで、フォルダ名が文字化け
コンソール画面のコマンドのメッセージに日本語が含まれて表示されます。→文字化けで意味不明

-

(2). 英語キーボードを「日本語キーボード」として指定すると、

キー配列で「[」が「@」になります。

-

(3). タイムゾーンを日本(Asia、Tokyo)にすると、

「date」コマンドでの表示が「日本語」が含まれた書式(文字化け)で、JST が使われます。

-


2). インストール完了後:

「EndeavourOS」(Arch Linux)のコンソール画面だと、

ロケールに「日本」が指定されていて、日本語フォントをインストールしても、日本語が「■」(豆腐文字)に化けます:

-

コンソールで日本語を表示するには、「KMSCON 」などでコンソール ( tty1 は除外するのが望ましい) を代替えするやり方があります。ただし、公式リポジトリの登録ではなく、AUR パッケージです。また「仮想マシン」で使うのは(問題が発生する?みたいで)推奨されていません。

-

ロケールが指定されており、フォントをインストールした場合(つまり、日本語指定でインストールした後に、日本語フォントを入れた場合)に、コンソールでは文字化けしますが、
ssh 接続したら正常に表示されるのか、は未確認。例えば、「date」コマンドで化けるか、化けないかの確認が必要です。

-


3). 「Vagrant」にて、公開される「Box」で推奨される? と思われる設定:

参考:

オリジナルvagrant box の作り方 〜CentOS7のboxを自作してみた〜

-

(1). 公開される「Box」は、ベースとして使われる「Box」になるので、「最小構成」が基本みたい:

→公式の「Box」には、「ホーム」ディレクトリが作成されていないものがありました。

-

また、「仮想マシン」の作成で、メモリを 4GB 、ディスクを 25GB ほどに設定しましたが、極力小さめに設定するのが良いようです。それらはいつでも拡張できます。

-

(2). 「Box」にしたい「仮想マシン」に「vagrant」グループと「vagrant」ユーザを作成:

vagrant」ユーザを作成すれば、「vagrant」グループが作られ、それに含まれます。
「公開」する場合は、パスワードは「vagrant」。「プライベート」の場合は任意で、パスワードなしは解除。

-

(3). ssh 接続に使う「vagrant」ユーザ用の公開鍵を配置:

-

(4). 「VBoxGuestAdditions」をインストール:

「共有フォルダ」を使う場合に必要です。GUI を使う場合は、使い勝手に影響します。

-

(5). 個人的に使うなら、「公開」でなく、「プライベート」(非公開)でアップすることも検討:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

今回の、インストールの方針:

-

VirtualBox 7.0」の仮想マシンに、新規に「EndeavourOS」の「デスクトップ環境なし」をインストール:

-

言語は「英語」指定、キーボードは「日本語キーボート」指定、でインストール:

言語を「日本語」にすると、「ホーム」フォルダが日本語になることと、デフォルトのコンソールでは日本語が文字化けして、設定作業が面倒になります:

-

公開するなら、「英語キーボード」の指定が望ましいのでしょうが、単なる確認テストなので、楽に使える「日本語キーボード」の指定としました。どちらにしても、公開するなら注意点として表題に含めれば良いのかも。

-

Vagrant」の「Box」の公開(はしないけど、公開)を前提にした(vagrant ユーザの作成や、ssh 接続等の)設定を考えて、手間を減らせるようにインストールしました:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

1. 「ゲストOS」のISO イメージをダウンロード:

-

1). 「EndeavourOS」(Endeavouros-Galileo-11-2023.iso) のダウンロード

-

「デスクトップ」環境が違っても、ダウンロードする「ISO ファイル」は共通で、ひとつだけです:

-

ダウンロード サイト:

-

Download mirror list:

ダウンロードするミラーを選び、ダウンロード:

2023-12-29 現在

Web サイトのデザインが変わって、以前の「Github: World wide」はなくなりました。

例: 今回は、「Asia」の「Singapore Jingk」を選びました:

-

(1). ISO

→ファイルを「~/ダウンロード/Endeavour/」フォルダに移動しました

-

(2). Sha512sum

→クリックにて、Web ブラウザ画面に表示されました:

50a6ca3fbe4203f8ea12b3acadd8119d6c3baa039773d13e05b3e0c5001f2c13be6dfe088745cd9cf05ad9ae48ea6954b79811b40dfe06fd8c6f32e0ab735be1  Endeavouros-Galileo-11-2023.iso

-


2). 「チェックサム」を確認:

$ cd ~/ダウンロード/Endeavour/

$ ls -1
:
Endeavouros-Galileo-11-2023.iso          ←(追加: 最新の iso)
Endeavouros_Cassini_Nova-03-2023_R2.iso  ←(旧 iso)
Endeavouros_Cassini_Nova-03-2023_R2.iso.sha512sum

-

確認:

$ sha512sum Endeavouros-Galileo-11-2023.iso
:
50a6ca3fbe4203f8ea12b3acadd8119d6c3baa039773d13e05b3e0c5001f2c13be6dfe088745cd9cf05ad9ae48ea6954b79811b40dfe06fd8c6f32e0ab735be1  Endeavouros-Galileo-11-2023.iso

→ダウンロードしたファイルと値が同じか確認:

-


3). 参考: 「Windows11」で「チェックサム」を確認:

ダウンロードしたファイルが「C:\Users\user\Downloads\」にある場合:

-

(1).「PowerShell」を起動:

Windows ボタン →「po」で絞り込み →「Windows PowerShell

PS C:\Users\user> 

→「user」はユーザ名で任意です

-

(2). 「Downloads\」フォルダに移動:
> cd Downloads\
PS C:\Users\user\Downloads> ls E*
:
    ディレクトリ: C:\Users\user\Downloads

Mode              LastWriteTime      Length Name
----              -------------      ------ ----
d-----  2023/06/27 火     18:55             Endeavour
-a----  2023/12/09 土     17:25  2608148480 Endeavouros-Galileo-11-2023.iso

-

(3). ハッシュ値である「Hashプロパティ」の値のみを「小文字」で表示:
> (Get-FileHash -Algorithm SHA512 EndeavourOS*.iso).Hash.toLower()
:
50a6ca3fbe4203f8ea12b3acadd8119d6c3baa039773d13e05b3e0c5001f2c13be6dfe088745cd9cf05ad9ae48ea6954b79811b40dfe06fd8c6f32e0ab735be1

→結果が配列として返るので、プログラム的に書ける(加工できる)のが「PowerShell」の利点(だけど使いこなすには場数が必要)

-

(4). 参考: 以前のイメージファイル(R1、R2) をすでにダウンロードしている場合:

それを使ってインストールして、システム更新すれば同じです。システム更新の時間がかかるだけです。

-

ただし、「EndeavourOS キーリング」パッケージの更新があってインストーラがエラーする場合は、
こちら 」の操作が必要かも。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

2. 「仮想マシン」の作成:

-

1). 「VirtualBox 7.0.10」の起動:

メニュー →「システム」→「Orcle VM VirtualBox

-


2). 右上の「新規」ボタンをクリック

-


3). Virtul machine Name and Operating System(名前とオペレーティングシステム):

-

(1). 作成したい「ゲストOS」名を入力:
名前:EndeavourOS_base   ←(好みの英字の名前)

-

(2). ISO イメージファイルを指定:

ISO Image:<選択されていません>

右端をクリック →その他 →下記のファイルを指定:

「~/ダウンロード/Endeavour/Endeavouros-Galileo-11-2023.iso」

→「開く」

-

(3). 自動で下記が選択されました:
タイプ: Other
バージョン: Other/Unknown

→自動認識できなかったみたい。

-

(4). 下記に変更:
タイプ: Linux
バージョン: Arch Linux (64-bit)

→「Linux」の中に「Arch Linux」はありました。

-

→「次へ」

-


4). Hardware:

-

(1). メインメモリー:

今回は、メモリに、4 GB を割当てました:

4096 MB  ←(メモリに余裕がないときに大きくしすぎると、 ホストOS が不調になります)

-

(2). Processors:

2 CPU   ←(パソコンのプロセッサによって、上限は変わります)

-

(3). 「Enable EFI (special OSes only)」にチェック:

→「次へ」

-

仮想で使うならどちらでもかまいません。実際の動きを確認したいのでチェックしています。

-


5). Virtual Hard disk(仮想ハードディスク):

-

「Create a Virtual Hard Disk Now」(仮想ハードディスクを作成する)にチェックされていることを確認

25.00 GB に変更

→「次へ」

-


6). 概要:

今までに入力した項目の一覧が表示されるので確認:

→「完了」

-


7). 仮想マシンの「EndeavourOS」が作成されました:

-


8). 「ディスプレイ」の設定を変更:

「ディスプレイ」をクリック →「スクリーン」タブ

- ビデオメモリー: 16MB        →「128MB」に変更
- グラフィックコントローラー:         →「VMSVGA」であることを確認
「Guest Additions」をインストールする場合は、「VMSVGA」にします。

-

→「OK」

-

-


9). 右側の「ストレージ」の [光学ドライブ]に「ISO イメージ」がセットされていることを確認:

[光学ドライブ] Endeavouros-Galileo-11-2023.iso (2.43 GB)

→「Endeavouros-Galileo-11-2023.iso」の DVD でライブ立ち上げされます。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

3. 「EndeavourOS」(デスクトップ環境なし) のインストール:

-

新しい「Galileo ISO」から、(公式ではない)コミュニティ版の「OpenBox」などが直接インストールできなくなりました:

→コミュニティ版のデスクトップ環境をインストールしたい場合は、インストール手順の見直しが必要です:

-

「EndeavourOS」(Xfce) のインストール後に、コミュニティ版を手動で追加した場合は、手間は減りますが、余分なパッケージがインストールされます。

-

まずは、コミュニティ版のベースとなる、「EndeavourOS」(デスクトップ環境なし) のインストールを行いました-

すぐにコミュニティ版のデスクトップ環境をインストールせずに、

(学習も兼ねて)その「仮想マシン」から「Vagrant」の「Box」ファイルを作成します。

-

1). 「起動」(緑色の右矢印)ボタンをクリック

仮想マシンが起動

-

2). ブート選択画面が表示

グラフィックカードの選択ができるみたい。

→デフォルトの選択のまま待つか、Enter

-

メニューに「UEFI」の文字列が表示されています。つまり、「UEFI 立ち上げ」です。

-

画面の右側に「VirtalBox の通知エリア」が重なって表示:

何かしらの通知があると表示されますが、邪魔なので表示を消しました:

(「仮想マシン」の立ち上げ時の通知を抑止する機能が欲しいところ)

-

右上のオレンジのアイコンで「すべての通知が削除」され通知エリアが消えます。

もし、「通知エリアを隠す」だけなら、左の水色の吹き出しアイコンをクリック。もう一度クリックで表示されます。

-


3). デスクトップ表示後、「Welcome」画面が表示:

表示されるまで、時間がかかります:

-

→ライブ立ち上げのCD イメージのデスクトップ環境は「KDE plasma」 に変更されました:

なので、メニューやアイコンで起動されるアプリは「KDE」アプリです:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -

3-1. 参考: ライブ立ち上げ時の機能について:

-

1). 「解像度の自動調整」と「クリップボードの共有」の機能が、有効にするだけで使えます:

→つまり、「EndeavourOS」の公式のデスクトップ環境には、標準で「Guest Additions」がインストールされています:

-

(1). 「解像度の自動調整」

表示 →「ゲストOS の画面を自動リサイズ」をクリック →チェックが付いたアイコンに切替え:

すでに設定されています。

-

VirtualBox」ウィンドウのタイトルバーをつかんで、画面右端の中央にぶつけ、「1/2」画面のタイリング表示にしました:

-

(2). 「クリップボードの共有」機能を有効化:

バイス→「クリップボードの共有」→「無効」を「双方向」に変更

-

使用例:

「ブラウザ」で範囲指定、「端末」にマウスの中央ボタンで、うまく貼り付けできないとき:
  • 「ブラウザ」で範囲指定して、右クリック→「c」

  • 「端末」で、右クリック→「p」、もしくは、マウスの中央ボタン

→範囲指定と、クリップボードへのコピー操作が必要です

いつものように、範囲指定して、マウスの中央ボタンではダメです(記憶される場所が違うみたい)

-

参考: ホストの「ブラウザ」からライブ立ち上げの「端末」にコマンドを貼付けて確認できます:

[liveuser@eos-2023.11.17 ~]$ pwd
/home/liveuser
[liveuser@eos-2023.11.17 ~]$ uname -n
EndeavourOS

[liveuser@eos-2023.11.17 ~]$ uname -a
Linux EndeavourOS 6.6.1-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 08 Nov 2023 16:05:38 +0000 x86_64 GNU/Linux
[liveuser@eos-2023.11.17 ~]$ ls -1
Desktop
Documents
Downloads
iso_package_versions
LICENSE
Music
Pictures
Public
Templates
user_commands.bash
user_pkglist.txt
Videos

→(KDE plasma) の「端末」は、「konsole」です:

-

参考: ライブ立ち上げ時のバージョン:
$ uname -r
6.6.1-arch1-1
$ eos-welcome --version
3.78-1

→ライブ立ち上げのバージョンはディスク立ち上げ時よりも遅れています。

-

Alt+F4 もしくは、ウィンドウの右上の「x」で、端末を閉じます

-


2). 参考:「EndeavourOS」に内蔵の「Guest Additions」について:

確認するだけで操作しません:

-

バイス →メニューの一番下に「Guest Additions CD イメージの挿入…」と「Upgrade Guest Additions…」があって、どちらも選択できることに注目:(通常は、どちらか一方だけが選べます)

→「新規インストール」だけでなく「アップグレード」が出来るのは、アップグレードの対象となる、純正ではない何かの機能(EndeavourOS 向けの Guest Additions ?)がすでにインストールされているということ。

ちなみに、アップグレードすると、純正の「Guest Additions」がインストールされ、メニューでは「Upgrade Guest Additions…」だけが選べる状態に変わります。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- --

3-2. 参考: 新しい「Welcome」画面について:

-

1). 「Welcome」画面にて、メニューの 2番目にあった「Install community editions」が消えました:

→ 2番目は、ARM 版のインストール メニューになりました:

つまり、ライブ立ち上げで、コミュニティ版のデスクトップ環境のインストールは出来なくなりました。

-


2). 「Welcome」アプリが国際化対応になり、日本語での表示が出来ます:

-

(1). 「Welcome」画面の左下の「Change Language」タブをクリック

-

(2). 「Select language variation for 'Welcome'」画面が表示されるので、

Japanese (日本語)」をクリック

→「OK」

-

(3). 「Welcome」画面が「日本語」表示に変わりました:

「インストール」タブは、ライブ立ち上げしたときだけに表示される画面です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ---

3-3. 「EndeavourOS」(デスクトップ環境なし) のインストール:

-

1). Welcome 画面の 1番目のメニュー「インストーラーを起動」をクリック:

-


2). 「インストールのやり方を選択」画面が表示:

→「Online」をクリック

-


3). 「EndeavourOS インストーラー」画面が表示:

→表示されるまで時間がかかります。

-


(1). ようこそ:

「EndeavourOS Galileo インストーラーへようこそ」

→自動的に「日本語」で表示されました。

-

ベースの「Box」にするので、

→「American English」に変更しました:

-


(2). Welcome:(ようこそ)

「Welcome to the EndeavourOS Galileo installer」

-

-

→右下の「Next」

-


(3). Location:(ロケーション)

Region: Asia、Zone: Tokyo

(地図で日本をクリックしても設定されます)

-

→「Next」

-


(4). Keyboard:(キーボード)

-

英語キーボードの場合:

Keyboard Model: Generic 105-key PC

→「English (US)Default」に変更

-

日本語キーボードの場合:

Keyboard Model: Generic 105-key PC

→「JapaneseDefault」に変更

-

「Type here to test yur keyboard」 (ここでタイプしてキーボードをテストしてください)
→ @@ で確認。

-

→「Next」

-


(5). Desktop:(デスクトップ)

Desktops の一覧から 1つ選んでください。:

-

No Desktop」をクリック

-

→「Next」

-


(6). Packages:(パッケージ)

インストールされるパッケージの一覧が表示されます:

「Desktop-Base + Common packages」にチェックあり

「EndeavourOS applications」にチェックあり

「Recommended applications selection」にチェックあり

Firefox and language package」にチェックあり

Firewall」にチェックあり

-

何もさわらずに、デフォルトのまま

-

→「Next」

-


(7). Bootloader:(ブートローダー)

「Systemd-boot」→「Grub」オンに変更

-

→「Next」

-


(8). Partitions:(パーティション

Select storege device: (VBOX HARDDISK - 25.00 GiB /dev/sda)  ←(メーカ名とサイズが参考)
(ストレージデバイスを選択)

→「Erase disk」(ディスクの消去)にチェック:

-

→「Next」

-


(9). Users:(ユーザ情報)

任意設定ですが、「Box」を公開するときは、

What is your name?(あなたの名前は何ですか?)
vagrant

What name do you want to use to log in?(ログイン時に使用する名前は何ですか?)
vagrant

What is the name of this computer?(このコンピュータの名前は何ですか?)
vagrant

Password(パスワード) : 「vagrant

Repeat Password(パスワードを再度入力) : 「vagrant

「Log in automatically without asking for the password.」のチェックなし
(パスワードを尋ねずに自動的にログインする)

「Use the same password for the administrator account.」にチェック
(管理者アカウントと同じパスワードを使用する。)

-

→「Next」

-


(10). Summary:(要約)

今までに設定した内容を確認。

表示が隠れているかもしれないので、必ず、スクロールさせて、確認。

-

→「Install」(インストール)

-

→「Install now」(今すぐインストール)

-


(11). Install:(インストール)

インストールが開始しました:

→バーグラフが伸びて行きます。

-

「バーグラフ」の色が暗くて、見づらいです:

→水色やピンクなどの明るい色にした方が見やすいかも。

-

今回は時間がかかり過ぎたので「中止」し、再起動。
日曜日の夜はダメですね。
ミラーが混んでいるようなので、時間をズラシて再トライしました。

-


(12). Finish:(終了)

「All done.」(すべて完了しました。)表示:

-

DVD(iso イメージ)を取り外したいので、

「Restart now」(今すぐ再起動)にチェックせずに、

-

→「Done」(実行 完了)  ←(翻訳の訂正が必要)

-


4). デスクトップの、Welcome 画面に戻りました:

-


5). 電源オフ:

すべてのウィンドウを閉じて、

左下のアイコン (Application Launcher) をクリック

→右下の「Shut down」をクリック

→「OK」

-


6). 「VirtualBox」マネージャ画面を起動、もしくは「最大化」:

CD を取り外します:

右の「ストレージ」にある、

IDE セカンダリマスター: [光学ドライブ]  Endeavouros-Galileo-11-2023.iso (2.43 GB)

右の [光学ドライブ] ボリューム名 の部分をクリック

→「仮想ドライブからディスクを除去」

IDE セカンダリマスター: [光学ドライブ] 空

画面下の「共有フォルダー」が「なし」になっていることに注目。

-


7). 「VirtualBox」マネージャ画面を右上の「x」で閉じました:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----

4. インストール直後の「仮想マシン」から、一時的に「Box」ファイルを作成:

-

インストール直後に、「仮想マシン」を保存:

「システム更新」、および、「Box」を作成するときに推奨される設定を行ってから、 「Box」ファイルを作成したいところです。

-

ただし、ここで作っておくと、やり直しが楽です。

もしくは、「VirtualBox」で「クローンを作成」するやり方でも良いかも。

-


参考:「vagrant package」コマンドの使い方:

$ vagrant package --base [対象の「仮想マシン」の名前か、id] --output [ファイル名].box

→「id」は「Vagrant」で管理されている「仮想マシン」でないと(付加されないので)使えません:

-

参考: 「仮想マシン」の「id」を確認:

Vagrant」で管理されている「仮想マシン」だけが表示されます:

$ vagrant global-status
id       name   provider state  directory                           
--------------------------------------------------------------------
There are no active Vagrant environments on this computer! Or,
you haven't destroyed and recreated Vagrant environments that were
started with an older version of Vagrant.

和訳:

このコンピュータにはアクティブな Vagrant 環境がありません。
または、古いバージョンの Vagrant 環境を破棄して再作成していません。

-


1). 「.box」ファイルを作成したい場所を準備:

$ mkdir -p ~/ダウンロード/vm/box-share/

-


2). 「仮想マシン」を管理する「作業フォルダ」を準備:

ちょっと長いけど、分かりやすい名前にしました:

$ mkdir -p ~/ダウンロード/vm/endeavour-base/

→「仮想マシン」を管理する場所になります

-


3). 「仮想マシン」は停止しておきます:

-


4). VirtualBox に追加された「仮想マシン」の名前(フォルダ名)を確認:

$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox
EndeavourOS_base               ←(注目)

→「Vagrant」で管理されていない場合の「仮想マシン」名は、上記の「フォルダ名」ですが、

Vagrant」で管理されている場合の「仮想マシン」名は、フォルダ名に含まれている「default」です。

-

5). 「.box」ファイルを作成:

場所の移動:

$ cd ~/ダウンロード/vm/box-share/
$ ls -1
package-ubn2204-2023-1211.box

-

作成:

$ vagrant package --base EndeavourOS_base --output pkg-EndeavourOS_base-inst.box
==> EndeavourOS_base: Exporting VM...
==> EndeavourOS_base: Compressing package to: /home/ubn/ダウンロード/vm/box-share/pkg-EndeavourOS_base-inst.box

-

確認:

$ ls -1 ~/ダウンロード/vm/box-share/
:
package-ubn2204-2023-1211.box
pkg-EndeavourOS_base-inst.box

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -----

5. 作成された「Box」ファイルを「Box」の一覧に追加:

-


1). できた「Box」ファイルをホームの「Box」一覧に追加:

$ cd ~/ダウンロード/vm/box-share/
$ vagrant box add --name Endeav-base-00 pkg-EndeavourOS_base-inst.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'Endeav-base-00' (v0) for provider: 
    box: Unpacking necessary files from: file:///home/ubn/%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89/vm/box-share/pkg-EndeavourOS_base-inst.box
==> box: Successfully added box 'Endeav-base-00' (v0) for ''!

-


2). 「Box」の一覧に追加されたか確認:

$ vagrant box list
Endeav-base-00 (virtualbox, 0)             ←(追加)

-


3). 参考: ホームの「Box」の一覧にあるファイルを確認:

$ ls -lA ~/.vagrant.d/boxes/Endeav-base-00/0/virtualbox/
-rw-rw-r-- 1 ubn ubn        505 12月 20 23:59 Vagrantfile
-rw-rw-r-- 1 ubn ubn 2992691712 12月 20 23:59 box-disk001.vmdk
-rwx------ 1 ubn ubn       8953 12月 20 23:59 box.ovf
-rw-rw-r-- 1 ubn ubn         25 12月 20 23:59 metadata.json

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -

6. 「Vagrantfile」の作成:

-

1). 「Vagrantfile」の作成:

$ cd ~/ダウンロード/vm/endeavour-base/
$ featherpad Vagrantfile

↓ すべて貼付け:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "Endeav-base-00"
  #config.vm.boot_timeout = 300
  config.vm.boot_timeout = 60
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

Ctrl+S で保存

-

参考:「config.vm.box = "Endeav-openbox"」の行を変更すれば、他の「仮想マシン」でも使いまわし出来ます:

-

2). 確認:

$ ls -1Ap
:
Vagrantfile         ←(追加)

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- --

7. 「仮想マシン」の生成と立ち上げ:

-


1). 「仮想マシン」の生成と立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'Endeav-base-00'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: endeavour-base_default_1703085902199_27238
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...

赤色の警告表示:

Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
ubn@ubn-box:~/ダウンロード/vm/endeavour-base$ 

→プロンプトに戻りました。

-

→端末は開放されました。

ssh 接続は未設定なので、警告は無視)

-

仮想マシン」が立ち上がりました

→「デスクトップ環境なし」なので、コンソール画面が立ち上がりました。

-


2). 「仮想マシン」での操作:

ssh 接続の設定が済んでいないので、直接、コンソール画面で操作します:

-

(1). ログイン:
EndeavourOS Linux 6.6.7-arch1-1 (tty1)

vagrant login:

→ユーザ名に「vagrant」を入力

-

password:

→パスワードに「vagrant」を入力

-

[vagrant@vagrant ~]$

コマンドプロンプトが変わりました。

-

→コンソール画面にて、「date」コマンドが文字化けしていることに注目:

→日本語フォントをインストールしても同じです。
タイムゾーンが日本なので、(日本語が含まれた)日本の書式が使われています。

-

(これ以降、設定作業を行って行きます)

-

(2). ログアウト:
[vagrant@vagrant ~]$ logout

もしくは、

[vagrant@vagrant ~]$ exit

もしくは、

Ctrl+D

コマンドプロンプトが変わりました。

-


3). 「仮想マシン」を停止:

ホストOS の端末にて、

$ cd ~/ダウンロード/vm/endeavour-base/
$ vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: Guest communication could not be established! This is usually because
    default: SSH is not running, the authentication information was changed,
    default: or some other networking issue. Vagrant will force halt, if
    default: capable.
==> default: Forcing shutdown of VM...

→「仮想マシン」が電源オフ

ssh 接続は未設定なので、警告は無視)

-


4). 参考: 「仮想マシン」についての確認:

-

Vagrant で管理されている「仮想マシン」:
$ vagrant global-status
:
id       name    provider   state    directory
-------------------------------------------------------------------------
6c9f2a3  default virtualbox poweroff /home/ubn/ダウンロード/vm/endeavour-base  

→「仮想マシン」の「id」と、その管理に使われている「作業フォルダ」名がわかります。

-

VirtualBox の「仮想マシン」の実際のフォルダ:
$ ls -1Ap ~/'VirtualBox VMs'
:
EndeavourOS_OpenBox/
EndeavourOS_base/
endeavour-base_default_1703085902199_27238/  ←(Vagrant で管理)

→上記のフォルダ名が、VirtualBox で見える「仮想マシン」名です。

そのフォルダ名に含まれている「default」が、Vagrant で見える「仮想マシン」名です。

-

Vagrant に登録(ローカルのホームに保存)されている「Box」:
$ vagrant box list
:
Endeav-base-00 (virtualbox, 0)

Vagrant で見える「仮想マシン」のベース(元)になった「Box」です。

各「作業フォルダ」ごとに、Vagrantfile で利用されるベースが指定されます。

-

ここでは、バージョン管理(Box 作成のタイミング)として「Box」名の一部として「-00」を使いましたが、本来のバージョン管理は「,0」の部分(フォルダの階層)が使われます。

-

-


まとめ

「EndeavourOS」の最新の ISO イメージから、コミュニティ版のインストールメニューが消えました。 サポートの維持ができる「デスクトップ環境」だけを残したみたい。

なので、個人的に気に入っていた(完成度は高いけどサポーターの少ない)「OpenBox」は(簡単に)インストール出来なくなりました。

-

今回は、(学習を兼ねて)「OpenBox」等のベースになる、デスクトップ環境なしの「仮想マシン」を作り、

VirtualBox」で「スナップショット」や「クローン」を作成するのでなく、その代わりに、
インストール直後の「仮想マシン」で、「Vagrant」の「Box」ファイルを作成しました。

-

作業に失敗しても、「Box」があれば、「仮想マシン」のやり直し(廃棄や、作成)が簡単です。
保存した(任意の)時点に、簡単に「やり直しできる」のが「Vagrant」の利点です。

-

次回以降は、その作成した「Box」を使って、

Vagrant」の「Box」の(公開はしないけど、)公開を前提にした(ssh 接続等の)設定を加えて、「Box」ファイルを作成。

その後、コミュニティ版の「OpenBox」をインストールする予定です。

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-

Vagrant 実践編2: 既存の「EndeavourOS」(Openbox) から「Box」を作成〈H170-3〉

登録日: 2023-12-19 更新日: 2024-03-14

Xubuntu 22.04 LTS」および「Windows11」(22H2) の「VirtualBox 7.0」の仮想マシンに、色々なLinux ディストリビューションをインストールして、自分に最適なものはないか試しています。

開発環境では、それらの仮想マシン(ボックス)の管理に「Vagrant」(ベイグラント) というツールが、よく使われています。

-

前回の(実践編1) の投稿で、「Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて「Vagrant」を使えるようにしました。

-

(実践編2):

今回は、その環境で、「Vagrant」を使って、 「VirtualBox」ですでに作成している「仮想マシン」である、「EndeavourOS 」のデスクトップ環境を「Vagrant」の「Box」として使える(保存できる)か、トライしました:

個人で使えれば良いだけなので、「Vagrant」の「Box」の公開を前提にした(vagrant ユーザの作成や、ssh 接続等の)設定は行いませんでした。

-

その備忘録です。

-

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック
スマホの場合は、「ホーム」ボタンの横の「<」キーをタップ

-

-


目次

-

参考:

  1. 「Vagrant」コマンドについて:

  2. 「Vagrant」コマンドの使用例:

  3. 「Vagrant」コマンドの使用例:(目次)

  4.  修正版3: 使い回し可能な「Vagrantfile」:

-

今回の作業:

  1. 「仮想マシン」から「Box」ファイルを作成:

  2. 「Box」ファイルを「Box」の一覧に追加:

  3.  仮の「Vagrantfile」の作成:

  4. 「仮想マシン」を(作成して)立ち上げ:

  5.  最終的な「Vagrantfile」の作成:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

Vagrant」で「EndeavourOS」(Openbox) を起動:

-

1). ホストの「Xubuntu 22.04 LTS」の端末で「vagrant up」と入力:

仮想マシン」画面が立ち上がりました。「VirtualBox マネージャ」は起動されていません。

ホストの「端末」にて、ssh 接続を繰り返すのは、予想外:

→右の緑色の「CPU モニター」が大きめに振れてます。
なかなかタイムアウトにならず、そのままだと負荷になるので、「端末」画面を右上の「x」で閉じました。

-

「Box」作成のとき、事前に「仮想マシン」に、「Vagrant」の推奨の(vagrant ユーザの作成や、ssh 接続等の)設定を行わなかった影響のようです。

→「Vagrant」は ssh 接続が前提ということ。本処置でなく、「Vagrantfile」の修正で回避 できました。

-


2). ログイン画面が表示:

→壁紙が新しくなっています。
これは、「EndeavourOS」で次期 ISO イメージの公開に伴う、「大きめの更新」があったから。

-

→パスワード入力

-


3). デスクトップ画面が表示:

→元の「仮想マシン」で使っていた壁紙と環境です。

以前と同じように「仮想マシン」は使えます。支障ありません。

Vagrant」の「Box」として保存して、使えることを確認しました。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

VirtualBox」について:

-

VirtualBox」は、Oracle が開発している「仮想マシン」を構築するためのソフトウェアです。

-

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

Vagrant」 (ベイグラント) について:

-

公式サイト:

Vagrant by HashiCorp

-

仮想マシン」の管理や操作をコマンドで使うための「フロントエンド」のソフトウェアです:

-

→詳細は、前回に投稿の「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

1. 「VirtualBox」で作成した「仮想マシン」を「Vagrant」の「Box」として使えるかトライ:

-

Xubuntu 22.04 LTS」の「VirtualBox 7.0」にインストールした「EndeavourOS(Openbox)」の「仮想マシン」を使いました。

-

個人で使えれば良いだけなので、「Vagrant」の「Box」の公開を前提にした(vagrant ユーザの作成や、ssh 接続等の)設定は行いませんでした。

-

今回、使用したのは、「Openbox」環境です。
「EndeavourOS」の最新のISO イメージからは、「Openbox」の新規インストールが出来なくなりました。

以前に投稿した手順は使えないので、

「EndeavourOS」のインストール手順は、「EndeavourOS」(Xfce)の「こちら 」の手順を参照してください:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

2. 「Vagrant」で「Box」ファイルを作成:

-

参考: 「vagrant package」コマンド から抜粋:

使い方: vagrant package [オプション] [name|id]

オプション:

  --base NAME            ベース ボックスとしてパッケージ化したい
                         VirtualBox 内の VM の名前 (VirtualBox の場合)
  --output NAME          出力するファイルの名前
  --include FILE,FILE..  ボックスにパッケージ化するカンマ区切りの追加ファイル
  --info FILE            追加のボックス情報を含むカスタム info.jsonファイルへのパス
  --vagrantfile FILE     ボックスに同梱する Vagrantfile

-


1). VirtualBox に追加されている「仮想マシン」の名前(フォルダ名)を確認:

$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox               ←(★)
test3_default_1701354147406_49248        ←(「Vagrant」で管理)
ubn2204-dev_default_1702311334111_40485  ←(「Vagrant」で管理)
ubn2204_default_1701558714834_11706      ←(「Vagrant」で管理)

→「★」は、「Vagrant」で管理されていません:

Vagrant」で管理されていない場合の「仮想マシン」名は、上記の「フォルダ名」です。

Vagrant」で管理されている場合の「仮想マシン」名は、フォルダ名に含まれている「default」です。

-

参考: 「Vagrant」で管理されている(VirtualBox の)すべての「仮想マシン」を表示:

$ vagrant global-status
id       name    provider   state    directory                           
-------------------------------------------------------------------------
d4b57c8  default virtualbox poweroff /home/ubn/ダウンロード/vm/test3           
5770428  default virtualbox poweroff /home/ubn/ダウンロード/vm/ubn2204         
368c4fa  default virtualbox poweroff /home/ubn/ダウンロード/vm/ubn2204-dev     
:

→「Vagrant」で管理されている場合の「仮想マシン」名は、すべて「default」です。

-


2). 「作業フォルダ」を作成して、移動:

ちょっと長いけど、分かりやすい名前にしました:

$ mkdir -p ~/ダウンロード/vm/endeavour-openbox/
$ cd ~/ダウンロード/vm/endeavour-openbox/

→「Box」ファイルが作成される場所になります

-


3). 「Box」ファイルを作成:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ vagrant package --base EndeavourOS_OpenBox

「EndeavourOS_OpenBox」は、「virtualbox」での「仮想マシン」名です。
ここからベースとなる「Box」ファイルが作成されます。

==> EndeavourOS_OpenBox: Exporting VM...

↓ 時間がかかりました

==> EndeavourOS_OpenBox: Compressing package to: /home/ubn/ダウンロード/vm/endeavour-openbox/package.box

↓ 時間がかかりました

ubn@ubn-box:~/ダウンロード/vm/endeavour-openbox$ 

プロンプトに戻りました。

→作業フォルダに、「package.box」ファイルが作成されました:

$ pwd
/home/ubn/ダウンロード/vm/endeavour-openbox
$ ls -lA
:
-rw-rw-r-- 1 ubn ubn 12637560377 12月 12 13:55 package.box

→「12.6 GB」ほど

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

3. 作成された「Box」ファイルを「Box」の一覧に追加:

-


1). できた「Box」ファイルをホームの「Box」一覧に追加:

$ vagrant box add --name Endeav-openbox package.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'Endeav-openbox' (v0) for provider: 
    box: Unpacking necessary files from: file:///home/ubn/%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89/vm/endeavour-openbox/package.box
Progress: 69% (Rate: 45.4M/s, Estimated time remaining: 0:00:37)

↓ ファイルを解凍中: カウントUP

==> box: Successfully added box 'Endeav-openbox' (v0) for ''!
ubn@ubn-box:~/ダウンロード/vm/endeavour-openbox$ 

プロンプトに戻りました。

-


2). 「Box」の一覧に追加されたか確認:

$ vagrant box list
Endeav-openbox              (virtualbox, 0)              ←(追加)
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)
ubn2204-dev                 (virtualbox, 0)

-


3). 参考: ホームの「Box」の一覧にあるファイルを確認:

$ ls -lA ~/.vagrant.d/boxes/Endeav-openbox/0/virtualbox
-rw-rw-r-- 1 ubn ubn         505 12月 12 15:47 Vagrantfile
-rw-rw-r-- 1 ubn ubn 12739932672 12月 12 15:51 box-disk002.vmdk
-rwx------ 1 ubn ubn        9564 12月 12 15:51 box.ovf
-rw-rw-r-- 1 ubn ubn          25 12月 12 15:51 metadata.json

-

参考: ホームにある「Vagrantfile」の内容を確認:
$ cat ~/.vagrant.d/boxes/Endeav-openbox/0/virtualbox/Vagrantfile
Vagrant::Config.run do |config|
  # This Vagrantfile is auto-generated by `vagrant package` to contain
  # the MAC address of the box. Custom configuration should be placed in
  # the actual `Vagrantfile` in this box.
  config.vm.base_mac = "080027A4E2F0"
end

# Load include vagrant file if it exists after the auto-generated
# so it can override any of the settings
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)

→ケースによって、使われるテンプレートが変わる(決まっている)みたい。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

4. 「Vagrantfile」の作成:

-


1). 「Vagrantfile」の作成:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ vagrant init -m Endeav-openbox
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

→いつもの表示メッセージです

-

確認:
$ ls -1A
:
Vagrantfile         ←(追加)
package.box

-

2). 「Vagrantfile」の内容を確認:

$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "Endeav-openbox"
end

-


3). 「Vagrantfile」の修正:

前回の「Ubuntu 22.04」のBox の共有で使った内容を参考にしました:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ featherpad Vagrantfile

↓ すべて置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "Endeav-openbox"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

Ctrl+S で保存

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

5. 「仮想マシン」を(作成して)立ち上げ:

-


1). 「仮想マシン」を立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'Endeav-openbox'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: endeavour-openbox_default_1702366872448_91638
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
: 繰り返し

    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...

→緑色のCPU モニターのバーが振れてます。負荷になってます。

-

その後、赤い警告表示:

Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.

和訳:

「仮想マシン」の起動の待機中にタイムアウトになりました。

これは、Vagrant が設定された時間 (「config.vm.boot_timeout」値) 内に
ゲスト マシンと通信できなかったことを意味します。

:
認証設定も適切に設定されていることを確認してください。

ボックスが適切に起動している場合は、
タイムアウト (「config.vm.boot_timeout」) 値を増やせます。

-


2). 問題点1: 立ち上げ時に ssh 接続のリトライ繰り返し、その後タイムアウト:

参考:

[Vagrant] vagrant upがタイムアウトになるときの対処法

-

OS によって、立ち上がりに時間がかかる場合は、
「Vagrantfile」に下記の 1行を追記して、タイムアウト値を延ばします:

config.vm.boot_timeout = 600

(単位は秒で、デフォルトは 300秒)

-

ssh の設定が行われていないので、たぶん、改善しないと思われます。

念の為、設定してみました:

-

回避策1: 「Vagrantfile」の修正1:(追記: 効果なしだったので作業は要りません)
$ cd ~/ダウンロード/vm/endeavour-openbox/
$ featherpad Vagrantfile

↓ すべて置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "Endeav-openbox"
  config.vm.boot_timeout = 600                     ←(大きくしました)
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

Ctrl+S で保存

-


3). 問題点2: ディスク立ち上げでなく、ライブ立ち上げされました:

-

「Box」作成時に、「仮想マシン」に最新OS のテストのための「ISO イメージ」をマウントし放しだったみたい。

たぶん、これもタイムアウトに影響したと思われます。いつもより立ち上げが遅くなります。

-

参考: これは有益な情報です: 「ISO イメージ」で立ち上げた「仮想マシン」も「Box」にできます:

→何かに使えそう。

-

回避策2:

「ISO イメージ」をアンマウントすれば良いだけ。

-


4). 「仮想マシン」を停止:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ vagrant halt
==> default: Attempting graceful shutdown of VM...
    default: Guest communication could not be established! This is usually because
    default: SSH is not running, the authentication information was changed,
    default: or some other networking issue. Vagrant will force halt, if
    default: capable.
==> default: Forcing shutdown of VM...

和訳:

==> default: 「仮想マシン」を正常にシャットダウンしようとしています...
    default: ゲスト通信を確立できませんでした。
    default: これは通常、SSH が実行されていない、認証情報が変更された、
    default: またはその他のネットワークの問題が原因です。
    default: 可能であれば、Vagrant は強制的に停止します。
==> default: 「仮想マシン」を強制的にシャットダウンしています...
問題点3: →「SSH」を起動していないので、当然ですが、シャットダウン時の表示がうるさいです。

→警告が表示されるだけなので、支障なし。

-


5). 「VirtualBox」マネージャを起動:

VirtualBox」マネージャで「光学ドライブ」を取り外す方が早いです。

-

左側で仮想マシンの「endeavour-openbox_default_1702366872448_91638」をクリックして選択:

右の「ストレージ」にある、[光学ドライブ] Endeavouros-Galileo-11-2023.iso (2.43 GB) をクリック

→「仮想ドライブからディスクを除去」

→[光学ドライブ] 空 に変わりました。

-


6). 「共有フォルダ」を有効にするために、ホストOS を再起動:

$ reboot

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

6. 「仮想マシン」に設定を反映させて、再立ち上げ:

-


1). 「仮想マシン」を再作成して、立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ vagrant reload
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying
: 繰り返し
問題点4: →「Vagrant」はSSH 接続できることが前提なので、立ち上げ時に接続のメッセージが繰り返されるのはしかたないかな:

警告が表示されないけど、ホストOS の負荷になっています。「タイムアウト値を大きくする」修正は逆効果でした。

→「端末」画面を右上の「x」で閉じました。

-


2). ログイン画面が表示:

→パスワード入力

-


3). デスクトップ画面が表示:

-


4). 「仮想マシン」を停止:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ vagrant halt

-


5). 回避策1-2: 「Vagrantfile」の修正2(タイムアウト値を小さくしました):

今度は逆に、早くタイムアウト(端末を開放)するように値を小さくしました。

-

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ featherpad Vagrantfile

↓ 2行の修正:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "Endeav-openbox"
  #config.vm.boot_timeout = 300                     ←(デフォルト値)
  config.vm.boot_timeout = 60                     ←(小さくしました)
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

Ctrl+S で保存

-

参考:「config.vm.box = "Endeav-openbox"」の行を変更すれば、他の「仮想マシン」でも使いまわし出来ます:

-


6). 「仮想マシン」に設定を反映させて、再立ち上げ:

$ cd ~/ダウンロード/vm/endeavour-openbox/
$ vagrant reload
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...
    default: Warning: Authentication failure. Retrying...

赤色の警告(タイムアウト):

Timed out while waiting for the machine to boot. This means that
Vagrant was unable to communicate with the guest machine within
the configured ("config.vm.boot_timeout" value) time period.

If you look above, you should be able to see the error(s) that
Vagrant had when attempting to connect to the machine. These errors
are usually good hints as to what may be wrong.

If you're using a custom box, make sure that networking is properly
working and you're able to connect to the machine. It is a common
problem that networking isn't setup properly in these boxes.
Verify that authentication configurations are also setup properly,
as well.

If the box appears to be booting properly, you may want to increase
the timeout ("config.vm.boot_timeout") value.
ubn@ubn-box:~/ダウンロード/vm/endeavour-openbox$ 

→プロンプトに戻りました。

早めにタイムアウトになり、端末が開放されました。
すでに「仮想マシン」は起動されているので支障なし。

-

問題点5: リトライや警告の表示が邪魔して、それ以降のメッセージは確認できません:

→正常に立ち上がれば良いけど、うまく立ち上がらないときは情報が不足するかも。

-


7). もし、「Vagrantfile」を修正しない場合は、

仮想マシン」が立ち上がったら、「端末」画面を、右上の「x」で閉じます。

必要になった時に、「端末」を再び起動すればいいだけです。

これはこれで良いのかも。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

7. 「Vagrant」の個人的な使い方:

-

個人的には、色々な「Linux ディストリビューション」をインストールして確認する作業を行っています。

手間をかけてカスタマイズした「仮想マシン」ですが、ディスク容量には限りがあるので、残すのは 3個ぐらいに留めていて、その都度、削除しています。

-

Vagrant」は、「仮想マシン」を再現したり、廃棄したりが自由です。

手間をかけてカスタマイズした中で、有益な「Linux ディストリビューション」(仮想マシン)であれば、「Vagrant」で残す(保存する)ことにしました:

-

デスクトップ環境がある「仮想マシン」を「Box」に使った場合、

Vagrant」は「ssh 接続」が前提なので、推奨された「ssh 接続」等の設定が行われていないと、 「仮想マシン」の「立ち上げ」や「電源オフ」時に余計なメッセージが表示されます。

-

ssh 接続」では使わないのに、「仮想マシン」に「Vagrant」推奨の設定を追加するのは無駄です:

→「Vagrantfile」で、立ち上げのタイムアウト値を小さくする(下記の参考: を参照)と、すぐに端末が開放されました。

-

参考: 使い回し出来る「Vagrantfile」の内容:

→「Box」を作成した「仮想マシン」を「config.vm.box = "Endeav-openbox"」の行で指定すれば、他の「仮想マシン」でも使い回し出来ます:

-

-


まとめ

今回の目的は、「仮想マシン」を「Box」として簡単に保存出来るかです。なので、「Box」の公開時に行うべき?(vagrant ユーザの作成や、ssh 接続の設定)などの作業は省きました。

-

その影響で、ssh 接続の要らない、デスクトップ環境を持つ「仮想マシン」を「Box」にした場合であっても、 「仮想マシン」の立ち上げや、電源オフで、余計なメッセージが表示されます。

これは、「Vagrantfile」の修正 で何とか回避出来たので、当初の目的は果たせました。

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-

Vagrant 実践編1:「Ubuntu 22.04」の「仮想マシン」作成と「Box」の共有〈H170-2〉

登録日: 2023-12-12 更新日: 2024-03-14

Xubuntu 22.04 LTS」および「Windows11」(22H2) の「VirtualBox 7.0」の仮想マシンに、色々なLinux ディストリビューションをインストールして、自分に最適なものはないか試しています。

開発環境では、それらの仮想マシン(ボックス)の管理に「Vagrant」(ベイグラント) というツールが、よく使われています。

-

(実践編1):

今回は「Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて、「Vagrant」を使えるようにした後に、

Vagrant」で実際に Ubuntu 22.04(デスクトップ) の「仮想マシン」を作成、 および、その「Box」を共有してみました。

その備忘録です。

-

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック
スマホの場合は、「ホーム」ボタンの横の「<」キーをタップ

-

-


目次

-

参考:

  1. 「Vagrant」コマンドについて:

  2. 「Vagrant」コマンドの使用例:

  3. 「Vagrant」コマンドの使用例:(目次)

  4.  修正版3: 使い回し可能な「Vagrantfile」:

-

今回の作業:

  1.  Vagrant で使う「Box」を検索:

  2. 「VirtualBox」をインストール:

  3. 「Vagrant」をインストール:

  4. 「仮想マシン」の(初回の作成と)立ち上げ:

  5. 「Vagrantfile」ファイルの修正:

-

追加の作業:

  1. 「共有」したい「仮想マシン」を元に、新しい「Box」を作成:

  2.  配布された「Box」にて、「仮想マシン」を「共有」:

-

問題点の回避策:

  1. 回避策1: 「仮想マシン」の立ち上げ時に「Guest Additions」のバージョンが合わないとの警告:

  2. 回避策2: 立ち上げた「仮想マシン」のデスクトップ画面が時々真っ暗:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

Xubuntu 22.04 LTS」を起動:

-

VirtualBox 7.0.10」の仮想マシンUbuntu 22.04」(デスクトップ有り)を「Vagrant」で起動:

→ホストの「Xubuntu 22.04 LTS」の端末で「vagrant up」と入力するだけで起動しています。

ちなみに、「VirtualBox マネージャ」は起動していません。

-

VirtualBox マネージャ」を起動:

→「Vagrant」で管理されている「仮想マシン」の名前に注目(「default」が含まれます)。
Vagrant」で管理されていますが、「VirtualBox マネージャ」で「仮想マシン」の状態を確認したり、いつも通りの管理が可能です。

-

上記の「仮想マシン」をカスタマイズ:

→壁紙を変えて、ドックのアイコンを小さくして、画面半分のサイズに拡大
システム更新後、アプリを追加しています。

こちらの「仮想マシン」を「項番 9. 」で「共有」してみました。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

VirtualBox」について:

-

VirtualBox」は、Oracle が開発している「仮想マシン」を構築するためのソフトウェアです。

-

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

Vagrant」 (ベイグラント) について:

-

公式サイト:

Vagrant by HashiCorp

-

仮想マシン」の管理や操作をコマンドで使うための「フロントエンド」のソフトウェアです:

-

→詳細は、前回に投稿の「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

1. 事前に、Vagrant で使う「Box」を検索:

-

検索は、「vagrant box add」や「vagrant init」前であれば、いつでも良いです:

-

公式のVagrant の「Box」の公開サイト:

Discover Vagrant Boxes

→「Vagrant cloud」に「Box」は保存されています:

-

デフォルトは「ダウンロード数」でのソートなので、ダウンロードが 1番多い「Box」が 1番上に来ます:

「ダウンロード数」が多いということは、検証されていて、怪しいときは削除される?と思うので、少し安心。

-

「検索キー」の入れ方で、微妙に、表示される「Box」が変わります:

-


1). 「ubuntu22」で検索:

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

(a).「generic/ubuntu2204」v4.3.6

クロスプラットフォーム開発で使用するためのビルド環境:

hyperv           Vagrant Cloud (1.46 GB)  
libvirt          Vagrant Cloud (1.57 GB)  
parallels        Vagrant Cloud (1.69 GB)  
virtualbox       Vagrant Cloud (1.57 GB)  
vmware_desktop   Vagrant Cloud (1.41 GB)  

→ 1番ダウンロード数が多いです。登録が「Vagrant Cloud」なので安心かな。

「デスクトップ環境」なしと思うけど、開発ツールが入っているのか、サイズが大きめ?。
もしかしたら「デスクトップ環境」ありかも?。インストールしないとわかりません。

-


2). 「ubuntu22 desk」で検索:

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

(b).「fasmat/ubuntu2204-desktop」v22.0509.1

This version was created over 1 year ago. ←( 1年以上前に作成: ここが悩むところ)

Ubuntu Desktop 22.04 Jammy Jellyfish (64-bit)
VirtualBox Guest Additions v6.1.34

virtualbox       Vagrant Cloud (1.49 GB) 
vmware_desktop   Vagrant Cloud (1.49 GB) 

→「デスクトップ」環境あり。登録が「Vagrant Cloud」で、毎回アップの常連さんです。
サイズの表示もあり。デスクトップ環境であればこんなものかな。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

(c). 「nercceh/ubuntu22.04-desktop」4.0.3

Puppet とさまざまな開発者ツールがプリインストールされた Ubuntu 22.04 デスクトップ

virtualbox       外部ホスト (dist.nerc-lancaster.ac.uk)  サイズ不明
vmware_desktop   外部ホスト (dist.nerc-lancaster.ac.uk)  サイズ不明

→「デスクトップ」環境は、Ubuntu 純正の「Gnome」でした。

-

登録が「外部サーバー」だとセキュリティ面では不利です:

→(Lancaster University) は、リビジョンごとに毎回アップの常連さんなので安心かな。

-

「外部サーバー」だと サイズが表示されません:

→ダウンロードしたら、2.7 GiB

(気に入るかわからない)開発者ツールがすでに入っている のがポイント。
サイズが大きくなりますが、もしかしたら、使い勝手が良くて便利かも。

-


3). 個人で使うには「デスクトップ環境」があると便利。とりあえず「nercceh/ubuntu22.04-desktop」を選びました:

Vagrant の「Box」は開発環境での使用が多く、ほとんどが「デスクトップ環境」なし、だろうと思います:

ただし、Ubuntu はデスクトップありが普通なので、desktop や、server が「Box」名に付いていない場合は、「デスクトップ環境」ありの場合もあるかも。試して見ないとわかりません。

-


削除は簡単なので、3つとも確認してみたいところ:

「Box」と「仮想マシン」の削除のやり方は、 「項番 9-2. の11). 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

2. 「Xubuntu 22.04 LTS」にて、「VirtualBox」をインストール:

-

「.deb」ファイルをダウンロードして、最新の「VirtualBox 7.0.10」がすでにインストール済みです:

-

インストールしたときの手順は「こちら 」:

→「VirtualBox」の「アップデート」手順ですが、「新規インストール」の手順も同じです:

-

内容:
(1). 「VirtualBox」のインストール:
(2). 「VirtualBox Extension」のインストール:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

3. ホストOS に「Vagrant」をインストール:

-

追記:

Vagrant」をインストールするときは、「VirtualBox」とのバージョンの整合に注意:

-

  • apt でインストールした「Vagrant」のバージョンだと、最新の「VirtualBox 7.0」はサポートされていませんでした。

-

  • 最新の「VirtualBox」(7.0) をインストールした場合は、最新の「Vagrant」をインストールすると良いです:

 →「VirtualBox 7.0」をサポートしている可能性が高いです。

-

  • apt でインストールされる「Vagrant 2.2.19」は、「VirtualBox 6.1」までのサポートです:

  • apt でインストールした場合、「VirtualBox 6.1」なので、「Vagrant」をapt でインストールして良いです。

-


参考: apt でインストールされるバージョン:

Xubuntu 22.04.3 LTS」にて確認:

2023-12-02 現在:

-

$ apt list virtualbox -a
:
virtualbox/jammy-updates 6.1.38-dfsg-3~ubuntu1.22.04.1 amd64
virtualbox/jammy 6.1.32-dfsg-1build1 amd64

→apt でインストールされる「virtualbox」のバージョンは「6.1.38」

-

$ apt list vagrant -a
:
vagrant/jammy,jammy 2.2.19+dfsg-1ubuntu1 amd64

→apt でインストールされる「vagrant」のバージョンは「2.2.19」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

3-a. 参考: 最新の「VirtualBox 7.0」の環境で、(楽をしようと)apt で「Vagrant」をインストール:

-

失敗例なので、確認だけにしてください:

-

Vagrant」が「VirtualBox 7.0」をサポートしておらず、「仮想マシン」の作成で「失敗」しました

ちなみに、「VirtualBox 6.1」の環境であれば 、apt で「Vagrant」をインストールして使えます

-

-


参考:( ↓ 以下は、楽をしようとして、失敗した手順です)


-

1). 「VirtualBox」のインストールを確認:

$ apt list virtualbox -a | grep 済
$ 

→apt でのインストールなし。

-

$ apt list virtualbox* -a | grep 済
:
virtualbox-7.0/now 7.0.10-158379~Ubuntu~jammy amd64 [インストール済み、ローカル]

→手動(ダウンロード)でインストールされています。

(最新の)「.deb」パッケージをダウンロードしてインストールしたので、「ローカル」の表示があります。

-

パッケージ名が「virtualbox」ではなく、「virtualbox-7.0」であることに注目:
(7.0 が主流になれば、「virtualbox」になるはずです)

-


2). (楽をしようと)apt で「Vagrant」をインストールしました:

$ sudo apt update
$ sudo apt install vagrant
以下のパッケージが新たにインストールされます:
  attr augeas-lenses bsdmainutils btrfs-progs cryptsetup-bin db-util
  db5.3-util debootstrap exfatprogs extlinux f2fs-tools finalrd gawk
  guestfish guestfs-tools guestmount hfsplus icoutils keyutils kpartx
  ldmtool libafflib0v5 libarchive-tools libaugeas0 libbfio1 libconfig9
  libdate-manip-perl libevent-core-2.1-7 libewf2 libguestfs-hfsplus
  libguestfs-perl libguestfs-reiserfs libguestfs-tools libguestfs-xfs
  libguestfs0 libhfsp0 libhivex0 libinih1 libintl-perl libintl-xs-perl
  libldm-1.0-0 libnetpbm10 libnfsidmap1 librpm9 librpmio9 libsigsegv2
  libstring-shellquote-perl libsys-virt-perl libtsk19 libvhdi1 libvmdk1
  libwin-hivex-perl libxml-xpath-perl libyara8 lsscsi lzop mdadm mtools
  ncal netpbm nfs-common nfs-kernel-server osinfo-db racc reiserfsprogs
  rpcbind rpm-common ruby-bcrypt-pbkdf ruby-builder ruby-childprocess
  ruby-concurrent ruby-ed25519 ruby-erubi ruby-excon ruby-ffi
  ruby-fog-core ruby-fog-json ruby-fog-libvirt ruby-fog-xml
  ruby-formatador ruby-i18n ruby-libvirt ruby-listen ruby-log4r
  ruby-mime-types ruby-mime-types-data ruby-mini-portile2 ruby-multi-json
  ruby-net-scp ruby-net-sftp ruby-net-ssh ruby-nokogiri ruby-oj
  ruby-pkg-config ruby-rb-inotify ruby-vagrant-cloud ruby-zip scrub
  sleuthkit supermin syslinux syslinux-common vagrant vagrant-libvirt
  virt-p2v xfsprogs zerofree
アップグレード: 0 個、新規インストール: 107 個、削除: 0 個、保留: 0 個。

-


3). インストールされたか確認:

$ apt list vagrant
:
vagrant/jammy,jammy,now 2.2.19+dfsg-1ubuntu1 all [インストール済み]

-

Vagrant」のバージョンを確認:

$ vagrant --version
Vagrant 2.2.19

-


4). ホストOS を再起動:

$ reboot

-


5). 作業用ディレクトリの作成:

作業用のディレクトリ名は、分かりやすい名前にしました:

$ mkdir -p ~/ダウンロード/vm/ubn2204/
$ cd ~/ダウンロード/vm/ubn2204/

-


6). 「Box」をダウンロード、および「Vagrantfile」を作成:

例: 公式サイトの「Box」を指定:「nercceh/ubuntu22.04-desktop」

$ vagrant init nercceh/ubuntu22.04-desktop
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

和訳:

「Vagrantfile」はこのディレクトリに配置されています。  
これで、最初の仮想環境を「vagrant up」する準備が整いました。  
Vagrant の使用方法の詳細は、Vagrantfile のコメントと「vagrantup.com」の
ドキュメントをお読みください。

→これは、いつもの表示です。すぐに完了しました。

-

参考: わざわざ、「vagrant box add」を使って「Box 一覧」に追加しなくても、
「Box」のイメージがダウンロードされていなければ、初回に「vagrant up」したときにダウンロードされます。

-

「作業フォルダ」の確認:

$ ls -lA ~/ダウンロード/vm/ubn2204
:
-rw-rw-r-- 1 ubn ubn 3033 11月 18 16:44 Vagrantfile
→「Vagrantfile」だけが作られました。

-


7). 仮想マシンの(初回の作成と)立ち上げ:(失敗)

$ vagrant up --provider=virtualbox

もしくは、

$ vagrant up

→「--provider=virtualbox」のパラメータは「virtualbox」がデフォルトなので、省略できます。

-

赤色のメッセージが表示:
The provider 'virtualbox' that was requested to back the machine
'default' is reporting that it isn't usable on this system. The
reason is shown below:

Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:

4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0, 6.1

A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.

和訳:

マシン「default」でサポートするように要求されたプロバイダ「virtualbox」は、
このシステムでは使用できません。

その理由は以下です:

Vagrant は、このバージョンの Vagrant でサポートされていないバージョンの
VirtualBox がインストールされていることを検出しました。

Vagrant を使用するには、以下の一覧のサポートされているバージョンの
VirtualBox を使用してください。

4.0、4.1、4.2、4.3、5.0、5.1、5.2、6.0、6.1

指定したバージョンのサポートを追加する Vagrant のアップデートを利用できる場合があります。  
最新バージョンのダウンロードは、www.vagrantup.com/downloads.html を確認してください。
→apt でインストールした「Vagrant 2.2.19」では、最新の「VirtualBox 7.0.10」は未サポートでした。
なので、「仮想マシン」の作成で失敗しました:

-

-


8). うまく動かなかった「Vagrant」を削除:

-

(1). 「Vagrant」の確認:
$ apt list vagrant
:
vagrant/jammy,jammy,now 2.2.19+dfsg-1ubuntu1 all [インストール済み]

-

(2). 「Vagrant」の削除:
$ sudo apt remove vagrant

-

(3). 削除されたか確認:
$ apt list vagrant
:
vagrant/jammy,jammy 2.2.19+dfsg-1ubuntu1 all

-

(4). ゴミの削除:
$ sudo apt autoremove

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

3-b. 最新の「VirtualBox 7.0」の環境で、最新の「Vagrant」をインストール:

-

最新の「VirtualBox」をダウンロードしてインストールしているので、最新の「Vagrant」をダウンロードしてインストールしました:

-

参考: 整合するバージョンの組合せ:

-


1). 「VirtualBox」のインストールを確認:

$ apt search virtualbox-7.0
:
virtualbox-7.0/now 7.0.10-158379~Ubuntu~jammy amd64 [インストール済み、ローカル]
  Oracle VM VirtualBox

→ダウンロードした最新の「.deb」パッケージをインストール
 「ローカル」の表示があることに注目

-


2). 最新の「Vagrant」をダウンロードしてインストール:

-

(1). 最新の vagrant_2.4.0-1_amd64.deb をダウンロード:

-

(2). チェックサムが同じか確認:
$ cd ~/ダウンロード/

$ sha256sum vagrant_2.4.0-1_amd64.deb
e04916750205819c90e38acf639ab12af89fd4593dcc6ef38c33c306666f73c5  vagrant_2.4.0-1_amd64.deb

-

(3). 「.deb」ファイルのインストール:
$ sudo apt install ./vagrant_2.4.0-1_amd64.deb
以下のパッケージが新たにインストールされます:
  vagrant

-

(4). インストールされたか確認:
$ apt list vagrant -a
:
vagrant/now 2.4.0-1 amd64 [インストール済み、ローカル]
vagrant/jammy,jammy 2.2.19+dfsg-1ubuntu1 amd64

→ローカルの表示に注目

-

バージョンを確認:

$ vagrant --version
Vagrant 2.4.0

-

(5). ホストOS を再起動:
$ reboot

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

4. 「仮想マシン」の(初回の作成と)立ち上げ:

-

1). 作業用ディレクトリの作成:

作業用のディレクトリ名は分かりやすい名前にしました:

$ mkdir -p ~/ダウンロード/vm/ubn2204/
$ cd ~/ダウンロード/vm/ubn2204/

-

前回の作業で作成されたファイルがあれば削除:

$ ls -1A
.vagrant
Vagrantfile

-

$ rm -r .vagrant
$ rm Vagrantfile
$ ls -A
$ 

-

2). 「Box」をダウンロード、および「Vagrantfile」を作成:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant init nercceh/ubuntu22.04-desktop
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

和訳:

「Vagrantfile」はこのディレクトリに配置されています。  
これで、最初の仮想環境を「vagrant up」する準備が整いました。  
Vagrant の使用方法の詳細は、Vagrantfile のコメントと「vagrantup.com」の
ドキュメントをお読みください。

→すぐに完了しました。

-

確認:

$ cd ~/ダウンロード/vm/ubn2204
$ ls -lA
:
-rw-rw-r-- 1 ubn ubn 3401 11月 18 18:37 Vagrantfile

→「Vagrantfile」が作られただけです。

-

3). 参考: 公式のVagrant の「Box」の登録サイトにある、「Vagrantfile」タブを表示:

Vagrant.configure("2") do |config|                     ←(1行目)
  config.vm.box = "nercceh/ubuntu22.04-desktop"        ←(2行目)
end                                                    ←(3行目)

-

4). 実際の「Vagrantfile」の内容を確認:

$ cd ~/ダウンロード/vm/ubn2204/
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|                ←( 1行目)★
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "nercceh/ubuntu22.04-desktop"    ←( 2行目)★

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Disable the default share of the current code directory. Doing this
  # provides improved isolation between the vagrant box and your host
  # by making sure your Vagrantfile isn't accessable to the vagrant box.
  # If you use this you may want to enable additional shared subfolders as
  # shown above.
  # config.vm.synced_folder ".", "/vagrant", disabled: true

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end                                              ←( 3行目)★

-

5). 仮想マシンの作成と立ち上げ:

→最新の「VirtualBox 7.0.10」の場合は、最新の「Vagrant 2.4.0」のインストールが必要でした:

-

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up --provider=virtualbox

「--provider=virtualbox」のパラメータはデフォルトなので、省略できます。

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'nercceh/ubuntu22.04-desktop' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'nercceh/ubuntu22.04-desktop'
    default: URL: https://vagrantcloud.com/api/v2/vagrant/nercceh/ubuntu22.04-desktop
==> default: Adding box 'nercceh/ubuntu22.04-desktop' (v4.0.3) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/nercceh/boxes/ubuntu22.04-desktop/versions/4.0.3/providers/virtualbox/unknown/vagrant.box
Download redirected to host: dist.nerc-lancaster.ac.uk
Progress: 32% (Rate: 5885k/s, Estimated time remaining: 0:07:06)

: ダウンロードがあるので、時間がかかります(最後の行がカウントUP):

==> default: Successfully added box 'nercceh/ubuntu22.04-desktop' (v4.0.3) for 'virtualbox'!
==> default: Importing base box 'nercceh/ubuntu22.04-desktop'...
Progress: 80%

: 時間がかかります(最後の行がカウントUP):

==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'nercceh/ubuntu22.04-desktop' version '4.0.3' is up to date...
==> default: Setting the name of the VM: ubn2204_default_1700301456943_75635
Vagrant is currently configured to create VirtualBox synced folders with
the `SharedFoldersEnableSymlinksCreate` option enabled. If the Vagrant
guest is not trusted, you may want to disable this option. For more
information on this option, please refer to the VirtualBox manual:

  https://www.virtualbox.org/manual/ch04.html#sharedfolders

This option can be disabled globally with an environment variable:

  VAGRANT_DISABLE_VBOXSYMLINKCREATE=1

or on a per folder basis within the Vagrantfile:

  config.vm.synced_folder '/host/path', '/guest/path', SharedFoldersEnableSymlinksCreate: false
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222          ←(SSH 接続する場合の情報)
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Connection reset. Retrying...
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...      ←(チェックで問題あり)
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 6.1.38
    default: VirtualBox Version: 7.0
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204

→「VirtualBox」の仮想マシン「ubn2204_default_1700301456943_75635」が、マネージャ画面なしで自動起動されましたが、「画面真っ暗」です。

-


6). 「Vagrant」側のファイル階層を確認:

「Box」側の確認です:

-

「作業フォルダ」の位置:
$ pwd
/home/ubn/ダウンロード/vm/ubn2204

-

「作業フォルダ」のファイル階層を表示:

簡易的なツリー表示:

$ ls -1ARp ~/ダウンロード/vm/ubn2204/
/home/ubn/ダウンロード/vm/ubn2204/:
.vagrant/
Vagrantfile           ←(「Vagrantfile」)

/home/ubn/ダウンロード/vm/ubn2204/.vagrant:  ←(「.vagrant/ フォルダの中身」)
machines/
rgloader/

/home/ubn/ダウンロード/vm/ubn2204/.vagrant/machines:
default/

/home/ubn/ダウンロード/vm/ubn2204/.vagrant/machines/default:
virtualbox/

/home/ubn/ダウンロード/vm/ubn2204/.vagrant/machines/default/virtualbox:
action_provision
action_set_name
box_meta
creator_uid
id
index_uuid
private_key
synced_folders
vagrant_cwd

/home/ubn/ダウンロード/vm/ubn2204/.vagrant/rgloader:
loader.rb

-


7). 「VirtualBox」側のファイル階層を確認:

仮想マシン」側の確認です:

-

仮想マシン」側のファイル階層を表示:
$ ls -ARp1 ~/'VirtualBox VMs'/
'/home/ubn/VirtualBox VMs/':
EndeavourOS_OpenBox/                          ←(「VirtualBox」で作成した「仮想マシン」)
ubn2204_default_1700301456943_75635/    ←(「Vagrant」で作成された「仮想マシン」)

'/home/ubn/VirtualBox VMs/EndeavourOS_OpenBox':
EndeavourOS_OpenBox.nvram
EndeavourOS_OpenBox.vbox
EndeavourOS_OpenBox.vbox-prev
EndeavourOS_OpenBox.vdi
Logs/

'/home/ubn/VirtualBox VMs/EndeavourOS_OpenBox/Logs':
VBox.log
VBox.log.1
VBox.log.2
VBox.log.3

'/home/ubn/VirtualBox VMs/ubn2204_default_1700301456943_75635':
Logs/
packer-virtualbox-iso-1670500096-disk001.vmdk
ubn2204_default_1700301456943_75635.vbox
ubn2204_default_1700301456943_75635.vbox-prev

'/home/ubn/VirtualBox VMs/ubn2204_default_1700301456943_75635/Logs':
VBox.log
VBox.log.1
VBox.log.2
VBox.log.3

-

VirtualBox」の「仮想マシン」のディスクイメージを確認:
$ ls -lA '/home/ubn/VirtualBox VMs/EndeavourOS_OpenBox'
:
-rw------- 1 ubn ubn      540672 11月 16 03:07 EndeavourOS_OpenBox.nvram  ←(仮想マシンのBIOS設定)
-rw------- 1 ubn ubn        4219 11月 16 03:07 EndeavourOS_OpenBox.vbox
-rw------- 1 ubn ubn        5067 11月 16 03:07 EndeavourOS_OpenBox.vbox-prev
-rw------- 1 ubn ubn 19115540480 11月 16 03:07 EndeavourOS_OpenBox.vdi  ←(VirtualBoxの仮想ハードディスク形式)
drwx------ 2 ubn ubn        4096 11月 16 03:02 Logs

-

Vagrant」の「仮想マシン」のディスクイメージを確認:
$ ls -lA '/home/ubn/VirtualBox VMs/ubn2204_default_1700301456943_75635'
:
drwx------ 2 ubn ubn        4096 11月 19 09:58 Logs
-rw------- 1 ubn ubn 16523853824 11月 19 10:43 packer-virtualbox-iso-1670500096-disk001.vmdk  ←(VMwareの仮想ハードディスク形式)
-rw------- 1 ubn ubn        5384 11月 19 10:43 ubn2204_default_1700301456943_75635.vbox
-rw------- 1 ubn ubn        6249 11月 19 10:01 ubn2204_default_1700301456943_75635.vbox-prev

-


8). ホストOS を再起動:

$ reboot

-

9). 仮想マシンの再立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up

「--provider=virtualbox」のパラメータはデフォルトなので、省略しました。

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'nercceh/ubuntu22.04-desktop' version '4.0.3' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...   ←(チェックで下記を指摘。後で対応)
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 6.1.38
    default: VirtualBox Version: 7.0
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
$ 

Ubuntu のデスクトップ画面が表示されました:

→デスクトップが表示されてもゲスト側の「黒いマウス」が動かないので、デスクトップの操作が出来ません。

-

10). 仮想マシンの停止(シャットダウン、電源オフ):

$ vagrant halt
==> default: Attempting graceful shutdown of VM...
$

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

5. 参考: Vagrantfile を修正して、仮想マシンのメモリを「4096 MB」に増やしました:

-

デスクトップの問題とは関係ないけど、

デスクトップ環境を使うのに、メモリが 2048 MB では少ないので修正:
(PC のメモリに余裕がある場合の修正です)

-

1). 「Vagrantfile」ファイルを修正:

テキストエディタは何でも良いです:

$ cd ~/ダウンロード/vm/ubn2204/
$ featherpad Vagrantfile

-

メモリを「4096 MB」に増やしました:

57 行目以降を修正:

  # Example for VirtualBox:
  #
    config.vm.provider "virtualbox" do |vb|            ←(コメント解除)
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
      vb.memory = "4096"              ←(追記)
    end                    ←(コメント解除)
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

Ctrl+S で保存:

-

2). 「Vagrantfile」を反映させて、仮想マシンを立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant reload

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -

6. Vagrant の「仮想マシン」に SSH で接続して、ログイン:

-

まずは、確認できる項目を確認しました:

デスクトップが表示されなかったり、表示されても操作できなかったりしても、
仮想マシン」に接続できれば、コマンドで操作ができます。

-

SSH の情報(「vagrant up」時のメッセージ中に表示されます):

  • ユーザ名: vagrant

  • パスワード: vagrant

  • ポート番号: 2222

→「Box」をWeb サイトで公開する場合に、システムイメージに追加しておく推奨の設定みたい。

-

1). 「仮想マシン」に SSH で接続:

ホストが、Linux の場合:

ホストの「端末」画面にて、

$ ssh -p 2222 vagrant@localhost

-

vagrant ssh」というコマンドも使えます。

-

最初のログイン時にのみ表示:
The authenticity of host '[localhost]:2222 ([127.0.0.1]:2222)' can't be established.
ED25519 key fingerprint is SHA256:seET.......yek.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? 

和訳:

ホスト '[localhost]:2222 ([127.0.0.1]:2222)' の信頼性を確立できません。
ED25519 キーのフィンガープリントは SHA256:seET......yek です。
このキーは他の名前では知られていません
接続を続けてもよろしいですか (yes/no/[fingerprint])? 

→「yes」Enter

-

最初、および 2度目以降のログイン時の表示:
vagrant@localhost's password:

→パスワードは「vagrant」を入力

-

ホストの「端末」画面に表示:

Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-56-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sat 18 Nov 12:25:13 UTC 2023

  System load:  0.4072265625       Processes:             206
  Usage of /:   22.9% of 38.15GB   Users logged in:       1
  Memory usage: 20%                IPv4 address for eth0: xx.xx.xx.xx
  Swap usage:   0%

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

466 updates can be applied immediately.
288 of these updates are standard security updates.
To see these additional updates run: apt list --upgradable

        ,u@@E@@E@@>,         
    .;EBBBBBBBBBBBBBBE@       
   p@BB@5EBBBBBBBBBBBBBB@     Packer.io built VM maintained by the Application
 ,EBBBBBB@@BBBBBBBBBBBBBBBL   Development Team, Centre for Ecology & Hydrology
 @B██████BB██████BB██BB██BB, 
EBB██BBBBBB██@BBBBB██BB██BBE 
EBB██BBBBBB████BBBB██████BBB 
(BB██BBBBBB██BB@BBB██BB██BBE  Version:    Ubuntu 22.04.1 LTS
 EB██████BB██████@B██BB██BB   Built:      2022-12-08
  EBBBBBBBBBBBBBB@@BBBBBBE"   Management: puppet
   "EBBBBBBBBBBBBBB@@B@@P     Repository: https://github.com/NERC-CEH/ubuntu
     "tEBBBBBBBBBBBBBb"      
         "*CehP*"^"          
Last login: Sat Nov 18 10:12:44 2023 from xx.xx.xx.xx
vagrant@vagrant:~$ 

→ログインすると、プロンプトの表示が変わります:

ユーザ名@マシン名

接続した「仮想マシン」にて、 OS 名、および、「システム更新がある」ことが表示されています。

-

2). システムの情報を確認:

$ uname -a
Linux vagrant 5.15.0-56-generic #62-Ubuntu SMP Tue Nov 22 19:54:14 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

$ uname -r
5.15.0-56-generic

$ uname -n
vagrant

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

→システムは初期の頃の「Ubuntu 22.04.1 LTS」です。

こちらの「Box」は、その頃に公開されたということです。

-

3). システム更新:

$ sudo apt update
:
Hit:1 http://apt.puppetlabs.com jammy InRelease
Hit:2 http://gb.archive.ubuntu.com/ubuntu jammy InRelease 
Get:3 http://gb.archive.ubuntu.com/ubuntu jammy-updates InRelease [119 kB]
Hit:4 http://gb.archive.ubuntu.com/ubuntu jammy-backports InRelease
Get:5 http://gb.archive.ubuntu.com/ubuntu jammy-security InRelease [110 kB]
Fetched 229 kB in 4s (57.2 kB/s)  
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
460 packages can be upgraded. Run 'apt list --upgradable' to see them.

→更新がたくさんあります。

-

更新内容の確認:
$ apt list --upgradable

→たくさん表示

-

更新を実行:
$ sudo apt upgrade

(毎回、なぜか、)ピンク色の画面が表示:

-

Package configuration

 ┌──────────┤ Pending kernel upgrade ├───────────────┐
 │  
 │ Newer kernel available   
 │     
 │ The currently running kernel version is 5.15.0-56-generic which is 
 │ not the expected kernel version 5.15.0-88-generic.     
 │    
 │ Restarting the system to load the new kernel will not be handled 
 │ automatically, so you should consider rebooting.    
 │  
 │                                <Ok>  

和訳:

パッケージ構成

 ┌──────────┤ カーネルのアップグレードが保留中です ├───────────┐
 │  
 │ 新しいカーネルが利用可能   
 │     
 │ 現在実行中のカーネル バージョンは 5.15.0-56-generic ですが、
 │ これは予期されたカーネル バージョン 5.15.0-88-generic ではありません。
 │ 
 │ 新しいカーネルをロードするためのシステムの再起動は自動的に処理
 │ されないため、再起動を検討する必要があります。
 │  
 │                                <Ok>  

<Ok> が選択されているので、Enter

-

次の画面が表示:
Package configuration

┌─────────┤ Daemons using outdated libraries ├──────────┐
│
│ Which services should be restarted? 
│ 
│    [*] acpid.service
│    [*] colord.service 
│    [*] cron.service
│    [ ] dbus.service
│    [ ] gdm.service
│    [ ] gdm3                          ↓(スクロールバー)
│ 
│          <Ok>              <Cancel>     

和訳:

パッケージ構成

┌─────────┤ 古いライブラリを使用するデーモン ├───────────┐
│
│ どのサービスを再起動する必要がありますか? 
│ 
│    [*] acpid.service
│    [*] colord.service
│    [*] cron.service
│    [ ] dbus.service
│    [ ] gdm.service
│    [ ] gdm3                          ↓(スクロールバー)
│ 
│          <Ok>              <Cancel>     

→Tab キーで、<Ok> を選択して、Enter

-

更新が終了しました:

vagrant@vagrant:~$ 

-

4). 作業が完了したので、SSH 接続を終了(切断):

$ exit

もしくは、

$ logout

もしくは、

Ctrl+D
logout
Connection to localhost closed.

ubn@ubn-box:~/ダウンロード/vm/ubn2204$ 

→ホストのプロンプトに戻りました

-

5). 「仮想マシン」の状態を確認:

$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

和訳:

「仮想マシン」が実行中です。この「仮想マシン」を停止するには、
「vagrant halt」を実行して強制的にシャットダウンするか、または、
「vagrant suspend」を実行して単に仮想マシンを一時停止することができます。
どちらの場合も、再起動は、「vagrant up」を実行するだけです。

-

ちなみに、「default」は「仮想マシン名」です。

-

6). 「仮想マシン」の停止(シャットダウン):

$ vagrant halt
==> default: Attempting graceful shutdown of VM...

和訳:

default: VM の正常なシャットダウンを試みています...

-

→「VirtualBox」の仮想マシン「default」のウィンドウが閉じました。

-

Vagrant」の操作では、「VirtualBox」マネージャ画面は起動されません。(必要とされていません)

Vagrant」によって、現在の「作業フォルダ」に置かれた「Vagrantfile」で作成された「仮想マシン」の画面だけが起動されます。

-

7). 「仮想マシン」の立ち上げ:

$ vagrant up
:
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 6.1.38
    default: VirtualBox Version: 7.0
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/ubn2204$ 

-

後半部分の和訳:

==> default: 共有フォルダのマウント...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204
==> default: マシンはすでにプロビジョニングされています。
     「vagrant provision」を実行するか、「--provision」を使用します。
==> default: プロビジョニングを強制するフラグ。
       常に実行するようにマークされたプロビジョニングは引き続き実行されます。

→起動された「仮想マシン」の画面は真っ暗です。(「項番 8-2.」で対応: )

-

デスクトップ画面がうまく表示される場合と、されない場合があるみたい。

また、デスクトップ画面が表示されたとしても、
Ubuntu の左側にあるドックが表示されなかったり、マウス操作ができなかったりです。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- --

7. 問題点1: 「仮想マシン」の立ち上げ時に「Guest Additions」のバージョンが合わないとの警告が表示:

-

「Guest Additions」のバージョンは、「Box」(ゲストOS: つまり仮想マシン )のイメージを作成した環境によると思われます:

-


仮想マシン」を立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...   ←(プロバイダは VirtualBox)
==> default: Checking if box 'nercceh/ubuntu22.04-desktop' version '4.0.3' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...   ←(★バージョン チェックで問題がある部分)
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 6.1.38   ←(現在のバージョン)
    default: VirtualBox Version: 7.0           ←(現在のバージョン)
==> default: Mounting shared folders...   ←(●「共有フォルダ」機能が有効です)
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/ubn2204$     ←(プロンプトに戻りました)

★バージョン チェックの部分を和訳:

仮想マシン での guest additions の追加を確認しています...

この VM に追加された guest additions は、
インストールされている VirtualBox のバージョンと一致しません。
ほとんどの場合、問題ありませんが、
まれに、共有フォルダなどが正常に動作しなくなることがあります。

共有フォルダのエラーが表示された場合は、仮想マシン内の guest additions の追加が
ホストにインストールされている VirtualBox のバージョンと一致していることを確認し、
仮想マシン をリロードしてください。

    Guest Additions Version: 6.1.38     ←(仮想マシン側: 低いまま)
    VirtualBox Version: 7.0             ←(ホストOS 側: 最新)

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

追記:

●バージョンは一致してませんが、今回は「共有フォルダ」機能が有効です:

「作業フォルダ」が「仮想マシン」に共有フォルダ「/vagrant」としてマウントされました:

==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204

-

VirtualBox マネージャを起動して確認:

→画面下の「共有フォルダー」に、「共有フォルダ」の設定が 1つ登録されています:

-

「共有フォルダー」をクリックして、設定を確認:

→「共有フォルダー」が自動で登録されました:

というより、「共有フォルダー」が登録されているイメージを「Box」として登録している(するべき?な)のかも。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ---

7-2. 回避策:「仮想マシン」の「Guest Additions」をアップグレードしました:

-

項番 7. 」にて、

仮想マシン」の立ち上げ時に「Guest Additions」のバージョンが合わないとの警告が表示:

その回避策です:

-

1). 「仮想マシン」を立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up

-

2). 「Guest Additions …」をアップグレード:

仮想マシン」の画面の上部のメニューバー →「Devices」→(一番下の)「Upgrade Guest Additions …」

仮想マシンのウィンドウの右側のエリアに「Installing image ...」が表示

バーグラフは「77%」の表示が続きます →だいぶ待つと、通知エリアが消えました。

-


3). 「仮想マシン」の再起動:

仮想マシン」の停止:

$ vagrant halt
:
==> default: Attempting graceful shutdown of VM...

-

仮想マシン」の立ち上げ:

$ vagrant up
:
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'nercceh/ubuntu22.04-desktop' version '4.0.3' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...      ←(★チェック時の警告が消えました)
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/ubn2204$ 

→バージョン違いの警告が表示されなくなりました。

ただし、起動された「仮想マシン」の画面は、「真っ暗」のままです。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----

8. 問題点2: 立ち上げた「仮想マシン」のデスクトップ画面が時々「真っ暗」で、表示されてもマウス操作できず:

-


1). 仮想マシンを再起動してみる:

仮想マシン」を停止:

$ vagrant halt
:
==> default: Attempting graceful shutdown of VM...

-

仮想マシン」を立ち上げ:

$ vagrant up

→起動された「仮想マシン」の画面は真っ暗です。

-


2). ホストOS を再起動してみる:

仮想マシン」を停止:

$ vagrant halt

-

ホストOS を再起動:

$ reboot

-


3). 「仮想マシン」を立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'nercceh/ubuntu22.04-desktop' version '4.0.3' is up to date...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
    default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/ubn2204$ 

-


4). 気づいたこと1: デスクトップ画面が真っ暗です:

VirtualBox」のステータスエリアが画面右側に表示されたので、そのままにして、立ち上げ終わってから、

ステータスエリアを閉じたら、そのエリアだけ、デスクトップの背景が表示されました:

うまく表示できるパターンです。

-


5). デスクトップの再描画:

仮想マシンのウィンドウのメニューバーにて、「View」 →「Virtual Screen 1」→「Scale to Resize to 100%」→「Scale to Resize to 125%」→「Scale to Resize to 100%」

→デスクトップ画面が表示されました。画面右のドックパネルも表示されています。

-


6). 気づいたこと2: デスクトップ画面が表示されたとき、ホストOS のマウスを動かしても、「仮想マシン」(ゲストOS)の黒いマウスカーソルが動きません:

仮想マシン」(ゲストOS)を操作するには、ゲストOS の黒いマウスカーソルを動かす必要があります。

-


7). 気づいたこと3: デスクトップ画面が表示されたとき、Ubuntu 画面の左のドックが表示されません:

ホストOS のマウスを動かしても、「仮想マシン」(ゲストOS)の黒いマウスカーソルが動きません:

-

8). 再度、「仮想マシン」を再起動したら、「VirtualBox」のステータスエリアが画面右側に表示されず、画面真っ暗のままになりました:

「Scale to Resize」を変更しても、真っ暗のままで変わりません。

-

9). 「デスクトップ」画面の表示が不安定です:

-

VirtualBox」の「ディスプレイドライバー」が合っていないみたい。

→下記の「項番 8-2.」で対応:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -----

8-2. 回避策: 「VirtualBox マネージャ」にて「ディスプレイ」の設定を変更:

-

項番 8. 」にて、

立ち上げた「仮想マシン」のデスクトップ画面が時々真っ暗で、表示されてもマウス操作できず、などの件の回避策:

-

「VMSVGA」に変更することで解消:

-

1). ホストOS にて、「VirtualBox マネージャ」を起動:

-

2). 「ディスプレイ」の設定を(VirtualBox ではデフォルトの)「VMSVGA」に変更:

ディスプレイ:

ビデオメモリ: 256 MB
グラフィックスコントローラー: VBoxVGA  →「VMSVGA」に変更
アクセラレーション: 3D
リモートディスクトップサーバーポート: 5902
レコーディング: 無効

-

3). 「VirtualBox マネージャ」を右上の「x」で閉じます:

-

4). 「仮想マシン」を起動して確認:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up

→デスクトップ画面が正常に表示されました。

画面の左のドックが表示され、マウスで操作できるようになりました。

-

このやり方だと、「仮想マシン」を再作成すると、設定が消えてしまいます:

-

5). 恒久的な対策として、「Vagrantfile」を修正:

仮想マシン」のディスプレイ設定を「VMSVGA」に変更:
vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]

-

編集:
$ cd ~/ダウンロード/vm/ubn2204/
$ featherpad Vagrantfile

↓ すべて置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "nercceh/ubuntu22.04-desktop"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

-

6). 「仮想マシン」を再作成して、起動:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant reload

→デスクトップ画面が正常に表示されました。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -

9. 参考: Vagrant にて、お気に入りの「Box」を元に、新しい「Box」を作成して「共有」:

-

Vagrant」で管理されている、現在の「仮想マシン」の環境(「作業フォルダ」と該当の「仮想マシン」)から、新しい「.box」ファイルを生成できます:

開発メンバーで「同じ環境」を使いたい場合や、ベースを元にカスタマイズした「仮想マシン」を保存したい場合、などに使えます:

-

参考: 「vagrant package」コマンドの使い方:

コマンドの詳細(ヘルプ)は、「こちら 」を参照:

-

コマンドの使い方:

使い方: vagrant package [オプション] [name|id]

オプション:

  --base NAME            ベース ボックスとしてパッケージ化したい
                         VirtualBox 内の VM の名前 (VirtualBox の場合)
  --output NAME          出力するファイルの名前
  --include FILE,FILE..  ボックスにパッケージ化するカンマ区切りの追加ファイル
  --info FILE            追加のボックス情報を含むカスタム info.jsonファイルへのパス
  --vagrantfile FILE     ボックスに同梱する Vagrantfile

→パッケージ化するときに、色々なファイルを同梱できます。

-


1). 作業前の確認:

仮想マシン」を作成後の状態:

$ ls -1A ~/ダウンロード/vm/ubn2204/
:
.vagrant
Vagrantfile
sudo-cat-etc-sudoers.txt

→「sudo-cat-etc-sudoers.txt」は、「共有フォルダ」のテスト時の残がいです。 通常は存在しません。

-


2). 「.box」ファイルの生成:

-

時間がかかるので、時間の余裕があるときに実施:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- --

9-a. 「Vagrantfile」のある「作業フォルダ」に移動して、「vagrant package」コマンドを実行する場合:

-

仮想マシン」名を指定せずに、「.box」ファイルを生成できます。

簡単なのが利点です:

-

仮想マシン」は停止した状態です:

-

1). 生成:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant package
==> default: Clearing any previously set forwarded ports...
==> default: Exporting VM...

和訳:

==> default: 以前に設定された転送ポートをクリア...
==> default: 「仮想マシン」の転送中...

↓ 時間がかかりました:(18分でした)

==> default: Compressing package to: /home/ubn/ダウンロード/vm/ubn2204/package.box

和訳:

==> default: パッケージの圧縮中: /home/ubn/ダウンロード/vm/ubn2204/package.box

↓ 時間がかかりました:(24分でした)

ubn@ubn-box:~/ダウンロード/vm/ubn2204$ 

プロンプトに戻りました。(合計: 42分でした)

-

2). ファイルを確認:

$ ls -1A ~/ダウンロード/vm/ubn2204/
:
.vagrant
Vagrantfile
package.box      ←(追加されました)
sudo-cat-etc-sudoers.txt

-

ファイルサイズを確認:
$ ls -lA ~/ダウンロード/vm/ubn2204/p*
-rw-rw-r-- 1 ubn ubn 7917759690 12月 11 07:46 /home/ubn/ダウンロード/vm/ubn2204/package.box

→「7.9 GB」ほどでした。

-

3). 作成した「package.box」ファイルと、稼働中の「Vagrantfile」を開発メンバーに配布:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ---

9-b. 「仮想マシン」の ID を指定して、「vagrant package」コマンドを実行する場合:

-

「Box」ファイルを生成するフォルダを指定できることと、「作業フォルダ」を汚さないのが利点です:

-

コマンドの使い方:

$ vagrant package --base [対象の「仮想マシン」の名前か、id] --output [ファイル名].box

→「仮想マシン」の名前だと、「Vagrant」では共通の「default」なので、「作業フォルダ」に移動しないと使えません。それなら、「項番 9-a.」の手順が使えます。

なので、「id」で指定します。

-

1). 「仮想マシン」は停止しておきます:

-

2). パッケージ化の対象となる「仮想マシン」の「id」を取得:

$ vagrant global-status
id       name    provider   state    directory                           
-------------------------------------------------------------------------
d4b57c8  default virtualbox poweroff /home/ubn/ダウンロード/vm/test3
5770428  default virtualbox poweroff /home/ubn/ダウンロード/vm/ubn2204 ←(対象)
 
:

→id は「5770428」です

-

3). 「.box」ファイルを生成したい場所を準備:

$ mkdir -p ~/ダウンロード/vm/box-share

-

4). 作成:

$ cd ~/ダウンロード/vm/box-share/
$ vagrant package "5770428" --output package-ubn2204-2023-1211.box
==> default: Exporting VM...
==> default: Compressing package to: /home/ubn/ダウンロード/vm/box-share/package-ubn2204-2023-1211.box

-

5). 確認:

$ ls -lA
:
-rw-rw-r-- 1 ubn ubn 7917759632 12月 11 19:16 package-ubn2204-2023-1211.box

→「7.9 GB」ほどでした。

-

6). 作成した「package.box」ファイルと、稼働中の「Vagrantfile」を開発メンバーに配布:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----

9-2. 参考: 配布された「.box」ファイルを使って、「仮想マシン」を共有するやり方:

-

「~/ダウンロード/vm/box-share/」フォルダに、共有のために配布された「.box」ファイルを保存した場合:

-


1). ファイルの確認:

$ cd ~/ダウンロード/vm/box-share/

$ ls -1A
package-ubn2204-2023-1211.box

-


2). 共有する「Box」をホームフォルダの「Box」の一覧に保存:

→URL を指定しなくて、ローカルにある「Box」のパスの指定でもOK です。

$ cd ~/ダウンロード/vm/box-share/
$ vagrant box add ubn2204-dev package-ubn2204-2023-1211.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'ubn2204-dev' (v0) for provider: 
    box: Unpacking necessary files from: file:///home/ubn/%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89/vm/box-share/package-ubn2204-2023-1211.box
==> box: Successfully added box 'ubn2204-dev' (v0) for ''!

→日本語("ダウンロード")が含まれるパスがあるので、表示が見づらいです。

ファイルがコピーされるので、少し時間がかかります。

-


3). 保存された「Box」の一覧を表示:

-

(1). 「Box」の一覧を表示:
$ vagrant box list
CentOS7-test                (virtualbox, 0)
CentOS7_test3_2             (virtualbox, 0)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)
ubn2204-dev                 (virtualbox, 0)     ←(追加)

-

(2). 保存された「Box」のファイル(フォルダ)を表示:
$ ls -1 ~/.vagrant.d/boxes/
CentOS7-test
CentOS7_test3_2
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop
ubn2204-dev

-

$ cd ~/.vagrant.d/boxes/
$ ls -1 ubn2204-dev/0/virtualbox/
Vagrantfile
box-disk001.vmdk
box.ovf
metadata.json
vagrant_private_key

-

(3). 「Vagrantfile」の内容を確認:
$ cat ubn2204-dev/0/virtualbox/Vagrantfile
Vagrant::Config.run do |config|
  # This Vagrantfile is auto-generated by `vagrant package` to contain
  # the MAC address of the box. Custom configuration should be placed in
  # the actual `Vagrantfile` in this box.
  config.vm.base_mac = "080027E17009"
end

# Load include vagrant file if it exists after the auto-generated
# so it can override any of the settings
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)

Vagrant.configure("2") do |config|
  config.ssh.private_key_path = File.expand_path("../vagrant_private_key", __FILE__)
end

-

コメント部分の和訳:

この Vagrantfile は「vagrant package」によって自動生成され、
ボックスの MAC アドレスが含まれます。
カスタム設定は、このボックス内の実際の `Vagrantfile` に配置する必要があります。
自動生成後にインクルード vagrant ファイルが存在する場合は、
それをロードして設定をオーバーライドできるようにします。

-


4). 「作業フォルダ」の準備:

$ mkdir -p ~/ダウンロード/vm/ubn2204-dev

-


5). 「Vagrantfile」を作成:

-

(1). 「Vagrantfile」の作成:
$ cd ~/ダウンロード/vm/ubn2204-dev/
$ vagrant init -m ubn2204-dev
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

→いつもの表示メッセージ

-

-

(2). ファイルの確認:
$ ls -1A
Vagrantfile

-

(3). 「Vagrantfile」の内容を確認:
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "ubn2204-dev"
end

→初期の内容です。

-


6). 「仮想マシン」の生成と立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204-dev/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubn2204-dev'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: ubn2204-dev_default_1702297021428_72001
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204-dev
ubn@ubn-box:~/ダウンロード/vm/ubn2204-dev$ 
問題: →「仮想マシン」は起動されますが、画面が表示されません。

-

仮想マシン」は起動しています:

$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

-

停止:

$ vagrant halt
==> default: Attempting graceful shutdown of VM...

-

$ vagrant status
Current machine states:

default                   poweroff (virtualbox)

The VM is powered off. To restart the VM, simply run `vagrant up`

-

7). ホストOS を再起動:

$ reboot

-

8). 仮想マシンの立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204-dev/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204-dev
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/ubn2204-dev$ 

→先ほどと違い、最後の 2行が表示されました。

-

でも、画面が起動されません。
仮想マシン」のイメージが「Vagrant」で(完全に)管理しきれていないみたい。

-

$ vagrant halt
==> default: Attempting graceful shutdown of VM...

-

9). 「Vagrantfile」を稼働していたときの内容に修正:

$ cd ~/ダウンロード/vm/ubn2204-dev/
$ featherpad Vagrantfile

↓ すべて置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "ubn2204-dev"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

Ctrl+S で保存

-

10). 「vagrant reload」を実行:

$ cd ~/ダウンロード/vm/ubn2204-dev/
$ vagrant reload
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204-dev
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/ubn2204-dev$ 

仮想マシン」が起動され、仮想マシンの画面が表示されました。

-

VirtualBox」マネージャで確認したときには、稼働中の設定と同じ値(メモリ "4096"、"vmsvga")だったので、

「Vagrantfile」の内容と、「仮想マシン」のイメージに違いがあると、完全に「Vagrant」で管理できないようです。

どちらにしても、「Vagrantfile」は同じ内容にした方が良いです。

-

「共有フォルダ」を有効にするため、ホストOS を再起動する必要はあるので、

手順を見直すとしたら、「項番 6).」(up) の前に「項番 9).」(編集)を行うことかな。

-


参考: 「Vagrantfile」の管理について:

-

「Vagrantfile」の内容は(稼働していた元の環境から)引き継がれない」ようです:

-

「Box」ファイルを作成する(パッケージ化する)ときに、「Vagrantfile」ファイルを同梱しても良いですが、 手順が複雑になるよりも、できるだけシンプルな手順の方が楽です。

-

配布するときは、稼働中の「Vagrantfile」と「.box」ファイルを「一緒に渡す」と良いです:

例えば、「Dropbox」等に、稼働中の「Vagrantfile」と共有する「.box」ファイルを一緒にUP しておけば安心です。

-


11). 次の「項番 9-3.」で手順を見直すので、今までのファイルをクリア:

-

(1). (VirtualBox の)「仮想マシン」の確認:
$ vagrant global-status
id       name    provider   state    directory                           
-------------------------------------------------------------------------
d4b57c8  default virtualbox poweroff /home/ubn/ダウンロード/vm/test3           
5770428  default virtualbox poweroff /home/ubn/ダウンロード/vm/ubn2204         
e64c6ad  default virtualbox poweroff /home/ubn/ダウンロード/vm/ubn2204-dev ←(こちら)
 :

-

(2). (VirtualBox の)「仮想マシン」の削除:
$ cd ~/ダウンロード/vm/ubn2204-dev/
$ vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] y
==> default: Destroying VM and associated drives...

-

(3). 「Box」名を確認:
$ vagrant box list
CentOS7-test                (virtualbox, 0)
CentOS7_test3_2             (virtualbox, 0)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)
ubn2204-dev                 (virtualbox, 0)  ←(こちら)

-

(4). 「Box」ファイルを一覧から削除:
$ vagrant box remove ubn2204-dev

-

(5). 作業フォルダのファイルを削除:
$ cd ~/ダウンロード/vm/ubn2204-dev
$ rm -r .vagrant
$ rm Vagrantfile

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -----

9-3. 参考: 配布された「.box」ファイルを使って、「仮想マシン」を共有するやり方(改訂版):

-

スムーズに共有できるように、手順を見直しました:

-

「~/ダウンロード/vm/box-share/」フォルダに、共有のために配布された「.box」ファイル保存した場合:

-


1). ファイルの確認:

$ cd ~/ダウンロード/vm/box-share/
$ ls -1A
package-ubn2204-2023-1211.box

-


2). 共有する「Box」をホームフォルダの「Box」の一覧に保存:

ローカルにある「Box」のパスを指定:

$ cd ~/ダウンロード/vm/box-share/
$ vagrant box add ubn2204-dev package-ubn2204-2023-1211.box

→ファイルがコピーされるので、少し時間がかかります。

-


3). 保存された「Box」の一覧を表示:

$ vagrant box list
CentOS7-test                (virtualbox, 0)
CentOS7_test3_2             (virtualbox, 0)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)
ubn2204-dev                 (virtualbox, 0)     ←(追加)

-


4). 「作業フォルダ」の準備:

$ mkdir -p ~/ダウンロード/vm/ubn2204-dev

-


5). 「Vagrantfile」を稼働していたときの内容で、新規に作成:

$ cd ~/ダウンロード/vm/ubn2204-dev/
$ featherpad Vagrantfile

↓ すべて貼付け:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "ubn2204-dev"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

Ctrl+S で保存

-

ファイルの確認:
$ ls -1A
Vagrantfile

-


6). 「仮想マシン」の生成と立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204-dev/
$ vagrant up

→「仮想マシン」が起動され、「仮想マシン」の画面が表示されました:

-


7). 「共有フォルダ」を有効にするため、ホストOS を再起動

-

(1). 「仮想マシン」の停止:
$ vagrant halt

-

(2). ホストOS を再起動:
$ reboot

-

(3). 「仮想マシン」の立ち上げ:
$ cd ~/ダウンロード/vm/ubn2204-dev/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection reset. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
    default: /vagrant => /home/ubn/ダウンロード/vm/ubn2204-dev
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
ubn@ubn-box:~/ダウンロード/vm/ubn2204-dev$ 

→「仮想マシン」が起動され、「仮想マシン」の画面が表示されました。

-

-


まとめ

今回は「Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて、「Vagrant」を使えるようにしてから、
Vagrant」で実際に Ubuntu 22.04(デスクトップ) の「仮想マシン」を作成してみました。

また、「Box」の共有も試しました。

-

実際に行って確認した項目は、その都度、(覚書き編)〈H170〉の投稿に反映させています。 なので、だいぶ使える資料になってきていると思います。

色々と試してみて、個人的には、手間ひまかけてカスタマイズした「仮想マシン」を保存する手段として、 「Vagrant」は使うつもりです。
次回の(実践編2) 〈H170-3〉では、その辺りにトライしました。

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-

「VirtualBox 7.0」の仮想マシンを「Vagrant」で管理(覚書き編)〈H170〉

登録日: 2023-12-01 更新日: 2024-03-14

Xubuntu 22.04 LTS」および「Windows11」(22H2) の「VirtualBox 7.0」の仮想マシンに、色々なLinux ディストリビューションをインストールして、自分に最適なものはないか試しています。

それらの仮想マシン(ボックス)の管理で手間を減らすツールとして、開発環境では「Vagrant」(ベイグラント) というソフトがよく使われるようです。

-

Vagrant」について学ぶため、色々と作業時に参考にできそうな項目を書き出しました。
確認が不十分だし勘違いもありそうです。

確認が取れたらその都度、追加や訂正のつもりですが、個人的な備忘録なので、
参考にするぐらいにして下さい。

-

次回の「実践編」〈H170-2〉で、「Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて、実際に「Vagrant」をインストールして、確認しています。

-

-

(注)リンクを戻るときはブラウザの左上の「←」をクリック
スマホの場合は、「ホーム」ボタンの横の「<」キーをタップ

-

-


目次

-

参考:

  1. 「Vagrant」コマンドについて:

  2. 「Vagrant」コマンドの使用例:

  3. 「Vagrant」コマンドの使用例:(目次)

  4.  修正版3: 使い回し可能な「Vagrantfile」:

-

今回の作業:

  1.  ホストOS に「VirtualBox」をインストール:

  2. 「Ubuntu」 に、「Vagrant」をインストール:

  3. 「Windows11」 に、「Vagrant」をインストール:

  4. 「rpm」系のLinux に、「Vagrant」をインストール:

  5.  公開された「Box」を検索:

  6. 「vagrant box add」にて、「Box」を追加する場合:

  7. 「Vagrantfile」の作成:

  8. 「Vagrantfile」から「仮想マシン」を作成、立ち上げて、操作:

-

「まとめ へ」

「目次詳細 へ」

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -

Xubuntu 22.04 LTS」を起動:

-

VirtualBox 7.0.10」の仮想マシンUbuntu 22.04」(デスクトップ付)を「Vagrant」で起動:

→ホストの「Xubuntu 22.04 LTS」の端末で「vagrant up」と入力するだけで起動しています。

VirtualBox」のゲスト画面なのに、「VirtualBox マネージャ」は起動していません。仕組みが見える気がします。

-

多くの「Box」はデスクトップ表示なしで「ssh 接続」できれば良いだけなので、簡単に使えると思います。 こちらの「Box」の場合はデスクトップ表示が必要なので、ちゃんと表示させるまでに手間がかかりました。

もしかしたら、「VirtualBox 7.0」でなく「VirtualBox 6.1」などの最新ではない?環境だったら、すんなりと表示されたかも。イメージを作成した環境によりそう。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - --

VirtualBox」について:

-

VirtualBox」は、Oracle が開発している「仮想マシン」を構築するためのソフトウェアです。

-

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ---

Vagrant」 (ベイグラント) について:

-

公式サイト:

Vagrant by HashiCorp

-

仮想マシン」の管理や操作をコマンドで使うための「フロントエンド」のソフトウェアです:

-


1). 特徴:

-

  • 「Box」ファイル (.box)、および、設定を記述した設定ファイル「Vagrantfile」を元に、「仮想マシン」の生成から設定までを自動化できます:

  • 作った「仮想環境」は、何度も繰り返し利用できます:

  • 同じ「仮想環境」を複数のサーバーに物理的に展開できます:

  • 同じ「仮想環境」をファオルダ分けにより、目的別に使用できます:

  • 仮想環境の起動や停止などの基本操作、状態のロールバックなどの操作は「プラグイン」で実現されます:

-


2). 「仮想環境」を管理するツール、「Vagrant」と「Docker」を比較:

どちらも「仮想環境」を管理する技術ですが、対象が異なります。

目的によって、使い分けるのが良さそう。

-

(1). 「Docker」は、「コンテナ」を管理:

「Docker」は、Docker 社が提供する Linux の「コンテナ」技術(プロセスの実行空間を隔離する為の技術)を利用したもの。

ソフトウェアの高速配布やソフトウェアの実行が容易で、
シンプルなイメージのカスタマイズや導入が簡単にできます。

-

  • 「コンテナ」についての説明は「こちら 」を参照:

  • 「Docker」を試したいときは「〈H157-7〉 」を参照:

 →仮想環境のソフト(プロバイダ)は「Boxes」ですが、「VirtualBox」の仮想環境と同じです。

-

(2). 「Vagrant」は、「仮想マシン」を管理:

Vagrant」は、「仮想マシン」をコマンドで操作するので、GUI 操作や管理の手間を減らせます。 また、同じ仮想環境を複数のサーバーに物理的に展開できます。

-


3). 用語の説明:

参考:

今更だけどVagrantを公式チュートリアルで入門! (翻訳+解説付き)

-

(1). 「Vagrant cloud」:

公式な「Box」ファイルの公開サイトです。

-

vagrant box add」のコマンドで、Vagrant clooud からダウンロードする場合は、URL の指定が要りません。 逆に、好みの「Box」名を付けるとき、「Vagrantfile」ファイルの修正が必要です。

コミュニティからダウンロードする場合は、URL の指定が必要ですが、 コマンドのパラメータで指定するだけで、好みの「Box」名に簡単にできます。

-

(2). 「プロバイダ」(Provider) :

仮想環境を提供するソフトウェアのことで、この仮想環境上に「仮想マシン」を作成して、操作します。

デフォルトは「VirtualBox」です。追加したいブロバイダはプラグインで対応できます。

-

(3). 「プロビジョニング」(Provisioning) :

仮想マシン」に、「Webサーバー」(Apache、Nginx)、「プログラミング言語」(PHPPythonRuby)、DBMS(Posgre、MySQL) 、などのソフトウェアを組み込む(インストールして設定する)ことです。

-

(4). 「Box」ファイル:

仮想マシン」を作成するときのベース(ひな型、テンプレート)となるイメージファイルです。
vagrant box add」、または初回の「vagrant up」によって、「ホームの隠しフォルダ」にダウンロードされます。

-

(5). 「Vagrantfile」ファイル:

Vagrant を使って生成する「仮想マシン」の設定(仮想マシンのスペックやプロビジョニングツールの指定など)を記述するファイルです。

vagrant init」の実行で、現在の「作業ディレクトリ」に生成されるので、ベースになる「Box」は同じでも、プロジェクトごとに「フォルダ分け」できます。

-

(6). 「Vagrant」コマンド:

簡単にVagrant で「仮想マシン」を操作するために、「端末エミュレータ」画面上で使うコマンドのことです。

-

Vagrant」コマンドについては、「項番 10. 」を参照:

Vagrant」コマンドの使用例は、「項番 11. 」を参照:

Vagrant」コマンドの使用例の「目次」は、「項番 12. 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----

1. ホストOS に「VirtualBox」をインストール:

-

Vagrant」の動作の土台となる「プロバイダ」のひとつで、「Vagrant」ではデフォルトです。

-

1). 「VirtualBox」のインストール:

-

2). 「VirtualBox Extension」のインストール:

-

ちなみに、「Guest Additions」は、各「仮想マシン」(Box)の作成後に、「仮想マシン」側にインストール(インストールしてあれば、アップデート)します。ただし、「共有フォルダ」の機能以外?は、デスクトップ環境がないと無駄になります。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - -----

1-a. 「Xubuntu 22.04 LTS」にて、「VirtualBox」をインストール:

-

「Xubuntu 22.04 LTS」で、「VirtualBox 7.0.10」へアップデート〈H169〉 」を参照:

→「VirtualBox」の「アップデート」手順ですが、バージョンが違うだけで、新規の場合と手順は同じです:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -

1-b. 「Windows11」にて、「VirtualBox」をインストール:

-

「Windows11」(22H2) で、「VirtualBox 7.0.10」へアップデート〈H169-2〉 」を参照:

→「VirtualBox」の「アップデート」手順ですが、バージョンが違うだけで、新規の場合と手順は同じです:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- --

2. ホストOS に「Vagrant」をインストール:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ---

2-a. 「Ubuntu」にて、「Vagrant」をapt でインストールする場合:

-

Xubuntu 22.04.3 LTS」で確認:

-

2023-12-01 現在

Vagrant」Version: 2.2.19

-

追記:

apt で「VirtualBox」をインストールしている場合に、apt で「vagrant」をインストールできます。
→「VirtualBox 7.0」で使うには、最新の「Vagrant」を(リポジトリを登録するか、ダウンロードして)インストールする必要があります:
→「VirtualBox 7.0」がインストールされている場合、apt で「Vagrant」をインストールしても、現時点のバージョン (2.2.19) では「VirtualBox 7.0」はサポートされていません。「仮想マシン」の作成で失敗します。

-

-


1). apt でインストールされるバージョンを確認:

$ apt search vagrant
:
vagrant/jammy,jammy 2.2.19+dfsg-1ubuntu1 all
  Tool for building and distributing virtualized development environments

和訳:

仮想化開発環境を構築および配布するためのツール

-

2). apt で「VirtualBox」をインストールしている場合に、apt でインストールできます:

$ sudo apt update
$ sudo apt install vagrant

-

3). Vagrant がインストールされたか確認:

$ vagrant --version

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----

2-b. 「Ubuntu」にて、最新の「Vagrant」をダウンロードしてインストールする場合:

-

Xubuntu 22.04.3 LTS」で確認:

-

2023-12-01 現在

Vagrant」Version: 2.4.0 (最新バージョン)

-

公式サイトのページからは「Fedora」系の「rpm」パッケージしかダウンロードできないようです。
なので、直接、ダウンロードのページにアクセスしました:

-

-


1). 「Ubuntu/Debian」の場合のダウンロード:

直接、ダウンロードページ にアクセス:

vagrant_2.4.0_SHA256SUMS
vagrant_2.4.0_SHA256SUMS.72D7468F.sig
vagrant_2.4.0_SHA256SUMS.sig
vagrant-2.4.0-1-x86_64.pkg.tar.zst
vagrant-2.4.0-1.i686.rpm
vagrant-2.4.0-1.x86_64.rpm
vagrant_2.4.0-1_amd64.deb   ←(こちらをクリック)
vagrant_2.4.0-1_i686.deb
vagrant_2.4.0_darwin_amd64.dmg
vagrant_2.4.0_darwin_arm64.dmg
vagrant_2.4.0_linux_amd64.zip
vagrant_2.4.0_windows_amd64.msi
vagrant_2.4.0_windows_i686.msi

更新があって、バージョンが上がったら、フォルダ名を変更してアクセスすれば OK

-

2). Vagrant 2.4.0 の SHA256 チェックサムをダウンロードして確認:

SHA256 checksums for Vagrant 2.4.0

内容:

e04916750205819c90e38acf639ab12af89fd4593dcc6ef38c33c306666f73c5  vagrant_2.4.0-1_amd64.deb
87be2e0db61fd2c7ab60fbd3814a67e3ccdd0f7b04f59adfaf54ec181b8e0ac5  vagrant_2.4.0-1_i686.deb
0061505c8aae8a83df525374403af021270d331253a82ff93909930c8a2c4ee7  vagrant-2.4.0-1.i686.rpm
5770768234da6546f71602c4c4e97f2f120231a45b1b83eadd6c5c2727a48a02  vagrant-2.4.0-1-x86_64.pkg.tar.zst
37255ab7b903695863d3a6ee77cb9c660f34f14839a133d50f3a8672bffe4807  vagrant-2.4.0-1.x86_64.rpm
97806047dfc7e0c3818f946a1c954ab03d8f6d1ae45d1aa43e5bdbd7a8856631  vagrant_2.4.0_darwin_amd64.dmg
97806047dfc7e0c3818f946a1c954ab03d8f6d1ae45d1aa43e5bdbd7a8856631  vagrant_2.4.0_darwin_arm64.dmg
a638c22f9dd35481a4486bdb0eca614ad695036aa444cc3aace4513d3de0cbbe  vagrant_2.4.0_linux_amd64.zip
d8f62fce5de0f4b9fb1a4afece10faa6fafed41929ccfe7bb380f160358043e4  vagrant_2.4.0_windows_amd64.msi
6c63fab066223e55f52e3eb58dd41876e877926e152f61aafb60bb2651c88c68  vagrant_2.4.0_windows_i686.msi

-

3). ダウンロード後に、チェックサムが同じか確認:

$ cd ~/ダウンロード/
$ sha256sum vagrant_2.4.0-1_amd64.deb
e04916750205819c90e38acf639ab12af89fd4593dcc6ef38c33c306666f73c5  vagrant_2.4.0-1_amd64.deb

-

4). 「.deb」ファイルのインストール:

$ cd ~/ダウンロード/
$ sudo apt install ./vagrant_2.4.0-1_amd64.deb

-

5). Vagrant がインストールされたか確認:

$ vagrant --version

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- -----

2-c. 「Ubuntu」にて、リポジトリを登録して、最新の「Vagrant」をインストールする場合:

-

Ubuntu の場合です:

-

2023-12-01 現在

Vagrant」Version: 2.4.0 (最新バージョン)

-

参考: パッケージ管理が「rpm」系の場合のリポジトリを登録してのインストールは、「項番 3-c. 」を参照:

-

  • すぐに、下記の「項番 5).」にあるコマンドを、1行ずつ端末に貼り付けて実行しても良いです:

-

-


1). 公式サイトをブラウザで開きます:

Vagrant by HashiCorp

-

-

2). 画面右上の「Download」をクリック:

もしくは、下記の画面の「Download」をクリック:

Community

Self-managed | always free
Download

-

3). 「Install Vagrant」画面が表示:

Linux」の項目を確認します:

-

4). 「Package manager」にて、

→「Ubuntu/Debian」を選択

-

5). 「コピー」ボタンをクリックして、クリップボードにコピー:

テキストエディタに貼り付け

-

Ubuntu/Debian」を選択した場合:
wget -O- https://apt.releases.hashicorp.com/gpg | sudo gpg --dearmor -o /usr/share/keyrings/hashicorp-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] https://apt.releases.hashicorp.com $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/hashicorp.list
sudo apt update && sudo apt install vagrant

-

6). 端末で、各行を実行:

-

7). Vagrant がインストールされたか確認:

$ vagrant --version

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- -----

2-d. 参考: 「Windows11」にて、「Vagrant」をインストールする場合:

-

「Windows11」(22H2) で確認:

-

2023-12-04 現在

Vagrant」Version: 2.4.0 (最新バージョン)

-

こちらは、Windows の「msi」パッケージをダウンロードして、インストールする場合です:

-

-


1). 公式サイトをブラウザで開きます:

Vagrant by HashiCorp

-

-

2). 画面右上の「Download」をクリック:

もしくは、下記の画面の「Download」をクリック:

Community

Self-managed | always free
Download

-

3). 「Install Vagrant」画面が表示:

Windows」の項目を確認します:

-

4). 「Binary download」にて、

→「AMD64」にある、「Download 」をクリック:

-

PC で使われている「CPU 」のタイプを選びます。

-

5). Vagrant 2.4.0 の SHA256 チェックサムをダウンロードして確認:

「Note」にある下記のリンクをクリック:

SHA256 checksums for Vagrant 2.4.0

内容:

e04916750205819c90e38acf639ab12af89fd4593dcc6ef38c33c306666f73c5  vagrant_2.4.0-1_amd64.deb
87be2e0db61fd2c7ab60fbd3814a67e3ccdd0f7b04f59adfaf54ec181b8e0ac5  vagrant_2.4.0-1_i686.deb
0061505c8aae8a83df525374403af021270d331253a82ff93909930c8a2c4ee7  vagrant-2.4.0-1.i686.rpm
5770768234da6546f71602c4c4e97f2f120231a45b1b83eadd6c5c2727a48a02  vagrant-2.4.0-1-x86_64.pkg.tar.zst
37255ab7b903695863d3a6ee77cb9c660f34f14839a133d50f3a8672bffe4807  vagrant-2.4.0-1.x86_64.rpm
97806047dfc7e0c3818f946a1c954ab03d8f6d1ae45d1aa43e5bdbd7a8856631  vagrant_2.4.0_darwin_amd64.dmg
97806047dfc7e0c3818f946a1c954ab03d8f6d1ae45d1aa43e5bdbd7a8856631  vagrant_2.4.0_darwin_arm64.dmg
a638c22f9dd35481a4486bdb0eca614ad695036aa444cc3aace4513d3de0cbbe  vagrant_2.4.0_linux_amd64.zip
d8f62fce5de0f4b9fb1a4afece10faa6fafed41929ccfe7bb380f160358043e4  vagrant_2.4.0_windows_amd64.msi
6c63fab066223e55f52e3eb58dd41876e877926e152f61aafb60bb2651c88c68  vagrant_2.4.0_windows_i686.msi

-

6). 「Windows11」で、「PowerShell」を起動:

Windows ボタン →「po」(ピー・オー)で絞り込み →「Windows PowerShell

PS C:\Users\user> 

-

参考:「PowerShell」では、テキストエディタのような「編集」操作ができるので便利です:

表示された「文字列」をダブルクリックするか、マウスや Shift+「矢印キー」で範囲選択して、Ctrl+C

プロンプトで、Ctrl+V で貼り付け

-

7). 作業ディレクトリを「Downloads\」フォルダに移動:

> cd C:\Users\user\Downloads\
PS C:\Users\user\Downloads> 

→「>」はプロンプトで、ここでは「PS C:\Users\user>」を省略して表示してます。入力しません。

「user」はユーザ名なので、各自異なります。

-

8). 「Windows11」で、ファイルを確認:

> ls vagrant*
    ディレクトリ: C:\Users\user\Downloads

Mode             LastWriteTime     Length Name
----             -------------     ------ ----
-a----   2023/12/04 月   22:53        952 vagrant_2.4.0_SHA256SUMS
-a----   2023/12/04 月   22:52  273833984 vagrant_2.4.0_windows_amd64.msi

-

9). 「Windows11」で、「チェックサム」を確認:

ハッシュ値である「Hashプロパティ」の値のみを「小文字」で表示:

> (Get-FileHash -Algorithm SHA256 vagrant_2.4.0_windows_amd64.msi).Hash.toLower()
d8f62fce5de0f4b9fb1a4afece10faa6fafed41929ccfe7bb380f160358043e4

-

ウィンドウの右上の「x」で、閉じます。

-

10). ダウンロードした「.msi」パッケージをインストール:

-

(1). エクスプローラを起動:

-

(2). ダウンロードした、「C:\Users\user\Downloads\」フォルダにある、下記の「ファイル」をダブルクリック:

vagrant_2.4.0_windows_amd64.msi

-

(3). 「Please read the Vagrant License Agreement」(ライセンス契約をお読みください)画面が表示:

下にある「I accept the terms in the License Agreement」(同意します)にチェックして、

→右下の「Install」

-

(4). (実行を許可しますか?)

→「はい」

-

(5). 「Completed the Vagrant Setup Wizard」画面が表示:

→「Finish」

-

(6). 「Vagrant Setup」画面が表示:

(再起動が必要なので、再起動しますか?)

→「no」

-

(7). 手動で再起動:

-

11). 「PowerShell」を起動:

-

12). Vagrant がインストールされたか確認:

> vagrant --version
Vagrant 2.4.0

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -

3. 参考: 「rpm」系のLinux にて、「Vagrant」をインストールする場合:

-

rpm」系のLinux とは、「Fedora」、「CentOS」、「RHEL」、「Amazon Linux」等のことです:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- --

3-a. 参考: 「rpm」系のLinux にて、「Vagrant」をdnf でインストールする場合:

-

dnf コマンドを使えるのは、「Fedora 35」以降に該当する(新しめの)Fedora 系のOS の場合です。

先進の「Fedora」よりも世代を遅らせて、安定志向にしたのが「CentOS」や「RHEL」(Red Hat Enterprise Linux) です。 新しめの「RHEL 9.0」などでないとdnf コマンドは使えません。

-

2023-12-01 現在

Vagrant」Version: ( 未確認 )

-

参考:

Server World: Fedora 39、Vagrant : インストール

-

-


1). dnf でインストール:

$ sudo dnf update
$ sudo dnf install vagrant

-

2). Vagrant がインストールされたか確認:

$ vagrant --version

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ---

3-b. 参考: 「rpm」系のLinux にて、最新の「Vagrant」をダウンロードして、インストールする場合:

-

2023-12-01 現在

Vagrant」Version: 2.4.0 (最新バージョン)

-

こちらは、「rpm」パッケージをダウンロードして、インストールする場合です:

-

-


1). 公式サイトをブラウザで開きます:

Vagrant by HashiCorp

-

-

2). 画面右上の「Download」をクリック:

もしくは、下記の画面の「Download」をクリック:

Community

Self-managed | always free
Download

-

3). 「Install Vagrant」画面が表示:

Linux」の項目を確認します:

-

4). 「Binary download」にて、

→「X86_64」にある、「Download 」をクリック:

-

PC で使われている「CPU 」のタイプを選びます。

5). Vagrant 2.4.0 の SHA256 チェックサムをダウンロードして確認:

「Note」にある下記のリンクをクリック:

SHA256 checksums for Vagrant 2.4.0

内容:

e04916750205819c90e38acf639ab12af89fd4593dcc6ef38c33c306666f73c5  vagrant_2.4.0-1_amd64.deb
87be2e0db61fd2c7ab60fbd3814a67e3ccdd0f7b04f59adfaf54ec181b8e0ac5  vagrant_2.4.0-1_i686.deb
0061505c8aae8a83df525374403af021270d331253a82ff93909930c8a2c4ee7  vagrant-2.4.0-1.i686.rpm
5770768234da6546f71602c4c4e97f2f120231a45b1b83eadd6c5c2727a48a02  vagrant-2.4.0-1-x86_64.pkg.tar.zst
37255ab7b903695863d3a6ee77cb9c660f34f14839a133d50f3a8672bffe4807  vagrant-2.4.0-1.x86_64.rpm
97806047dfc7e0c3818f946a1c954ab03d8f6d1ae45d1aa43e5bdbd7a8856631  vagrant_2.4.0_darwin_amd64.dmg
97806047dfc7e0c3818f946a1c954ab03d8f6d1ae45d1aa43e5bdbd7a8856631  vagrant_2.4.0_darwin_arm64.dmg
a638c22f9dd35481a4486bdb0eca614ad695036aa444cc3aace4513d3de0cbbe  vagrant_2.4.0_linux_amd64.zip
d8f62fce5de0f4b9fb1a4afece10faa6fafed41929ccfe7bb380f160358043e4  vagrant_2.4.0_windows_amd64.msi
6c63fab066223e55f52e3eb58dd41876e877926e152f61aafb60bb2651c88c68  vagrant_2.4.0_windows_i686.msi

-

6). チェックサムが同じか確認:

$ cd ~/ダウンロード/

$ sha256sum vagrant-2.4.0-1.x86_64.rpm
37255ab7b903695863d3a6ee77cb9c660f34f14839a133d50f3a8672bffe4807  vagrant-2.4.0-1.x86_64.rpm

-

7). 「.rpm」パッケージのインストール:

$ sudo rpm -ivh ./vagrant-2.4.0-1.x86_64.rpm

-

8). Vagrant がインストールされたか確認:

$ vagrant --version

もしくは、

$ sudo rpm -qa | grep vagrant

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----

3-c. 参考: 「rpm」系のLinux にて、リポジトリを登録して、最新の「Vagrant」をインストールする場合:

-

2023-12-01 現在

Vagrant」Version: 2.4.0 (最新バージョン)

-

参考: 「Ubuntu/Debian」の場合のリポジトリを登録してのインストールは、「項番 2-c. 」を参照:

-

  • 手順を経ずに、下記の「項番 4).」にあるコマンドを、端末に 1行ずつ貼付けて実行しても良いです:

-

-


1). 公式サイトをブラウザで開きます:

Vagrant by HashiCorp

-

-

2). 画面右上の「Download」をクリック:

もしくは、下記の画面の「Download」をクリック:

Community

Self-managed | always free
Download

-

3). 「Install Vagrant」画面が表示:

Linux」の項目を確認します:

-

4). 「Package manager」にて、

→下記の「Linux ディストリビューション」のどれかを選択

-

(1). 「CentOS/RHEL」を選んだ場合:
$ sudo yum install -y yum-utils
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
$ sudo yum -y install vagrant

-

(2). 「Fedora」を選んだ場合:
$ sudo dnf install -y dnf-plugins-core
$ sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
$ sudo dnf -y install vagrant

→「dnf」は「yum」の後継のコマンドです

-

(3). 「Amazon Linux」を選んだ場合:
$ sudo yum install -y yum-utils shadow-utils
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
$ sudo yum -y install vagrant

-

(4). 「Homebrew」を選んだ場合 (MacOS):
$ brew tap hashicorp/tap
$ brew install hashicorp/tap/vagrant

「Homebrew」は、「MacOS」の「パッケージ管理ツール」です。

「Homebrew-on-Linux」をインストールすることで、「Linux」、「Windows (wsl2)」にも対応しました:

-

参考:「Homebrew-on-Linux」のインストール手順:

Homebrew Documentation: Homebrew on Linux

MacOSLinux、および Windows (wsl2) で、同じパッケージ マネージャを使用してパッケージ管理ができます。
ちなみに、Homebrew (brew) を使うときは、sudo を付ける必要はありません。

-

5). 表示された項目の「コピー」ボタンをクリックして、クリップボードにコピー:

テキストエディタに貼り付け

-

6). 端末に 1行ずつ貼り付けて実行:

-

7). Vagrant がインストールされたか確認:

$ vagrant --version

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- -----

3-d. 参考: 「rpm」系のLinux にて、歴代の rpm の「Vagrant」をダウンロードして、インストールする場合:

-

Fedora」でインストールできるソフトを使いたいけど、CentOSリポジトリにないとき等に使えます:

インストールが楽な、デフォルトのリポジトリに登録されているパッケージは、
サーバー目的で使われることの多い「CentOS/RHEL」とか「RHEL 互換OS」(AlmaLinux、Rocky Linux 等)だと、「Fedora」よりも (リスクを減らすため、わざと?)少ないです。

-

歴代のrpm を自由に使えるのが「rpm」の利点です

歴代のリポジトリに登録されていた「rpm」パッケージは、3世代ほどの期間だけ、「RPM resource 」のサイトで公開されています。

-

なので、次のシステムが出ると「消える」リポジトリがあるので注意:

→サイトに存在しているときに(依存パッケージも含めて)保存しておくと良いです。

-

インストールできるのは、事前に「依存パッケージ」とのバージョンの整合が解決(インストール)できる、rpm のバージョンの場合だけです:

依存するパッケージの情報も「RPM resource 」のサイトで確認できます:

-

rpm のインストールで失敗したとき表示されるメッセージは、「rpm」パッケージ名でなく、「共有ライブラリ名」で表示されます。 ライブラリ名で検索すると、ヒットすることも、ヒットしない場合もあります。

-


現在利用できる「vagrant」の rpm パッケージ:

-

2023-12-01 現在:

ダウンロードできるのは、下記のリポジトリに登録されていたrpm パッケージです:

Fedora 37」、「Fedora 38」、「Fedora 39」、「Fedora Rawhide」(Fedora のローリング・リリース版)

-

  vagrant-2.2.19-5.fc37.noarch.rpm

-

  vagrant-2.2.19-10.fc38.noarch.rpm

-

  vagrant-2.3.4-3.fc39.noarch.rpm

-

  vagrant-2.3.4-3.fc39.noarch.rpm

-

→例えば、次のリビジョンが出ると、「Fedora 37」のrpm パッケージの登録は消えます。

-

システムが違うと共有ライブラリのバージョンが変わるので、すべての rpm パッケージが使えるとは限りません。

微妙に「vagrant」のバージョンが違うので、バージョンを整合させるときの選択肢が増えます。

ちなみに、「noarch」は「no アーキテクチャ」のことで、どのCPU タイプでも動くので、これを選ぶのが無難です。

-


参考:
「rpm」コマンドの使い方:

→注意: 「rpm」コマンドは、依存パッケージを自動解決してくれません:

手動で事前に、インストールしたいパッケージの依存パッケージをインストールしておく必要があります。「yum」や「dnf」コマンドの有り難みがわかります。

-

rpm」コマンドの使用例:

残念ながら、1年前の投稿なので「Fedora34」、「Fedora35」のリポジトリrpm は(消えており)使えません。
別のリポジトリに変えて使えるかは、試すしかなさそう。

-

1. 簡単な例:

「Rocky Linux 9.0」(Xfce) にて、 スクリーンビュワー「ristretto」のインストール:

-

2. 依存の多い例:

「Rocky Linux 9.0」(Xfce) にて、 日本語入力「ibus-mozc」のインストール:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -

4. ホストOS を再起動:

-

$ reboot

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- --

5. Web サイトで、使う目的に近い「Box」を検索:

-

Vagrant にて仮想マシンを作成(使用)するときに使われるのが、専用のサイトに置かれた使う目的に近い(ベースとなる) Vagrantの「Box」ファイルをダウンロードして追加することです:

→世界中で作成された様々な「Box」が公開されています。個人で試したい環境に近い、ベースとなる「Box」(仮想マシン)が手に入ります。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ---

5-a. ダウンロード可能な「Box」を、公式の「Vagrant Cloud」にて検索:

-

  • Vagrant Cloud (のバージョニングボックス)の機能を使うと、「Box」のバージョン管理が簡単になります。

 →コミュニティのサイトにはない利点

-

公式サイトの「VagrantCloud」:

Discover Vagrant Boxes

-


1). 「Discover Vagrant Boxes」の検索窓に、欲しい検索キーを入力:

例:

「CentOS7 PHP MariaDB」で検索:

→複数見つかります。

-


2). 「Box」を選ぶときの注意点:

-

(1). 「Popular」にあるダウンロード数が多い「Box」を選ぶのが無難。

-

(2). 「Box」のユーザ名:

ユーザ名が「Bent」や「ubuntu」の「Box」は信頼度が高いです。

-

(3). 「Box」のダウンロード数:

ダウンロードが多い「Box」は、頻繁に使われているので実績があります。

もし、悪意のあるソフトウェアが含まれている「Box」を見つけたら「support+vagrantcloud@bashicorp.com」に報告。

-

(4). 最新の公開日:

定期的に更新される「Box」、リリースが最近の「Box」には、最新のソフトウェアが含まれています。

-

(5). 「Box」のダウンロードが利用できるか:

Vagrant Cloud は、Vagrant Cloud 以外で「Box」の作成者によってホストされている「Box」の場合は、パブリックにアクセスできるか、定期的にチェックしています。この情報は、プロバイダの横にあるボックス ページで確認できます。

-


3). 表示された「Box」の一覧から、使用したい「Box」のURL をコピー:

テキストエディタに貼り付け

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----

5-b. ダウンロード可能な「Box」を、コミュニティの「Vagrantbox.es」にて検索:

-

ユーザが作成した「Box」を公開している、コミュニティのサイトがあります:

Vagrantbox.es

-

1). 「Box」の一覧が表示:

→検索キーでの絞り込みはできるけど、「ダウンロード数」や「サイズ」などでのソートはできません。

-

2). 使用したい「Box」のURL をコピー:

テキストエディタに貼り付け

-

3). 参考: 公開しても良い「Box」が出来たら、一覧に登録(貢献):

アップすることで、個人的にも、サイトを準備しなくても良いし、管理が楽で、「Box」も使いやすくなります。

プルリクエストを送信 します:

-

README.md より抜粋:

このリポジトリには、Web サイト「Vagrantbox.es」のコンテンツ、 つまり Vagrant 仮想化ツール用のサードパーティの「ベース ボックス」の一覧 が含まれています。

こちらで、一覧を更新したい人がプル リクエストを送信するだけで簡単に更新できます。

ただし、コードは「gh-pages」ブランチに移動されているので注意。そこに変更を提出します。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- -----

6. 「vagrant box add」にて、「Box」を追加する場合:

-

vagrant box add」コマンドを使って、「Box」を追加(ホームの隠しフォルダに保存)する場合、

基本的に「作業フォルダ」は、この時点では要りません。「vagrant init」の実行の時に必要です。

しかしながら、ファイルの動きを見たいので、わざと事前に準備しました。

-


1). 「仮想マシン」の設定ファイルを置く、「作業フォルダ」を準備:

-

(1). Windows の場合:
C:¥Users¥user> md CentOS-test
C:¥Users¥user> cd CentOS-test

-

(2). LinuxMacOS の場合:

mkdir で作成、もしくは、GUI で右クリック →「フォルダ作成」

$ mkdir -p ~/ダウンロード/vm/CentOS-test
$ cd  ~/ダウンロード/vm/CentOS-test/

-


2). 参考: Vagrant にて、 使用したい「Box」(仮想マシンイメージ)をダウンロードして追加:

基本的に「vagrant box add」コマンドを使う必要はありません:

通常の作業手順である、「vagrant init」で作成された「Vagrantfile」を使って「vagrant up」を実行すると、 「Box」がダウンロードされていない場合は、自動で(ホームの隠しフォルダに)ダウンロードされます。

つまり、「vagrant box add」の機能が流れの中に含まれています。

-

個人的には、コミュニティのサイトからのダウンロードの場合は、セキュリティ面で不安があるので、「vagrant box add」で自動でホームに一旦落としてから、実行する前に、ファイル構成を確認するなどできるので便利です。

-

Vagrant Box ファイルの保存先:

→「vagrant box add」または、「vagrant up」時に、「ホームの隠しフォルダ」に自動的に保存されます:

-

Vagrant BOX ファイルの一覧を表示:
$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-

実際のファイルの構造を表示:
$ ls -1ARp ~/.vagrant.d/boxes/
/home/ubn/.vagrant.d/boxes/:      ←(3つのBox が落ちています)
CentOS7-test/
generic-VAGRANTSLASH-fedora38/     ←(generic/fedora38 のことです)
nercceh-VAGRANTSLASH-ubuntu22.04-desktop/     ←(nercceh/ubuntu22.04-desktop のことです)

/home/ubn/.vagrant.d/boxes/CentOS7-test:  ←(Box 名)
0/ 

/home/ubn/.vagrant.d/boxes/CentOS7-test/0:  ←(バージョン番号を省略した時)
virtualbox/

/home/ubn/.vagrant.d/boxes/CentOS7-test/0/virtualbox: ←(プロバイダ名)
Vagrantfile
box-disk1.vmdk
box.ovf
metadata.json

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38:  ←(Box 名)
4.3.6/
metadata_url

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6:  ←(バージョン番号)
amd64/

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6/amd64:  ←(アーキテクチャ)
virtualbox/

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6/amd64/virtualbox: ←(プロバイダ名)
Vagrantfile
box.ovf
generic-fedora38-virtualbox-x64-disk001.vmdk
info.json
metadata.json

/home/ubn/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop:  ←(Box 名)
4.0.3/
metadata_url

/home/ubn/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3:  ←(バージョン番号)
virtualbox/

/home/ubn/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3/virtualbox: ←(プロバイダ名)
Vagrantfile
box.ovf
box_update_check
metadata.json
packer-virtualbox-iso-1670500096-disk001.vmdk
ubn@ubn-box:~$ 

-

不要になったVagrant BOX ファイルを削除:
$ vagrant box remove [Vagrant box名]

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- -

6-a. 公式サイトの「Vagrant Cloud」で検索、「Box」を追加する場合:

-

公式サイトの「VagrantCloud」:

Discover Vagrant Boxes

-

vagrant box add」コマンドの形式:

$ vagrant box add {管理名} 
  • {管理名} は、公式サイトに登録された名前(サイトに登録したユーザ名/box名)です:

→好みの「仮想マシン」名にすることはできません。

→ホームの隠しフォルダに「Vagrantfile」ファイル、およびディスクイメージが保存されます。

-

vagrant box add」コマンドを使うだけなら、事前に「作業フォルダ」を作る必要はありません:

vagrant initi」コマンドを使う時点で、「作業フォルダ」が必要です。
ただし、作業前に「作業フォルダ」に移動しておく、のが無難かも。

-

作業フォルダの作成:

$ mkdir -p ~/ダウンロード/vm/{test1,test2,test3}
$ ls -1 ~/ダウンロード/vm/
test1
test2
test3
ubn2204

→投稿が見やすいように「test1、test2、test3」のフォルダ名にしましたが、実際に使う場合は「fedora」等のわかりやすい名前がオススメです。
複数指定できるのは Linux の シェル (bash) の機能です。

ちなみに「ubn2204」は操作前に存在していたフォルダです。
「-p」は存在しなければ作成してくれる指定です。

-


「Box」を追加する例1:

-

(1). 「Box」を追加:
$ cd ~/ダウンロード/vm/test1/
$ vagrant box add generic/fedora38
==> box: Loading metadata for box 'generic/fedora38'
    box: URL: https://vagrantcloud.com/api/v2/vagrant/generic/fedora38
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.

1) docker
2) hyperv
3) libvirt
4) parallels
5) virtualbox
6) vmware_desktop

Enter your choice: 5   ←(「プロバイダ」の選択: virtualbox)

→複数のプロバイダに対応している場合の表示です。

==> box: Adding box 'generic/fedora38' (v4.3.6) for provider: virtualbox (amd64)
    box: Downloading: https://vagrantcloud.com/generic/boxes/fedora38/versions/4.3.6/providers/virtualbox/amd64/vagrant.box

↓ ダウンロード開始: %がカウントされます

    box: Calculating and comparing box checksum...
==> box: Successfully added box 'generic/fedora38' (v4.3.6) for 'virtualbox (amd64)'!
ubn@ubn-box:~/ダウンロード/vm/test1$ 

-

(2). 作業フォルダを確認:
$ ls -1A ~/ダウンロード/vm/test1/
$ 

→「vagrant box add」コマンドの実行では、「作業フォルダ」にファイルは作られません。

-

(3). ホームにある隠しフォルダを確認:
$ ls -1ARp ~/.vagrant.d/boxes/
/home/ubn/.vagrant.d/boxes/:
generic-VAGRANTSLASH-fedora38/
nercceh-VAGRANTSLASH-ubuntu22.04-desktop/

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38:
4.3.6/
metadata_url

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6:
amd64/

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6/amd64:
virtualbox/

/home/ubn/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6/amd64/virtualbox: ←(今回分)
Vagrantfile
box.ovf
generic-fedora38-virtualbox-x64-disk001.vmdk
info.json
metadata.json

/home/ubn/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop:
4.0.3/
metadata_url

/home/ubn/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3:
virtualbox/

/home/ubn/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3/virtualbox: ←(次回分)
Vagrantfile
box.ovf
box_update_check
metadata.json
packer-virtualbox-iso-1670500096-disk001.vmdk

-

(4). 「Vagrantfile」の内容を確認:
$ cat ~/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6/amd64/virtualbox/Vagrantfile
# The contents below were provided by the Packer Vagrant post-processor

Vagrant.configure("2") do |config|
  config.vm.base_mac = "0800277AC324"
end


# The contents below (if any) are custom contents provided by the
# Packer template during image build.
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure(2) do |config|

  config.vm.boot_timeout = 1800
  config.vm.synced_folder ".", "/vagrant", disabled: true

  config.vm.box_check_update = true

  # config.vm.post_up_message = ""
  config.vm.boot_timeout = 1800
  # config.vm.box_download_checksum = true
  config.vm.boot_timeout = 1800
  # config.vm.box_download_checksum_type = "sha256"

  # config.vm.provision "shell", run: "always", inline: <<-SHELL
  # SHELL

  # Adding a second CPU and increasing the RAM to 2048MB will speed
  # things up considerably should you decide to do anythinc with this box.
  config.vm.provider :hyperv do |v, override|
    v.maxmemory = 2048
    v.memory = 2048
    v.cpus = 2
  end

  config.vm.provider :libvirt do |v, override|
    v.disk_bus = "virtio"
    v.driver = "kvm"
    v.video_vram = 256
    v.memory = 2048
    v.cpus = 2
  end

  config.vm.provider :parallels do |v, override|
    v.customize ["set", :id, "--on-window-close", "keep-running"]
    v.customize ["set", :id, "--startup-view", "headless"]
    v.customize ["set", :id, "--memsize", "2048"]
    v.customize ["set", :id, "--cpus", "2"]
  end

  config.vm.provider :virtualbox do |v, override|
    v.customize ["modifyvm", :id, "--memory", 2048]
    v.customize ["modifyvm", :id, "--vram", 256]
    v.customize ["modifyvm", :id, "--cpus", 2]
    v.gui = false
  end

  ["vmware_fusion", "vmware_workstation", "vmware_desktop"].each do |provider|
    config.vm.provider provider do |v, override|
      v.whitelist_verified = true
      v.gui = false
      v.vmx["cpuid.coresPerSocket"] = "1"
      v.vmx["memsize"] = "2048"
      v.vmx["numvcpus"] = "2"
    end
  end

end

→複数の「ブロバイダ」に対応しています。 このように書くと、選択メッセージが表示されるのかな。

-

ちなみに、4行目は、ゲスト上のデフォルト NAT インターフェイスに割り当てられる MAC アドレス で、
ベンダー名の 08:00:27 は、ドイツのハードウェアのメーカ「PCS Systemtechnik GmbH」です。
「Packer」ツールのテンプレートを使うと、追加されるみたい。

-

(5). ディスクイメージのサイズを確認:
$ ls -lA ~/.vagrant.d/boxes/generic-VAGRANTSLASH-fedora38/4.3.6/amd64/virtualbox/
:
-rw-rw-r-- 1 ubn ubn      1949 11月 28 21:07 Vagrantfile
-rw-rw-r-- 1 ubn ubn      6786 11月 28 21:07 box.ovf
-rw-rw-r-- 1 ubn ubn 875532288 11月 28 21:07 generic-fedora38-virtualbox-x64-disk001.vmdk
-rw-rw-r-- 1 ubn ubn       301 11月 28 21:07 info.json
-rw-rw-r-- 1 ubn ubn        26 11月 28 21:07 metadata.json

→ディスクイメージのサイズで「Box」を選ぶのもありかも。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- --

6-b. コミュニティの「Vagrantbox.es」で検索、「Box」を追加する場合:

-

コミュニティのサイト:

Vagrantbox.es

-

Vagrant Cloud」を利用していないサイトの場合は、微妙にコマンドの書式が変わります。

-

vagrant box add」コマンドの形式:

$ vagrant box add {管理名} {URL}
  • {管理名} は、好みの管理しやすい名前にします。
  • {URL} に、使用したい「Box」のURL を貼り付けます。

→ホームの隠しフォルダに「Vagrantfile」ファイル、およびディスクイメージが保存されます。

-


「Box」を追加する例2:

-

(1). 「Box」を追加:
$ cd ~/ダウンロード/vm/test2/
$ vagrant box add CentOS7-test https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'CentOS7-test' (v0) for provider: 
    box: Downloading: https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
Download redirected to host: objects.githubusercontent.com
==> box: Successfully added box 'CentOS7-test' (v0) for ''!
ubn@ubn-box:~/ダウンロード/vm/test2$ 

-

(2). 作業フォルダを確認:
$ ls -1A ~/ダウンロード/vm/test2/
$ 

→「vagrant box add」では「作業フォルダ」にファイルは作られません。

-

(3). 「ホームの隠しフォルダ」を確認:
$ ls -1A ~/.vagrant.d/boxes/
:
CentOS7-test
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

-

$ ls -1ARp ~/.vagrant.d/boxes/CentOS7-test/
/home/ubn/.vagrant.d/boxes/CentOS7-test/:
0/

/home/ubn/.vagrant.d/boxes/CentOS7-test/0:
virtualbox/

/home/ubn/.vagrant.d/boxes/CentOS7-test/0/virtualbox:
Vagrantfile
box-disk1.vmdk
box.ovf
metadata.json

-

(4). 「Vagrantfile」の内容を確認:
$ cat ~/.vagrant.d/boxes/CentOS7-test/0/virtualbox/Vagrantfile
Vagrant::Config.run do |config|
  # This Vagrantfile is auto-generated by `vagrant package` to contain
  # the MAC address of the box. Custom configuration should be placed in
  # the actual `Vagrantfile` in this box.
  config.vm.base_mac = "080027DE0E0E"
end

# Load include vagrant file if it exists after the auto-generated
# so it can override any of the settings
include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ---

6-c. コミュニティの「Vagrantbox.es」でURL を検索、好みの「Box」名で追加する場合:

-

項番 6-b 」の「vagrant box add」コマンドを使うやり方だけでなく、 「vagrant init」を使うやり方もあります:

-

vagrant init」コマンドを実行して、テンプレートとなる「Vagrantfile」を作成。

「Vagrantfile」を修正して、「Box」をダウンロードして、好みの「Box」名で追加(保存)します:

-


「Box」を追加する例3:

-

(1). コミュニティのサイトで、好みの「Box」を検索し、URL をコピーしておきます:

-

コミュニティのサイト:

Vagrantbox.es

→「コピー」ボダンでクリップボードにコピー、テキストエディタに貼付けておきます。

-

(2). 作業フォルダの作成:
$ mkdir -p ~/ダウンロード/vm/{test1,test2,test3}

もしくは、

$ mkdir -p ~/ダウンロード/vm/test3

-

$ ls -1 ~/ダウンロード/vm/
test1
test2
test3
ubn2204

-

(3). 「Vagrantfile」を作成:
$ cd ~/ダウンロード/vm/test3/
$ vagrant init -m
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

→いつもの表示

-

確認:

$ ls -1A
Vagrantfile

→「Vagrantfile」が作成されました。

-

(4). 「Vagrantfile」の内容の確認:
$ cd ~/ダウンロード/vm/test3/
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "base"
end

-

(5). 「Vagrantfile」の修正:

使用するテキストエディタは何でも良いです:

$ cd ~/ダウンロード/vm/test3/
$ featherpad Vagrantfile

↓ 下記に置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  #config.vm.box = "base"
  config.vm.box = “CentOS7_test3”
  config.vm.box_url = "https://github.com/holms/vagrant-centos7-box/releases/download/7.1.1503.001/CentOS-7.1.1503-x86_64-netboot.box"
end

好みの「Box 名」に修正:
任意の「Box」ファイルのダウンロードURL を追記(URL を貼付け):

→コマンド側でパラメータを付加するのでなく、「Vagrantfile」を直接修正しました。

-

(6). 参考: 「-m」を付けない場合の「Vagrantfile」の内容:
$ cd ~/ダウンロード/vm/test3/
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "base"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Disable the default share of the current code directory. Doing this
  # provides improved isolation between the vagrant box and your host
  # by making sure your Vagrantfile isn't accessable to the vagrant box.
  # If you use this you may want to enable additional shared subfolders as
  # shown above.
  # config.vm.synced_folder ".", "/vagrant", disabled: true

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----

6-d. 公式サイトの「Vagrant Cloud」でURL を検索、好みの「Box」名で追加する場合:

-

項番 6-c. 」のやり方が公式のサイトでも使えるか、

つまり、「Vagrantfile」を修正して、「Box」をダウンロードして、好みの「Box」名で追加(保存)できるか、
トライしました:

-

ちなみに、公式のサイトで最初、「URL を見つけられなかった」ときに行った作業は「項番 9. 」に備忘録として残しました:

-


「Box」を追加する例3-2:

-

(1). 公式サイトで、好みの「Box」を検索し、URL をコピーしておきます:

-

公式サイトの「VagrantCloud」:

Discover Vagrant Boxes

-

公式サイトで、「Box」のURL をコピーするやり方:

公式サイトの一覧にある「generic/centos7 」をクリック

最新のバージョンである

v4.3.6 currently released version

virtualbox の項目にある、「amd64」の行の右端にある 水色の「↓」アイコンを右クリック →「リンクをコピー」

-

これが欲しかったURL です:

https://app.vagrantup.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box

-

(2). 作業フォルダの作成:
$ mkdir -p ~/ダウンロード/vm/{test1,test2,test3}

もしくは、

$ mkdir -p ~/ダウンロード/vm/test3

-

$ ls -1 ~/ダウンロード/vm/
test1
test2
test3
ubn2204

-

すでに test3 を使っているので、ファイルを削除:

$ cd ~/ダウンロード/vm/test3

$ ls -1A
Vagrantfile

削除:

$ rm Vagrantfile

$ ls -1A
$

-

(3). 「Vagrantfile」を作成:

例.「generic/centos7」

$ cd ~/ダウンロード/vm/test3/
$ vagrant init -m generic/centos7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

→いつもの表示

-

確認:

$ ls -1A
Vagrantfile

→「Vagrantfile」が作成されました。

-

(4). 「Vagrantfile」の内容の確認:
$ cd ~/ダウンロード/vm/test3/
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "generic/centos7"
end

-

(5). 「Vagrantfile」を修正:
$ cd ~/ダウンロード/vm/test3/
$ featherpad Vagrantfile

↓ すべて置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "CentOS7_test3_2"
  config.vm.box_url = "https://vagrantcloud.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box"
end

→Ctrl+S で、保存

→修正するよりも、すべて置換した方が確実です。

ちなみに、この状態が「vagrant init」を終えた状態です。

-

(6). うまく「仮想マシン」が作成されるか確認:
$ cd ~/ダウンロード/vm/test3/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'CentOS7_test3_2' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'CentOS7_test3_2' (v0) for provider: virtualbox   ←(仮想マシン名)
    default: Downloading: https://vagrantcloud.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box
==> default: Successfully added box 'CentOS7_test3_2' (v0) for 'virtualbox'!
==> default: Importing base box 'CentOS7_test3_2'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: test3_default_1701354147406_49248   ←(仮想マシン名)
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...   ←(Guest Additions Version のチェックでアウト)
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.2.44 r139111
    default: VirtualBox Version: 7.0
ubn@ubn-box:~/ダウンロード/vm/test3$ 

→エラーの対応は、次の投稿で回避しています。今回は無視。

-

$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

-

$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
CentOS7_test3_2             (virtualbox, 0)       ←(Box 名は変更されました)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-

(7). ファイルの確認:
$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
CentOS7_test3_2       ←(Box 名は変更されました)
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

-

$ ls -1A ~/ダウンロード/vm/test3/
:
.vagrant
Vagrantfile

→作業フォルダは正常です。

-

$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox
test3_default_1701354147406_49248  ←(注目)

VirtualBox の「仮想マシン」名はほとんど変わりません。数字が変わった位です。

-

結論:

-

(1). ダウンロードして保存される「Box」ファイル名は、「Vagrantfile」を修正すれば変更できます。
(2). ただし、公式サイトから持ってくる場合は、URL がわからないので、面倒です。

-

(3). VirtualBox の「仮想マシン」名は自動で付けられ、好みの名前に出来ません。
(4). VirtualBox の「仮想マシン」名は、「フォルダ名_default_自動で付く番号」になります。

→なので、フォルダ名を工夫すれば、わかりやすい名前を頭にすることは可能

-

 ちなみに、「default」は仮想マシン名です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- -----

7. 「仮想マシン」の初期化(「Vagrantfile」の作成):

-

vagrant init」コマンドを実行した「作業フォルダ」に「Vagrantfile」ファイルが生成されます:

-

vagrant init」コマンドの形式:

使い方: vagrant init [options] [name [url]]

→ [name [url]] の部分は、使うサイトで変わります。

公式サイトであれば、「登録された名前」(サイトに登録したユーザ名/box名)になり、
コミュニティサイトであれば、「管理しやすいように付けた名前」と「URL」になります。

-


1). 作業フォルダの作成:

すでに作成していた場合は不要です:

フォルダ作成で「-p」(--parents) を指定しているので、すでに存在していてもエラーは発生しません。 必要に応じて親ディレクトリが作成されます。

$ mkdir -p ~/ダウンロード/vm/{test1,test2,test3}
$ ls -1 ~/ダウンロード/vm/
test1
test2
test3
ubn2204
→次の処理に備えて、すでに作成されていたフォルダの中は「空」にしておく必要があります:

-

前回の作業でフォルダ内に作成されたファイルがあれば削除:
$  ls -1A
:
.vagrant
Vagrantfile

-

$ rm -r .vagrant
$ rm Vagrantfile
$ ls -A
$ 

-

ちなみに、フォルダ名はわかりやすい名前(例えば、fedora)にするのがオススメです。

-


2). 「仮想マシン」の初期化の例1:

-

(1). 「Vagrantfile」の作成:
$ cd ~/ダウンロード/vm/test1/
$ vagrant init generic/fedora38
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

和訳:

「Vagrantfile」はこのディレクトリに配置されています。
これで、最初の仮想環境を「vagrant up」する準備が整いました。
Vagrant の使用方法の詳細については、Vagrantfile のコメントと
「vagrantup.com」のドキュメントをお読みください。

-

(2). 作業フォルダを確認:
$ ls -1A ~/ダウンロード/vm/test1/
Vagrantfile

→「Vagrantfile」のみ作成されました。

-

(3). 「Vagrantfile」の内容を確認:
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "generic/fedora38"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Disable the default share of the current code directory. Doing this
  # provides improved isolation between the vagrant box and your host
  # by making sure your Vagrantfile isn't accessable to the vagrant box.
  # If you use this you may want to enable additional shared subfolders as
  # shown above.
  # config.vm.synced_folder ".", "/vagrant", disabled: true

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

→サイトに登録されている「Vagrantfile」と内容が違うことに注目:

Vagrant」のデフォルトのテンプレートで上書きされて、「vagrant init」コマンドに付けたパラメータ部分が反映されます。

-


3). 「仮想マシン」の初期化の例1-2:

-

(1). 「Vagrantfile」の作成:
$ cd ~/ダウンロード/vm/test1/
$ vagrant init -m generic/fedora38
`Vagrantfile` already exists in this directory. Remove it before
running `vagrant init`.

和訳:

`Vagrantfile` はこのディレクトリにすでに存在します。
「vagrant init」を実行する前に削除してください。

-

→「Vagrantfile」が存在すると、「vagrant init」は実行できません:

-

(2). 「Vagrantfile」を削除して「vagrant init」を再実行:
$ cd ~/ダウンロード/vm/test1/
$ rm Vagrantfile
$ vagrant init -m generic/fedora38
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

-

(3). 作業フォルダを確認:
$ ls -1A ~/ダウンロード/vm/test1/
:
.vagrant
Vagrantfile

→「Vagrantfile」だけでなく、「.vagrant」も作成されました。

-

(4). 「Vagrantfile」の内容を確認:
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "generic/fedora38"
end

→コメント行の削除を指示したので、スッキリ

-


4). 「仮想マシン」の初期化の例2:

-

(1). 「Vagrantfile」の作成:
$ cd ~/ダウンロード/vm/test2/
$ vagrant init CentOS7-test

→「vagrant box add」したので、URL の指定は省略できます。

もしくは、

$ cd ~/ダウンロード/vm/test2/
$ vagrant init CentOS7-test https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box

-

(2). 作業フォルダを確認:
$ ls -1A
Vagrantfile

-

(3). 「Vagrantfile」の内容を確認:
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
  # The most common configuration options are documented and commented below.
  # For a complete reference, please see the online documentation at
  # https://docs.vagrantup.com.

  # Every Vagrant development environment requires a box. You can search for
  # boxes at https://vagrantcloud.com/search.
  config.vm.box = "CentOS7-test"

  # Disable automatic box update checking. If you disable this, then
  # boxes will only be checked for updates when the user runs
  # `vagrant box outdated`. This is not recommended.
  # config.vm.box_check_update = false

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine. In the example below,
  # accessing "localhost:8080" will access port 80 on the guest machine.
  # NOTE: This will enable public access to the opened port
  # config.vm.network "forwarded_port", guest: 80, host: 8080

  # Create a forwarded port mapping which allows access to a specific port
  # within the machine from a port on the host machine and only allow access
  # via 127.0.0.1 to disable public access
  # config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"

  # Create a private network, which allows host-only access to the machine
  # using a specific IP.
  # config.vm.network "private_network", ip: "192.168.33.10"

  # Create a public network, which generally matched to bridged network.
  # Bridged networks make the machine appear as another physical device on
  # your network.
  # config.vm.network "public_network"

  # Share an additional folder to the guest VM. The first argument is
  # the path on the host to the actual folder. The second argument is
  # the path on the guest to mount the folder. And the optional third
  # argument is a set of non-required options.
  # config.vm.synced_folder "../data", "/vagrant_data"

  # Disable the default share of the current code directory. Doing this
  # provides improved isolation between the vagrant box and your host
  # by making sure your Vagrantfile isn't accessable to the vagrant box.
  # If you use this you may want to enable additional shared subfolders as
  # shown above.
  # config.vm.synced_folder ".", "/vagrant", disabled: true

  # Provider-specific configuration so you can fine-tune various
  # backing providers for Vagrant. These expose provider-specific options.
  # Example for VirtualBox:
  #
  # config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
  #   vb.memory = "1024"
  # end
  #
  # View the documentation for the provider you are using for more
  # information on available options.

  # Enable provisioning with a shell script. Additional provisioners such as
  # Ansible, Chef, Docker, Puppet and Salt are also available. Please see the
  # documentation for more information about their specific syntax and use.
  # config.vm.provision "shell", inline: <<-SHELL
  #   apt-get update
  #   apt-get install -y apache2
  # SHELL
end

-

$ cd ~/ダウンロード/vm/test2/
$ rm Vagrantfile
$ vagrant init -m vagrant init -m CentOS7-test https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

-

(4). 作業フォルダを確認:

$ ls -1A Vagrantfile

-

(5). 「Vagrantfile」の内容を確認:
$ cat Vagrantfile
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "CentOS7-test"
  config.vm.box_url = "https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box"
end

→「 vagrant init」時にコマンドで指定したパラメータが生きています。

-


5). 追加されたbox のリストを確認:

$ vagrant box list
CentOS7-test                (virtualbox, 0)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-


6). 「仮想マシン」の設定を変更したい場合:

「Vagrantfile」ファイルをエディタで修正:

$ cd  ~/ダウンロード/vm/fedora38/
$ vi Vagrantfile

→「Vagrantfile」ファイルが置かれているフォルダに移動します。エディタは何でも構いません。

-

例1: 仮想環境の ipアドレスを指定する部分(35行目)のコメントを解除:
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "bento/ubuntu-16.04"
end

-

例2: CPU数とメモリー容量を変更:

57行目から以下のようにコメント解除して値を変更:

  config.vm.provider "virtualbox" do |vb|
  #   # Display the VirtualBox GUI when booting the machine
  #   vb.gui = true
  #
  #   # Customize the amount of memory on the VM:
     vb.memory = "4096"
     vb.cpus = 2
  end

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- -

8. 「Vagrantfile」から「仮想マシン」を作成、立ち上げて、操作してみる:

-


1). 「仮想マシン」を起動:

「Vagrantfile」ファイルを使って、「仮想マシン」を作成して立ち上げ:

$ cd ~/ダウンロード/vm/fedora38/
$ vagrant up

しばらく待つと、プロンプトが表示:

→「Box」の利用はサーバー目的が多いので、デスクトップ環境が含まれていないことがほとんどです。 「仮想マシン」が起動されても GUI の画面が表示されないことがあります。

-


2). 「仮想マシン」が生成されていることを、「virtualbox」にて確認:

virtualbox」を実行して、「virtualbox」マネージャ画面で確認:

-

ちなみに、「Vagrant」の使用では、「virtualbox」マネージャは使われておらず、通常は起動されません。

virtualbox」マネージャで設定を変更すると「仮想マシン」(イメージ)には反映されますが、「Vagrantfile」ファイルには反映されません。逆に、「Vagrantfile」ファイルの設定は、初回の作成時に、「virtualbox」マネージャの設定画面に反映されます。

-


3). 「仮想マシン」に、SSH で接続してログイン:

-

Linux」、「MacOS」の場合:

端末にて:

$ vagrant ssh

→(すでに設定されているので)ポート指定しなくても、自動ログインされます。

-

ポート番号等の指定が必要な場合:

vagrant up」のメッセージに含まれる、 「仮想マシン」にSSH で接続するための情報を確認:

アドレス:192.168.33.10
ポート:22
ユーザ名:vagrant
パスワード:vagrant

-

もしくは、下記でも確認できます:

$ cd ~/ダウンロード/vm/test3
$ vagrant ssh-config

→「仮想マシン」の起動と、「作業フォルダ」への移動が必要です。

-

Windows」の場合:

PowerShell」を使うか、

もしくは、

TeraTerm」等の SSH クライアントを使って、ログイン:

「TeraTerm」の入手:

-


4). 作業を終えたら、「仮想マシン」の SSH 接続を切断:

$ exit

もしくは、

$ logout

もしくは、

Ctrl+D

→「仮想マシン」からローカルPC環境に戻ります:

-


5). 「仮想マシン」の停止(シャットダウン):

$ vagrant halt

-


6). 要らなくなった「仮想マシン」を削除するとき:

仮想マシン」の作業フォルダに移動後、

$ vagrant destroy

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- --

9. 備忘録: 公式サイトの「Vagrant Cloud」から、好みの「Box」名で追加する場合:

-

「Vagrantfile」を修正して、「Box」をダウンロードして、好みの「Box」名で追加(保存)できるか、

項番 6-d. 」の作業で、「URL を見つけられなかった」ときに行った作業です。

その後 URL を見つけたので、こちらの作業は要りません。参考として手順を残しました。

-


「Box」を追加する例3-2:

公式のサイトでも「例3 」のやり方ができるか、確認:

-

(1). 公式サイトで、好みの「Box」を検索し、URL をコピーしておきます:

-

公式サイトの「VagrantCloud」:

Discover Vagrant Boxes

→残念ながら、サイトに「URL の表示が見つかりません」

-

なので、「Box」名をコピーしました。

例.「generic/centos7」

-


追記: URL を見つけました:

公式サイトの一覧にある「generic/centos7 」をクリック

最新のバージョンである

v4.3.6 currently released version

virtualbox の項目にある、「amd64」の行の右端にある 水色の「↓」アイコンを右クリック →「リンクをコピー」

-

これが欲しかったURL です:

https://app.vagrantup.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box

-

URL が見つかったので、項番 (5). 〜 (19). は要りません。

項番 (1). 〜 (4).、および、項番 (20).以降を実行して下さい:

-

(2). 作業フォルダの作成:
$ mkdir -p ~/ダウンロード/vm/{test1,test2,test3}

もしくは、

$ mkdir -p ~/ダウンロード/vm/test3

-

$ ls -1 ~/ダウンロード/vm/
test1
test2
test3
ubn2204

-

すでに test3 を使っているので、ファイルを削除:

$ cd ~/ダウンロード/vm/test3

$ ls -1A
Vagrantfile

削除:

$ rm Vagrantfile

$ ls -1A
$

-

(3). 「Vagrantfile」を作成:

例.「generic/centos7」

$ cd ~/ダウンロード/vm/test3/
$ vagrant init -m generic/centos7
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

→いつもの表示

-

確認:

$ ls -1A
Vagrantfile

→「Vagrantfile」が作成されました。

-

(4). 「Vagrantfile」の内容の確認:
$ cd ~/ダウンロード/vm/test3/
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "generic/centos7"
end

→残念ながら、URL の指定がわからないので、修正できません。

-


(5). 試しに、「vagrant up」して、立ち上げ時のメッセージを確認:
$ cd ~/ダウンロード/vm/test3/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'generic/centos7' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'generic/centos7'
    default: URL: https://vagrantcloud.com/api/v2/vagrant/generic/centos7
==> default: Adding box 'generic/centos7' (v4.3.6) for provider: virtualbox (amd64)
    default: Downloading: https://vagrantcloud.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box ←★1
    default: Calculating and comparing box checksum...
==> default: Successfully added box 'generic/centos7' (v4.3.6) for 'virtualbox (amd64)'!
==> default: Importing base box 'generic/centos7'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'generic/centos7' version '4.3.6' is up to date...
==> default: Setting the name of the VM: test3_default_1701344130827_52682   ←(仮想マシン名)
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...      ←★2
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.2.44 r139111
    default: VirtualBox Version: 7.0
ubn@ubn-box:~/ダウンロード/vm/test3$ 

→「★1」の行のURL に注目: (欲しかった URL)

https://vagrantcloud.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box

-

→「★2」の行の「Guest Additions Version」のチェックで失敗。作成された「仮想マシン」が起動しきれません。

-

(5). 追加された「Box」を確認:
$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
generic/centos7             (virtualbox, 4.3.6, (amd64))   ←(注目)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-

(6). 「VirtualBox マネージャ」を起動して、追加された「仮想マシン」を確認:

仮想マシンとして、「/test3_default_1701344130827_52682」が追加されて「実行中」です:

サブ画面が真っ黒です。

→「VirtualBox マネージャ」画面の右上の「x」で閉じます。

-

(7). 「仮想マシン」の状態を確認:
$ vagrant status
Current machine states:

default                   running (virtualbox)    ←(仮想マシン「default」が実行中)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

-

(8). 「仮想マシン」の停止:
$ vagrant halt
==> default: Attempting graceful shutdown of VM...

-

(9). 「仮想マシン」の状態を確認:
$ vagrant status
Current machine states:

default                   poweroff (virtualbox)   ←(仮想マシン「default」が電源オフ)

The VM is powered off. To restart the VM, simply run `vagrant up`

-

(10). 保存された「Box」のファイル(フォルダ)を確認
$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
generic-VAGRANTSLASH-centos7       ←(注目)
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

-

(11). VirtualBox の「仮想マシン」のファイルを確認
$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox
test3_default_1701344130827_52682       ←(注目)

VirtualBox の「仮想マシン」名は、「フォルダ名default自動付加された番号」

-

(12). 作業フォルダの確認:
$ cd ~/ダウンロード/vm/test3/
$ ls -1A
.vagrant
Vagrantfile

-

(13). 「仮想マシン」の削除:
$ cd ~/ダウンロード/vm/test3/
$ vagrant destroy
    default: Are you sure you want to destroy the 'default' VM? [y/N] 

和訳:

    default: 「default」VM を破棄してもよろしいですか?  [y/N] 

→「y」Enter

-

==> default: Destroying VM and associated drives...

-

(14). ファイルの確認:
$ ls -1A ~/ダウンロード/vm/test3/
:
.vagrant
Vagrantfile

→作業フォルダは残っています。

-

$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox

VirtualBox の「仮想マシン」が削除されました。

-

$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
generic-VAGRANTSLASH-centos7       ←(注目)
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

→ダウンロードされた「Box」のファイルは残っています。

-

(15). 「仮想マシン」の状態を確認:
$ vagrant status
Current machine states:

default       not created (virtualbox)   ←(仮想マシン「default」が作成されていません)

The environment has not yet been created. Run `vagrant up` to
create the environment. If a machine is not created, only the
default provider will be shown. So if a provider is not listed,
then the machine is not created for that environment.

-

(16). 「VirtualBox マネージャ」を起動して、追加された「仮想マシン」を確認:

仮想マシンの「/test3_default_1701344130827_52682」が削除されました。

→「VirtualBox マネージャ」画面の右上の「x」で閉じます。

-

(17). 不要になったVagrant BOX ファイルを削除:
$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
generic-VAGRANTSLASH-centos7       ←(注目)
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

-

$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
generic/centos7             (virtualbox, 4.3.6, (amd64))  ←(注目)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-

削除:

$ vagrant box remove generic/centos7
Removing box 'generic/centos7' (v4.3.6) with provider 'virtualbox'...

-

確認:

$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

→削除されました。

-

$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

→削除されました。

-

$ ls -1A ~/ダウンロード/vm/test3
:
.vagrant
Vagrantfile

→作業フォルダは残っています。影響なし。

-

(18). 残った「.vagrant」フォルダだけ削除:
$ cd ~/ダウンロード/vm/test3/
$ rm -r .vagrant
$ ls -1A
Vagrantfile

→やっと、ここまで来ました。

-

(19). 「Vagrantfile」の内容を確認:
$ cd ~/ダウンロード/vm/test3/
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "generic/centos7"
end

-

(20). 「Vagrantfile」を修正:
$ cd ~/ダウンロード/vm/test3/
$ featherpad Vagrantfile

↓ すべて置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "CentOS7_test3_2"
  config.vm.box_url = "https://vagrantcloud.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box"
end

→Ctrl+S で、保存

→修正するよりも、すべて置換した方が確実です。

ちなみに、この状態が「vagrant init」を終えた状態です。

-

(21). うまく「仮想マシン」が作成されるか確認:
$ cd ~/ダウンロード/vm/test3/
$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'CentOS7_test3_2' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Box file was not detected as metadata. Adding it directly...
==> default: Adding box 'CentOS7_test3_2' (v0) for provider: virtualbox   ←(仮想マシン名)
    default: Downloading: https://vagrantcloud.com/generic/boxes/centos7/versions/4.3.6/providers/virtualbox/amd64/vagrant.box
==> default: Successfully added box 'CentOS7_test3_2' (v0) for 'virtualbox'!
==> default: Importing base box 'CentOS7_test3_2'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: test3_default_1701354147406_49248   ←(仮想マシン名)
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: 
    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default: 
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if it's present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...   ←(Guest Additions Version のチェックでアウト)
    default: The guest additions on this VM do not match the installed version of
    default: VirtualBox! In most cases this is fine, but in rare cases it can
    default: prevent things such as shared folders from working properly. If you see
    default: shared folder errors, please make sure the guest additions within the
    default: virtual machine match the version of VirtualBox you have installed on
    default: your host and reload your VM.
    default: 
    default: Guest Additions Version: 5.2.44 r139111
    default: VirtualBox Version: 7.0
ubn@ubn-box:~/ダウンロード/vm/test3$ 

→エラーの対応は、次の投稿で回避しています。今回は無視。

-

$ vagrant status
Current machine states:

default                   running (virtualbox)

The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.

-

$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
CentOS7_test3_2             (virtualbox, 0)       ←(Box 名は変更されました)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-

(22). ファイルの確認:
$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
CentOS7_test3_2       ←(Box 名は変更されました)
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

-

$ ls -1A ~/ダウンロード/vm/test3/
:
.vagrant
Vagrantfile

→作業フォルダは正常です。

-

$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox
test3_default_1701354147406_49248  ←(注目)

VirtualBox の「仮想マシン」名はほとんど変わりません。数字が変わった位です。

-

結論:

-

(1). ダウンロードして保存される「Box」ファイル名は、「Vagrantfile」を修正すれば変更できます。
(2). ただし、公式サイトから持ってくる場合は、URL がわからないので、面倒です。

-

(3). VirtualBox の「仮想マシン」名は自動で付けられ、好みの名前に出来ません。
(4). VirtualBox の「仮想マシン」名は、「フォルダ名_default_自動で付く番号」になります。

→なので、フォルダ名を工夫すれば、わかりやすい名前を頭にすることは可能

-

 ちなみに、「default」は仮想マシン名です。

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ---

10. 参考: 「Vagrant」コマンドについて:

-

1). すべての「Vagrant」コマンド のヘルプを表示:

$ vagrant list-commands

和訳:

以下は、利用可能なすべての Vagrant コマンドのリストとその機能の簡単な説明です:

autocomplete    ホスト上の自動完了されるインストールを管理
box             ボックスを管理します: インストール、削除など ★
cap             能力をチェックして実行します
cloud           Vagrant Cloud に関連するすべてを管理
destroy         vagrant マシンのすべてのトレースを停止して削除 ★
docker-exec     すでに実行されている Docker コンテナにアタッチします
docker-logs     Dockerコンテナからログを出力します。
docker-run      コンテナのコンテキストで 1 回限りのコマンドを実行
global-status   このユーザの Vagrant 環境のステータスを表示
halt            vagrant マシンを停止 ★★
help            サブコマンドのヘルプを表示 ★
init            Vagrantfile を作成して新しい Vagrant 環境を初期化します ★★
list-commands   プライマリ以外も含め、利用可能なすべての Vagrant サブコマンドを表示
login           
package         実行中の vagrant 環境を、ボックスにパッケージ化します ★
plugin          プラグインを管理します: インストール、アンインストール、更新など
port            ゲストポートマッピングに関する情報を表示
powershell      PowerShell をリモート経由でマシンに接続します
provider        この環境のプロバイダーを表示
provision       vagrant マシンをプロビジョニングします
push            この環境内のコードを構成された宛先にデプロイします
rdp             RDP経由でマシンに接続します
reload          vagrant マシンを再起動し、新しい Vagrantfile 設定を反映します ★★
resume          一時停止された vagrant マシンを再開します ☆
rsync           rsync 同期フォルダーをリモートマシンに同期します
rsync-auto      同期 rsync ファイルが変更されると自動的に同期フォルダーを同期します
serve           Vagrant サーバーを起動
snapshot        スナップショットを管理します: 保存、復元など
ssh             SSH 経由でマシンに接続 ☆(「ssh」より「vagrant ssh」は操作が楽)
ssh-config      マシンに接続するための OpenSSH の有効な設定を表示
status          vagrant で管理されている「仮想マシン」の稼働状況を表示 ★
suspend         マシンを一時停止 ☆
up              vagrant 環境を開始してプロビジョニングします ★★
upload          コミュニケータ経由でマシンにアップロード
validate        Vagrantfile を検証します
version         現在および最新の Vagrant バージョンを表示
winrm           WinRM 経由で Windows の「仮想マシン」上でコマンドを実行します
winrm-config    Windows の「マシン」に接続するための WinRM の設定を表示

→「★」はよく使うコマンド。「☆」は個人的に少し頻度が下がり、「★★」は頻度が高いもの。

-

参考: 「WinRM」とは、
他の Windows マシンのコマンドラインPowerShell)を呼び出して、遠隔でコマンドの実行やプログラムの起動などを行うための機能です。

-


2). 「Vagrant init」コマンド のヘルプを表示:

$ vagrant init --help

和訳:

使い方: vagrant init [オプション] [name [url]]

オプション:

     --box-version VERSION    追加するボックスのバージョン
 -f, --force                  既存の Vagrantfile を上書きする
 -m, --minimal                最小限の Vagrantfile テンプレートを使用 ★
                              (コメント行の省略) --template の指定があれば無視
     --output FILE            ボックスの出力パス。標準出力の場合は「-」
     --template FILE          カスタム Vagrantfile テンプレートへのパス

     --[no-]color             カラー出力を有効または無効にします
     --machine-readable       マシンの可読出力を有効にします
 -v, --version                Vagrantのバージョンを表示
     --debug                  デバッグ出力を有効にします
     --timestamp              ログ出力のタイムスタンプを有効にします
     --debug-timestamp        タイムスタンプ付きのデバッグ出力を有効にします
     --no-tty                 非対話型出力を有効にします
 -h, --help                   このヘルプを表示します

-


3). 「Vagrant box」コマンド のヘルプを表示:

$ vagrant box --help

和訳:

使い方: vagrant box <サブコマンド> [<args>]

利用可能なサブコマンド:
     add
     list
     outdated
     prune
     -
     repackage
     update

個々のサブコマンドのヘルプについては、「vagrant box <サブコマンド> -h」を実行ください

      --[no-]color           カラー出力を有効または無効にします
      --machine-readable     マシンの可読出力を有効にします
  -v, --version              Vagrant のバージョンを表示
      --debug                デバッグ出力を有効にします
      --timestamp            ログ出力のタイムスタンプを有効にします
      --debug-timestamp      タイムスタンプ付きのデバッグ出力を有効にします
      --no-tty               非対話型出力を有効にします

-


4). 「Vagrant box add」コマンド のヘルプを表示:

$ vagrant box add --help

和訳:

使い方: vagrant box add [オプション] <name, url, or path>

オプション:

  -c, --clean                一時ダウンロード ファイルをすべて削除します
  -f, --force                既存のボックスが存在する場合は上書きします
      --insecure             SSL 証明書を検証しません
      --cacert FILE          SSLダウンロード用のCA証明書
      --capath DIR           SSLダウンロード用のCA証明書ディレクトリ
      --cert FILE            クライアント SSL 証明書 (必要な場合)
      --location-trusted     HTTP リダイレクトの「Location」ヘッダーを信頼し、
                             後続の URL に対して最初の URL と同じ認証情報を使用
  -a, --architecture ARCH    ボックスが満たすべきアーキテクチャ
      --provider PROVIDER    ボックスが満たすべきプロバイダ
      --box-version VERSION  追加されたボックスのバージョンを制限します

ボックスのパラメータは、HashiCorp の Vagrant Cloud 上のボックスの名前、URL、
ローカル .box ファイル、または カタログ メタデータを含むローカル .json ファイル
にすることができます。

以下のオプションは、Vagrant サーバーや「user/box」のような構造
のボックスを使用せず、ボックス ファイルを直接追加する場合にのみ適用されます:

      --checksum CHECKSUM    ボックスのチェックサム
      --checksum-type TYPE   チェックサムの種類 (md5、sha1、sha256)  
      --name BOX             ボックスの名前 ★

      --[no-]color           カラー出力を有効または無効にします
      --machine-readable     マシンの可読出力を有効にします
  -v, --version              Vagrantのバージョンを表示
      --debug                デバッグ出力を有効にします
      --timestamp            ログ出力のタイムスタンプを有効にします
      --debug-timestamp      タイムスタンプ付きのデバッグ出力を有効にします
      --no-tty               非対話型出力を有効にします
  -h, --help                 このヘルプを表示します

-


5). 「vagrant ssh-config」コマンド のヘルプを表示:

$ vagrant ssh-config --help

和訳:

使い方: vagrant ssh-config [オプション] [name|id]

オプション:

      --host NAME              設定ファイルのHost 行の「名前」を設定します

      --[no-]color             カラー表示を有効または無効にします
      --machine-readable       マシン可読出力を有効にします
  -v, --version                Vagrant のバージョンを表示
      --debug                  デバッグ出力を有効にします
      --timestamp              ログ出力のタイムスタンプを有効にします
      --debug-timestamp        タイムスタンプ付きのデバッグ出力を有効にします
      --no-tty                 非対話型出力を有効にします
  -h, --help                   このヘルプを表示

-

コマンドを使用する場合は、
起動している「仮想マシン」の「作業フォルダ」で実行します:
$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant ssh-config

→「ssh」コマンドで、ssh 接続時に使える、ssh の設定を表示:

表示されるだけで、使える設定にするには、「~/.ssh/config」に反映させるか、ssh コマンドのパラメータとして与えます。

-

$ vagrant ssh-config --host test01

→Host 行の「名前」を「test01」に変更して表示

-


6). 「vagrant package」コマンド のヘルプを表示:

$ vagrant package --help

和訳:

使い方: vagrant package [オプション] [name|id]

オプション:

     --base NAME           ベース になる Box としてパッケージ化したい
                           VirtualBox 内の VM の名前 (VirtualBox の場合)
     --output NAME         出力するファイルの名前
     --include FILE,FILE.. Box にパッケージ化したいカンマ区切りの追加ファイル
     --info FILE           追加のBox の情報を含むカスタム info.jsonファイルへのパス
     --vagrantfile FILE    Box に同梱する Vagrantfile

     --[no-]color          カラー表示を有効または無効にします
     --machine-readable    マシン可読出力を有効にします
 -v, --version             Vagrant のバージョンを表示
     --debug               デバッグ出力を有効にします
     --timestamp           ログ出力のタイムスタンプを有効にします
     --debug-timestamp     タイムスタンプ付きのデバッグ出力を有効にします
     --no-tty              非対話型出力を有効にします
 -h, --help                このヘルプを表示

-

コマンドを使用する場合は、
作成した「仮想マシン」の「作業フォルダ」で実行します:
$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant package

→「作業フォルダ」に「package.box」が生成されます

ちなみに、「仮想マシン」を id で指定した場合は、どのフォルダ位置でも実行できます:

実行前に、「package.box」を生成したい「フォルダ」に移動しておきます。

-


7). 「vagrant box update」のヘルプを表示:

→「こちら」を参照:

-


8). 「vagrant vbguest」のヘルプを表示:

→「こちら」を参照:

-


9). 「vagrant box remove」のヘルプを表示:

→「こちら」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----

11. 参考: 「Vagrant」コマンドの使用例:

-

項番 9. 」で色々と使っているので、そこからの抜粋、および、補足しました:

-

Vagrant」コマンドの使用例:

目次は「項番 12. 」を参照:

-


1). 公式サイトから「Box」を追加:

「ホームの隠しフォルダ」にある「Box」の一覧に保存されます:

$ vagrant box add generic/fedora38

→「作業フォルダ」に移動する必要はありません。
名前が「登録ユーザ名/box 名」になっており、URL の指定は要りません。

好みの「Box」名で保存するのは手間がかかる割に、おいしくありません。
それは「仮想マシン名」として使われないからです。

-

参考: 「VirtualBox」の仮想マシン名の先頭に「作業フォルダ」名が含まれるので、
どちらかというと「作業フォルダ」の名前の付け方が重要です。

-


2). コミュニティのサイトから「Box」を追加:

「ホームの隠しフォルダ」にある「Box」の一覧に保存されます:

$ vagrant box add CentOS7-test https://github.com/tommy-muehle/puppet-vagrant-boxes/releases/download/1.1.0/centos-7.0-x86_64.box

→「作業フォルダ」に移動する必要はありません。
好みの「Box」名で保存できます。(例では「CentOS7-test」)

URL の指定は、どこからダウンロードするかわからないので必須です。
URL の指定は、ローカルにある「Box」の指定でもOK です。

-

参考: 好みの「Box」名で保存できても、作成される「仮想マシン」の名前は「項番 1).」と同じ形式なので、「作業フォルダ」の名前の付け方が重要です。

-


3). 保存された「Box」の一覧を表示:

$ vagrant box list
CentOS7-test                (virtualbox, 0)
generic/centos7             (virtualbox, 4.3.6, (amd64))
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-

保存された「Box」のファイル(フォルダ)を表示:
$ ls -1 ~/.vagrant.d/boxes/
CentOS7-test
generic-VAGRANTSLASH-centos7
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

→フォルダの内容と連動しています。

-

参考1: 「Box」はリビジョン管理がしやすいフォルダの並びです:

-

例1. リビジョン指定がない場合:
$ cd ~/.vagrant.d/boxes/
$ ls -1 CentOS7-test/0/virtualbox/
Vagrantfile
box-disk1.vmdk
box.ovf
metadata.json

-

例2. リビジョン指定がある場合(公式サイト):
$ cd ~/.vagrant.d/boxes/
$ ls -1 generic-VAGRANTSLASH-fedora38/4.3.6/amd64/virtualbox/
Vagrantfile
box.ovf
generic-fedora38-virtualbox-x64-disk001.vmdk
info.json
metadata.json

-

参考2: 「Box」の一覧が保存される「ホームの隠しフォルダ」の位置は変更可能:

デフォルトは「$HOME/.vagrant.d/」(つまり、「~/.vagrant.d/」)で、その配下の「boxes/」に保存されます。

ホストOS にて、下記の操作でパスを変更できます:

-

一時的な変更:
$ export VAGRANT_HOME=/任意のディレクトリの絶対パス

-

永続的な変更:

シェルがBash の場合:

「~/.bash_profile」ファイルの最後に下記の 1行を追記:

export VAGRANT_HOME=/任意のディレクトリの絶対パス

-


4). 「作業フォルダ」に「Vagrantfile」を作成:

Web サイトによっては仮想マシン」の初期化、という表現もされてます。

(1). 「作業フォルダ」の準備:

目的の業務(プロジェクト)ごとに「フォルダ分け」を行う、
vagrant init」の実行で「Vagrantfile」が作られるフォルダを準備します:

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考: 「作業フォルダ」配下は「共有フォルダ」として、「仮想マシン」上の「/vagrant」と同期されます:

仮想マシン」を立ち上げて、

バイス →「共有フォルダー」→「共有フォルダー設定」

「作業フォルダ」が共有フォルダとして登録されているか、確認:

-

ホストOS を再起動:
一度再起動しないと、有効になりません。

-

使用例:

仮想マシン」にて、

$ gedit Documents/sudo-cat-etc-sudoers.txt

-

共有フォルダにコピー:

$ sudo cp Documents/sudo-cat-etc-sudoers.txt /vagrant

-

「ホストOS」にて、

$ ls -1A ~/ダウンロード/vm/ubn2204
.vagrant
Vagrantfile
sudo-cat-etc-sudoers.txt  ←(追加されました)

ちなみに、上記の 3つとも「仮想マシン」の「/vagrant」で見えるようになります。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

Windows11 の場合:

  (下記は PowerShell7 を使用)  黒い端末アイコン

-

ホームの「Downloads」フォルダで作業した場合:

PS C:\Users\user> cd Downloads

-

フォルダの作成:

PS C:\Users\user\Downloads> md vm/fedora

もしくは、

PS C:\Users\user\Downloads> mkdir vm/fedora
    Directory: C:\Users\user\Downloads\vm

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----       2023/12/05 火     0:19                fedora

→「md vm\fedora」を間違って「md vm/fedora」と入れても、ちゃんと実行されました。

また、2階層(2つのフォルダ)の指定でも、ちゃんと 2つのフォルダが作成されました。

-

ちなみに、Windowsコマンドプロンプトの「PS C:\Users\user>」の「user」は(ログイン時に表示される)任意のユーザ名です。 また、頭にある「PS」は、「PowerShell」のコマンドプロンプトであることを意味します。

-

参考: ファイル階層(パス)の指定で使われるフォルダの区切りは、Linux であれば「/」で、Windows であれば「\」(または ¥)です。

-

「作業フォルダ」の移動:

PS C:\Users\user\Downloads> cd vm/fedora

もしくは、

PS C:\Users\user\Downloads> Set-Location vm/fedora

-

「作業フォルダ」の確認:

PS C:\Users\user\Downloads\vm\fedora> pwd

もしくは、

PS C:\Users\user\Downloads\vm\fedora> Get-Location
Path
----
C:\Users\user\Downloads\vm\fedora

PowerShell だと、文字列でなく配列で返るので、うるさい(見やすい?)ですね。

-

ちなみに、ヘルプを見ようと「md --help」としたら「--help」フォルダが出来てしまいました。
Linux の「Bash」とコマンドは似てるけど、別物(別なコマンドに似せたエイリアス )なので操作に注意。使えるパラメータも機能も違います。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

Linux の場合:
$ mkdir -p ~/ダウンロード/vm/ubn2204

-

(2). 「Vagrantfile」を作成:

例. 公式サイトの「nercceh/ubuntu22.04-desktop」

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant init -m nercceh/ubuntu22.04-desktop
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

→いつものメッセージが表示

-

「-m, --minimal」パラメータについて:

→「-m」はコメント行を削除して見やすくします。修正の可能性があるなら付けません。

「--template」を指定すると「-m」は無視されます。

-

(3). 「vagrant init」の実行後の確認:
$ cd ~/ダウンロード/vm/ubn2204/

$ ls -1A
Vagrantfile

→現在の「作業フォルダ」に「Vagrantfile」が作成されます。

-

(4). 参考: 「vagrant init」の実行で、

テンプレートファイルを使って、
入力した「vagrant init」コマンドに付けたパラメータ、
および省略した「プロバイダ名」を加えた内容で、

「作業フォルダ」に「Vagrantfile」が保存されます。

-

(5). 「Vagrantfile」の内容を確認:
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box_url = "nercceh/ubuntu22.04-desktop"
end

→「Vagrantfile」は、デフォルトのテンプレートで上書きされました。

「-m」で、コメント行を削除したので、すっきりしました。 修正の可能性があるなら付けません。

-

(6). 参考: 「Vagrantfile」の書式について:

Vagrant.configure("2") do |config|
 :
end

2」は、Vagrant の config のバージョンを示し、"1" または "2" が指定できます。

|config|」は、( do から end までの)スコープの識別子です。

-


5). 「仮想マシン」の(初回のみ生成、および)立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up

→「Vagrantfile」が置かれた「作業フォルダ」に移動して、実行します。

-

作業フォルダの確認:
$ ls -1A ~/ダウンロード/vm/ubn2204/
.vagrant    ←(vagrant up で追加: 「仮想マシン」を管理)
Vagrantfile    ←(vagrant up するのに必要)

-

ホームの隠しフォルダに保存された「Box」(フォルダ)を確認
$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
generic-VAGRANTSLASH-centos7
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop   ←(初回、なければ自動で追加)

-

VirtualBox に追加された「仮想マシン」のファイルを確認:
$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox
ubn2204_default_1701558714834_11706  ←(追加)

-

参考: まとめ
  • -VAGRANTSLASH-」は「/」のこと。Web 等で影響されない記述です

  • 保存されている「Box」のフォルダにて、「-VAGRANTSLASH-」が含まれているのは、公式サイトの「Box」からダウンロードされたと、すぐにわかります

 

  • VirtualBox で管理されている「仮想マシン」名は、「フォルダ名_default_自動付加された番号」の形式です

  • 先頭の「フォルダ名」 は邪魔だけど、逆に、 VirtualBox 側の「仮想マシン」名を見れば、対応している(「Vagrantfile」が置かれた)「作業フォルダ」の名前(位置)がすぐにわかります

  • default」は、「Vagrant」で管理されている「仮想マシン名」で(自分の知識では)変更できませんでした:

 →「Vagrant」では、「vagrant status default」のように使えます

-


6). 「Vagrant」で管理されている(VirtualBox の)「仮想マシン」の稼働状態を表示:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant status
Current machine states:

default                   poweroff (virtualbox)

The VM is powered off. To restart the VM, simply run `vagrant up`

もしくは、

VirtualBox マネージャ」画面でも「仮想マシン」の状態は確認できます:

-


7). 「Vagrant」で管理されている(VirtualBox の)すべての「仮想マシン」の稼働状態を表示:

$ vagrant global-status
id       name    provider   state    directory                           
-------------------------------------------------------------------------
d4b57c8  default virtualbox running  /home/ubn/ダウンロード/vm/test3           
5770428  default virtualbox poweroff /home/ubn/ダウンロード/vm/ubn2204         
 
The above shows information about all known Vagrant environments
on this machine. This data is cached and may not be completely
up-to-date (use "vagrant global-status --prune" to prune invalid
entries). To interact with any of the machines, you can go to that
directory and run Vagrant, or you can use the ID directly with
Vagrant commands from any directory. For example:
"vagrant destroy 1a2b3c4d"

和訳:

上記は、このマシン上のすべての既知の Vagrant 環境に関する情報を示しています。
このデータはキャッシュされているため、完全に最新ではない可能性があります。
 (無効なエントリを削除するには「vagrant global-status --prune」を使用します)。

いずれかのマシンと対話するには、そのディレクトリに移動して Vagrant を実行するか、
任意のディレクトリから Vagrant コマンドで ID を直接使用することができます。
例: 「vagrant destroy 1a2b3c4d」

もしくは、

VirtualBox マネージャ」画面でも「仮想マシン」の状態は確認できます:

-


8). 起動している「仮想マシン」に直接、SSH で接続(自動ログイン):

-

仮想マシン」が起動していない場合:

ssh で接続:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant ssh

赤色で警告表示:

VM must be running to open SSH connection. Run `vagrant up`
to start the virtual machine.

和訳:

SSH 接続するには「仮想マシン」が実行されている必要があります。
「vagrant up」を実行して「仮想マシン」を起動します。

-

仮想マシン」の立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up

-

ssh で接続:

$ vagrant ssh
The list of available updates is more than a week old.
To check for new updates run: sudo apt update

        ,u@@E@@E@@>,         
    .;EBBBBBBBBBBBBBBE@       
   p@BB@5EBBBBBBBBBBBBBB@     Packer.io built VM maintained by the Application
 ,EBBBBBB@@BBBBBBBBBBBBBBBL   Development Team, Centre for Ecology & Hydrology
 @B██████BB██████BB██BB██BB, 
EBB██BBBBBB██@BBBBB██BB██BBE 
EBB██BBBBBB████BBBB██████BBB 
(BB██BBBBBB██BB@BBB██BB██BBE  Version:    Ubuntu 22.04.1 LTS
 EB██████BB██████@B██BB██BB   Built:      2022-12-08
  EBBBBBBBBBBBBBB@@BBBBBBE"   Management: puppet
   "EBBBBBBBBBBBBBB@@B@@P     Repository: https://github.com/NERC-CEH/ubuntu
     "tEBBBBBBBBBBBBBb"      
         "*CehP*"^"          
vagrant@vagrant:~$ 

→自動ログインされました。

-

操作してみる:

vagrant@vagrant:~$ uname -r
5.15.0-56-generic
vagrant@vagrant:~$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.1 LTS"

-

ログアウト:

vagrant@vagrant:~$ exit
logout
ubn@ubn-box:~/ダウンロード/vm/ubn2204$ 

→ホストOS のプロンプトに戻りました。

-


9). 「vagrant ssh」の設定情報を表示:

vagrant ssh」でなく、「ssh」コマンドで接続するときに、ssh 接続に必要な情報(「vagrant ssh」の設定情報)を表示します:

接続できなかったり、「端末」画面以外の「ssh クライアント」で接続するときとか、

ssh 接続時の入力の手間を減らすために、設定ファイルの「~/.ssh/config」に反映(出力)させるときに使えます。

-

仮想マシン」が起動していて、該当の「作業フォルダ」で実行しないと使えません:

-

仮想マシン」が作成されていない「作業フォルダ」で実行した場合:
現在の設定を表示:
$ cd ~/ダウンロード/vm/test3
$ vagrant ssh-config
The provider for this Vagrant-managed machine is reporting that it
is not yet ready for SSH. Depending on your provider this can carry
different meanings. Make sure your machine is created and running and
try again. Additionally, check the output of `vagrant status` to verify
that the machine is in the state that you expect. If you continue to
get this error message, please view the documentation for the provider
you're using.

和訳:

この Vagrant 管理マシンのプロバイダは、まだ SSH の準備ができていない
ことを報告しています。プロバイダーによっては、これは異なる意味を持ちます。

マシンが作成され実行されていることを確認して、再試行してください。
さらに、「vagrant status」の出力をチェックして、マシンが期待した状態に
あることを確認します。このエラー メッセージが引き続き表示される場合は、
使用しているプロバイダのドキュメントを参照してください。

-

起動している「仮想マシン」の「作業フォルダ」で実行した場合:
現在の設定を表示:
$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant ssh-config
Host default            ←(ssh 接続先につけた「名前」: デフォルトは default)
  HostName 127.0.0.1    ←(ssh 接続先の「ホスト名」または「IP アドレス」)
  User vagrant          ←(ユーザ名)
  Port 2222             ←(ポート番号: デフォルトは 22 )
  UserKnownHostsFile /dev/null
  StrictHostKeyChecking no
  PasswordAuthentication no
  IdentityFile /home/ubn/ダウンロード/vm/ubn2204/.vagrant/machines/default/virtualbox/private_key
  IdentitiesOnly yes
  LogLevel FATAL
  PubkeyAcceptedKeyTypes +ssh-rsa
  HostKeyAlgorithms +ssh-rsa

→「vagrant ssh-config」で出力される、ssh 接続先につけた「名前」のデフォルトは「default」です

ポート番号のデフォルトは「22」ですが、有名すぎてリスクが高いので「2222」に変更されてます

-

ssh」コマンドは、これらの表示された「ポート番号」や「秘密鍵」を指定しての ssh 接続ができますが、 「~/.ssh/config」に記述することで、それらの入力の手間を減らせます:

-

仮想マシン」で確認:
$ hostname

-

「ホストOS」で実行:
$ vagrant ssh-config --host ubn-box >> ~/.ssh/config

→「--host」で設定ファイルの「Host」行の値を「わかりやすい名前」に変更できます。

実際の「ホスト名」にする必要はありません。ラベルなので、ip アドレスを記述しても OK です。任意です。

-

ssh」コマンドで接続:
$ ssh [Tab キー 2回で、ssh 接続先として指定できる一覧が表示されます]

→「ssh」の後ろに「半角スペース」が必要です:

設定ファイルに、複数の「Host」行(ラベル)を記述しているときに便利。ひとつの記述でも表示されます。

-

$ ssh ubn-box

→「ubn-box」は、「Host」行で ssh 接続先につけた「名前」です。

-


10). 参考: 起動している「仮想マシン」に、Linux の機能の「ssh」コマンドで接続して、ログイン:

これは「Vagrant」の機能ではなく、Linux の機能です:

-

仮想マシン」の立ち上げ:

$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant up

-

ssh で接続:

$ ssh -p 2222 vagrant@localhost

→「パスワード」(vagrant) や「ポート番号」(2222) は、「vagrant up」時のメッセージ中に表示されます

もしくは、「vagrant ssh-config」で確認できます:

-

ssh 接続できると、 初回のログインの前にメッセージが表示されるので、

→「yes」Enter

-

次は、ログインのパスワードを聞いてくるので、

→パスワードは「vagrant

-

実際の操作例は、

次回の投稿〈H170-2〉の「項番 6.」を参照:

-


11). (VirtualBox の)「仮想マシン」の停止(シャットダウン):

$ cd ~/ダウンロード/vm/test3/
$ vagrant halt

もしくは、

起動している「仮想マシン」画面のメニューバーから、

仮想マシン」→「ACPI 」シャットダウン

-


12). (VirtualBox の)「仮想マシン」の再起動:

$ cd ~/ダウンロード/vm/test3/
$ vagrant halt
$ vagrant up

→初回の立ち上げではないので、「Vagrantfile」は「仮想マシン」に反映されません

-

もしくは、

$ cd ~/ダウンロード/vm/test3/
$ vagrant reload

→必ず、立ち上げたときに、「Vagrantfile」が「仮想マシン」に反映されます

-


13). (VirtualBox の)「仮想マシン」の削除:

VirtualBox マネージャ」でも削除できます:

$ cd ~/ダウンロード/vm/test3/
$ vagrant destroy

→ダウンロードされた「Box」のファイルは残っています。

-

VirtualBox に追加された「仮想マシン」のファイルを確認:
$ ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox

→削除されました。

-


14). 不要になった「Box」ファイルを一覧から削除:

-

(1). 事前に「Box」名を確認:
$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
generic/centos7             (virtualbox, 4.3.6, (amd64))  ←(注目)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

-

(2). (ホームの隠しフォルダに保存された)「Box」ファイルを削除:
$ vagrant box remove generic/centos7

-

(3). 「Box」の一覧を確認:
$ vagrant box list
:
CentOS7-test                (virtualbox, 0)
generic/fedora38            (virtualbox, 4.3.6, (amd64))
nercceh/ubuntu22.04-desktop (virtualbox, 4.0.3)

→削除されました。

-

(4). ホームの隠しフォルダを確認:
$ ls -1 ~/.vagrant.d/boxes/
:
CentOS7-test
generic-VAGRANTSLASH-fedora38
nercceh-VAGRANTSLASH-ubuntu22.04-desktop

→削除されました。

-

(5). 作業フォルダの確認:
$ ls -1A ~/ダウンロード/vm/test3
:
.vagrant
Vagrantfile

→作業フォルダは残っています。影響なし。

-


15). 参考:「Vagrantfile」を修正したときは、「.vagrant」フォルダ を削除します:

「.vagrant」フォルダを削除しないと、「vagrant up」したときに「初回の立ち上げ」と認識されず、
「Vagrantfile」の修正が「仮想マシン」に反映されません。

-

(1). 既存の「仮想マシン」を削除:
$ cd ~/ダウンロード/vm/test3/
$ vagrant destroy

-

(2). 「.vagrant」フォルダ を削除:
$ cd ~/ダウンロード/vm/test3
$ rm -r .vagrant

-

(3). 「仮想マシン」の作成と立ち上げ
$ cd ~/ダウンロード/vm/test3/
$ vagrant up

→新しい「仮想マシン」が追加されて、立ち上がります。

-

参考: 既存の「仮想マシン」の削除を忘れて、「仮想マシン」が重複したら、

既存の「仮想マシン」は「Vagrant」の管理から外れており、「Vagrant destroy」は使えないので、

  • VirtualBox マネージャ」から起動を行い、使い続ける:

 

もしくは、

 

 画面左の、管理から外れた「仮想マシン」を右クリック→「除去…」→「すべてのファイルを削除」

-


16). 参考: 既存の「仮想マシン」の「Vagrantfile」を修正してみました:

すでに「仮想マシン」が作成されており、

「作業フォルダ」に、以前の「.vagrant」フォルダが残っています:

-

(1). 「Vagrantfile」の修正:

使用するエディタは何でもかまいません。

-

$ cd ~/ダウンロード/vm/ubn2204/
$ featherpad Vagrantfile

↓ すべて置換:

# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box_url = "nercceh/ubuntu22.04-desktop"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    # Customize the amount of memory on the VM:
    vb.memory = "3840"
    vb.cpus = 2
  end
end

Ctrl+S で保存

-

説明:

プロバイダに、virtualbox を設定
マシンの起動時に VirtualBox GUI を表示
virtualbox でのメモリ指定: 3840 MB
virtualbox での CPU数: 2

-

(2). 既存の「仮想マシン」を削除:
$ vagrant destroy
(3). 「.vagrant」フォルダ を削除:
$ rm -r .vagrant
(4). 「仮想マシン」の作成と立ち上げ
$ vagrant up

→「Ubuntu」のデスクトップ画面が表示されました。

-

(5). 「仮想マシン」にて、設定が反映されたか確認:

仮想マシン」の画面の右上の「電源ボタン」→「Settings」→「About」

About 画面:

Memory   3.6 GiB

→設定が反映されています。

-

(6). 設定画面を、右上の「x」で閉じました。

-


16-2). 参考: 既存の「仮想マシン」の「Vagrantfile」を修正してみました(改訂版):

すでに「仮想マシン」が作成されてる場合に、「Vagrantfile」を修正したときの操作:

上記の「項番 16).」よりも操作が簡単:

-

(1). 「仮想マシン」は、「停止」(vagrant halt) していても、「起動」(vagrant up) していてもかまいません。

-

(2). 「Vagrantfile」の修正:

使用するエディタは何でもかまいません。

-

$ cd ~/ダウンロード/vm/ubn2204/
$ featherpad Vagrantfile

-

(3). 「vagrant reload」を実行:
$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant reload

-

仮想マシン」が「停止」(vagrant halt) していた場合は、起動されます。

仮想マシン」が「起動」(vagrant up) していた場合は、再起動されます。

→「Vagrantfile」が「仮想マシン」に反映されました。余計な「仮想マシン」は作成されません。

-


17). 参考: 「作業フォルダ」の「.vagrant」を確認:

仮想マシン」の確認:

$  ls -1 ~/'VirtualBox VMs'/
:
EndeavourOS_OpenBox
test3_default_1701354147406_49248
ubn2204_default_1701558714834_11706  ←(こちらの「仮想マシン」)

-

「作業フォルダ」の「.vagrant」を確認:

$ cd ~/ダウンロード/vm/ubn2204
$ cd .vagrant/machines/default/virtualbox/
$ ls -1A
:
action_provision
action_set_name
box_meta
creator_uid
id
index_uuid
private_key
synced_folders
vagrant_cwd

-

ファイル内容の確認:

$ cat action_provision
1.5:36501fb4-5b50-492a-a845-ba306dafbe0d

-

$ cat action_set_name
1701558715

-

$ cat box_meta

見やすく記述:

{
"name":"nercceh/ubuntu22.04-desktop",
"version":"4.0.3",
"provider":"virtualbox",
"directory":"boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3/virtualbox"
}

→「Box」のメタ情報です(下にある「参考2:」を参照)

-

$ cat creator_uid
1000

-

$ cat id
36501fb4-5b50-492a-a845-ba306dafbe0d

-

$ cat index_uuid
57704281883a494c8b94fb93554bc15b

-

$ cat private_key
-----BEGIN OPENSSH PRIVATE KEY-----
:
-----END OPENSSH PRIVATE KEY-----

-

$ cat synced_folders

見やすく記述:

{
"virtualbox":
    {
    "/vagrant":
        {
        "guestpath":"/vagrant",
        "hostpath":"/home/ubn/ダウンロード/vm/ubn2204",
        "disabled":false,
        "__vagrantfile":true
        }
    }
}

→「共有フォルダ」の(ゲスト側とホスト側の)指定

-

$ cat vagrant_cwd
/home/ubn/ダウンロード/vm/ubn2204

→「作業フォルダ」の位置。「cwd」とは「cd」のこと。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考1: 現在の「作業フォルダ」にある、「Vagrantfile」の内容:

$ cat ~/ダウンロード/vm/ubn2204/Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "nercceh/ubuntu22.04-desktop"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"   ←( 「項番 18).」を参照)
    vb.memory = "3840"
    vb.cpus = 2
  end
end

デフォルトの内容 を少しだけ修正しています(コメント行の削除と、数行の追加)。

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

参考2: 「Box」のメタ情報について:

抜粋:

"directory":"boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3/virtualbox"

-

ディレクトリ (directory) のパスは、「~/.vagrant.d/」の配下になります:

$ ls -1A ~/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3/virtualbox
:
Vagrantfile        ←(導入時用)
box.ovf
box_update_check
metadata.json
packer-virtualbox-iso-1670500096-disk001.vmdk ←(仮想マシンのイメージファイル)

→こちらにある「Vagrantfile」は導入時用です:

$ cat ~/.vagrant.d/boxes/nercceh-VAGRANTSLASH-ubuntu22.04-desktop/4.0.3/virtualbox/Vagrantfile
# The contents below were provided by the Packer Vagrant post-processor

Vagrant.configure("2") do |config|
  config.vm.base_mac = "080027E17009"
end


# The contents below (if any) are custom contents provided by the
# Packer template during image build.
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
    config.vm.define "vagrant-ubuntu2204-desktop"
    config.vm.box = "ubuntu2204-desktop"

    config.vm.provider :virtualbox do |v, override|
        v.gui = true
        v.customize ["modifyvm", :id, "--memory", 2048]   ←(「項番 18).」を参照)
        v.customize ["modifyvm", :id, "--cpus", 2]
        v.customize ["modifyvm", :id, "--vram", "256"]
        v.customize ["setextradata", "global", "GUI/MaxGuestResolution", "any"]
        v.customize ["setextradata", :id, "CustomVideoMode1", "1024x768x32"]
        v.customize ["modifyvm", :id, "--ioapic", "on"]
        v.customize ["modifyvm", :id, "--rtcuseutc", "on"]
        v.customize ["modifyvm", :id, "--accelerate3d", "on"]
        v.customize ["modifyvm", :id, "--clipboard", "bidirectional"]
    end

    ["vmware_fusion", "vmware_workstation"].each do |provider|
      config.vm.provider provider do |v, override|
        v.gui = true
        v.vmx["memsize"] = "2048"
        v.vmx["numvcpus"] = "2"
        v.vmx["cpuid.coresPerSocket"] = "1"
        v.vmx["ethernet0.virtualDev"] = "vmxnet3"
        v.vmx["RemoteDisplay.vnc.enabled"] = "false"
        v.vmx["RemoteDisplay.vnc.port"] = "5900"
        v.vmx["scsi0.virtualDev"] = "lsilogic"
        v.vmx["mks.enable3d"] = "TRUE"
        v.vmx["pref.autoFitGuestToWindow"] = "TRUE"
      end
    end
end

→(上にある「参考1: 」の)「作業フォルダ」にある、「Vagrantfile」と内容が異なることに注目:

こちらの「Box」でサポートしている「プロバイダ」(virtualboxvmware_fusion、vmware_workstation)ごとの定義が記述されてます

-


18). 参考: Virtualbox の「仮想マシン」の設定を変更する機能:

Vagrant」は、Virtualbox の「仮想マシン」を起動する直前に、Virtualbox が持つ機能である、 「仮想マシン」の設定を変更できる「VBoxManage」コマンドを呼び出せます。

「VBoxManage」コマンドで ID を必要とするコマンドの場合は、「:id」と記述すると、そのパラメータを渡せます。

-

「VBoxManage」コマンドで使えるパラメータは、

例えば、「 vb.customize ["modifyvm", :id, "--XXXXX", "XXXX"] 」の行で使えるパラメータは、

VBoxManage のガイドにある、

8.10. VBoxManage modifyvm の項目を参照:

-

(1). 「仮想マシン」は停止しておきます:

-

(2). コマンドの使用前に、「仮想マシン」の「uuid」を確認:
$ cd ~/ダウンロード/vm/ubn2204
$ cat .vagrant/machines/default/virtualbox/id
36501fb4-5b50-492a-a845-ba306dafbe0d

→改行されないので、Enter で改行

-

(3). 使用前に、「Vagrantfile」の内容を確認:
$ cd ~/ダウンロード/vm/ubn2204
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "nercceh/ubuntu22.04-desktop"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "3840"
    vb.cpus = 2
  end
end

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

-

使用例1: 「仮想マシン」のメモリサイズ(MB) の設定変更:

デフォルトは "2048"、現在の値は "3840"

-

ホストOS にて、「VBoxManage」コマンドを使ってみる:
$ VBoxManage modifyvm "36501fb4-5b50-492a-a845-ba306dafbe0d" --memory="4096"

→変更されたかは、「VirtualBox」マネージャ画面を起動して、設定画面で確認すると、
すぐに反映されます。

-

「Vagrantfile」での記述:
    v.customize ["modifyvm", :id, "--memory", "4096"]

-

記述の省略形(ショートカット):
    vb.memory = "4096"

-

実際に「Vagrantfile」を修正:
$ cd ~/ダウンロード/vm/ubn2204
$ featherpad Vagrantfile

-

    #vb.memory = "2048"
    vb.memory = "3840"

↓ 置換:

    #vb.memory = "2048"
    vb.memory = "4096"

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

-

使用例2: 「仮想マシン」のディスプレイの設定変更:

参考:

「仮想マシン」が使用するグラフィックアダプタの種類を指定します。  
「VBoxSVGA」または「VMSVGA」グラフィックスコントローラを指定するには、
「仮想マシン」に「Guest Additions」をインストールする必要があります。

-

ホストOS にて、「VBoxManage」コマンドを使って変更してみる:

コマンドの構文が誤っていないかの確認:

$ VBoxManage modifyvm "36501fb4-5b50-492a-a845-ba306dafbe0d" --graphicscontroller="vmsvga"

コマンド実行前に、「VirtualBox」マネージャ画面を起動して、設定画面で「VBoxSVGA」にでも変更しておき、

→コマンドを実行。
すぐに「VMSVGA」に変更されました。

-

「Vagrantfile」での記述:
v.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]

-

記述の省略形(ショートカット): (下記は誤り、省略形なし)
vb.graphicscontroller = "vmsvga"

→検証で、エラーします:

-

(1). 参考:「Vagrantfile」の検証でエラー:(今回のコマンドの省略形の構文はないみたい)
$ cd ~/ダウンロード/vm/ubn2204
$ vagrant validate
There are errors in the configuration of this machine. 
Please fix the following errors and try again:

VirtualBox Provider:
* The following settings shouldn't exist: graphicscontroller

和訳:

このマシンの設定にエラーがあります。
次のエラーを修正して、再試行してください。

VirtualBox プロバイダー:
* 次の設定は存在しないはずです: graphicscontroller

-

(2). 実際に「Vagrantfile」を修正:
$ cd ~/ダウンロード/vm/ubn2204
$ featherpad Vagrantfile

-

    vb.cpus = 2

↓ 下記に置換:

    vb.cpus = 2
    v.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]

-

(3). 参考:「Vagrantfile」の検証でエラー:(構文エラー)
$ vagrant validate
Vagrant failed to initialize at a very early stage:

There was an error loading a Vagrantfile. The file being loaded
and the error message are shown below. This is usually caused by
a syntax error.

Path: <provider config: virtualbox>
Line number: 14
Message: NameError: undefined local variable or method `v' for main:Object

    v.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
    ^
Did you mean?  vb

14行目を「入力ミス」しました

-

↓ 下記に修正:

    vb.cpus = 2
    #vb.graphicscontroller = "vboxvga"     ←(省略形なし)
    #vb.graphicscontroller = "vmsvga"     ←(省略形なし)
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]

-

(4). 「Vagrantfile」を検証:
$ vagrant validate
Vagrantfile validated successfully.

→成功

-

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 

-

(5). 最終的な「Vagrantfile」の内容を確認:
$ cd ~/ダウンロード/vm/ubn2204
$ cat Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "nercceh/ubuntu22.04-desktop"
  config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    vb.gui = true
    #vb.memory = "2048"
    vb.memory = "4096"
    vb.cpus = 2
    vb.customize ["modifyvm", :id, "--graphicscontroller", "vmsvga"]
  end
end

-

(6). 「vagrant reload」を実行:
$ cd ~/ダウンロード/vm/ubn2204/
$ vagrant reload

-

仮想マシン」が起動されました。

→「Vagrantfile」が「仮想マシン」に反映されました。余計な「仮想マシン」は作成されていません。

-


19). 参考: Virtualbox にて、共有したい「仮想マシン」の「Box」を作成:

-

(1). 「Vagrantfile」のある「作業フォルダ」に移動して、「vagrant package」コマンドを実行する場合:

手順は、「こちら 」を参照:

-

(2). 「仮想マシン」の ID を指定して、「vagrant package」コマンドを実行する場合:

手順は、「こちら 」を参照:

-


20). 参考: Virtualbox にて、配布された「Box」ファイルを使って、「仮想マシン」を共有:

手順は、「こちら 」を参照:

-

-


- --- - --- - --- - --- - --- - --- - --- - --- - ----- ----- ----- ----- ----- ----- -

12. 「Vagrant」コマンドの「使用例」--( 目次 )--

-

項番 11. 」の「目次」です:

「コマンド」だけでなく、「ファイル」や「用語」なども含めましました:

-


(1). 「vagrant box add」

11-1)

11-2)

-


(2). 「vagrant box list」

11-3)

11-14)

-


(3). 「vagrant init」

11-4)-2

-


(4). 「vagrant up」

11-5)

11-8)

11-12)

-


(5). 「vagrant status」

11-6)

-


(6). 「vagrant global-status」

11-7)

-


(7). 「vagrant halt」

11-11)

11-12)

-


(8). 「vagrant reload」

11-12)

11-16)-2

11-18)-使用例2-6

-


(9). 「vagrant destroy」

11-13)

-


(10). 「vagrant box remove」

11-14)-2

-


(11). 「vagrant validate」

11-18)-使用例2-1

11-18)-使用例2-3

11-18)-使用例2-4

-


(12). 「vagrant ssh

11-8)

-


(13). 「vagrant ssh-config」

11-9)

-


(14). 「ssh

11-10)

-


(15). 「Box」一覧のフォルダの「~/.vagrant.d/boxes/」

11-3)

11-3-参考1

11-例2

11-5)

-


(16). 「作業フォルダ」

11-4)

11-5)

-


(17). 「Vagrantfile」

11-4)-5

11-16)

-

11-17)-参考2

→導入時用の例:

-

11-18)-使用例2-5

→最終的な例:

-


(18). 「.vagrant」フォルダ

11-15)

11-17)

-


(19). 「rm -r .vagrant

11-16)

-


(20). 「仮想マシン」のフォルダの「~/'VirtualBox VMs'/」

11-5)

-


(21). 「共有フォルダ」

11-4)-参考

-


(22). 「-VAGRANTSLASH-」の用語

11-5-参考

-


(23). 「default」の用語

11-5-参考

-


(24). 「仮想マシン」が重複

11-15)-参考

-


(25). 「Box」のメタ情報:

11-17)-参考2

-


(26). 「VBoxManage」コマンド: 「VirtualBox」が持つコマンド

11-18)

-


(27). 「VBoxManage modifyvm …」コマンド: 「VirtualBox」の「仮想マシン」の設定を変更

11-18)-使用例1

11-18)-使用例2

-


(28). 「vb.customize ["modifyvm"…」構文

11-18)-使用例1

11-18)-使用例2

11-18)-使用例2-5

-


(29). 「PowerShell7」

11-4)-Windows11

-


(30). 「vagrant package」コマンド: 「仮想マシン」から「Box」ファイルを作成

11-19)-1

11-19)-2

-


(31). 「vagrant plugin install」コマンド: 「プラグイン」のインストール

Vagrant に「vagrant-vbguest」プラグインをインストール:

-


(32). 「Box」ファイルから「仮想マシン」を共有

11-20)

-

-


まとめ

Xubuntu 22.04.3 LTS」の「VirtualBox 7.0.10」にて、「Vagrant」をインストールして使えるように、下調べをして「覚書き」としました。

色々と試してわかったのは、

Vagrant」での「Box」と「仮想マシン」は違うということ:

vagrant box add」もしくは初回の「vagrant init」コマンドで「Box」がダウンロードされ、
それを元に、「vagrant up」コマンドで「VirtualBox」の「仮想マシン」が作られます。
作る際の指示を行う、「Vagrantfile」ファイルを作成するのが「vagrant init」コマンドです。

-

動作の確認ができていない項目もあります。確認が取れたらその都度、訂正するつもりです。

最終的には、手持ちの「仮想マシン」のイメージを「Box」として利用できればと思います。

-

-

-


-

-

    目次

-

「投稿の先頭 へ」

-

-


-

「この目次 の先頭へ」

「本編の目次 に戻る」

-