Vagrant : インストール2024/04/12 |
|
VirtualBox 等の仮想化ソフトウェアのラッパーツール Vagrant をインストールします。
主要な仮想化ソフトウェアには概ね対応していますが、当例では
VirtualBox インストール済みを前提とします。
|
|
| [1] | Vagrant をインストールしておきます。 |
|
root@dlp:~ # pkg install -y vagrant
|
| [2] | Vagrant の基本操作です。任意の一般ユーザーで利用可能です。 |
|
# 仮想マシンイメージをダウンロードして追加 # ダウンロード可能な Box は公式サイト参照 # ⇒ https://app.vagrantup.com/boxes/search freebsd@dlp:~ $ vagrant box add generic/freebsd13 --provider virtualbox
==> vagrant: A new version of Vagrant is available: 2.4.1 (installed version: 2.3.7)!
==> vagrant: To upgrade visit: https://www.vagrantup.com/downloads.html
==> box: Loading metadata for box 'generic/freebsd13'
box: URL: https://vagrantcloud.com/generic/freebsd13
==> box: Adding box 'generic/freebsd13' (v4.3.12) for provider: virtualbox
box: Downloading: https://vagrantcloud.com/generic/boxes/freebsd13/versions/4.3.12/providers/virtualbox/amd64/vagrant.box
box: Calculating and comparing box checksum...
==> box: Successfully added box 'generic/freebsd13' (v4.3.12) for 'virtualbox'!
# 初期化 (カレントパスに Vagrantfile が作成される) freebsd@dlp:~ $ vagrant init generic/freebsd13 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. # 仮想マシン起動 freebsd@dlp:~ $ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'generic/freebsd13'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'generic/freebsd13' version '4.3.12' is up to date...
==> default: Setting the name of the VM: freebsd_default_1712893189651_68795
==> 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...
vboxdrv: XXXXXXXXXXXXXXXX VMMR0.r0
vboxdrv: XXXXXXXXXXXXXXXX VBoxDDR0.r0
VMMR0InitVM: eflags=40246 fKernelFeatures=0x2 (SUPKERNELFEATURES_SMAP=1)
==> 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:
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!
# 仮想マシンの状態 freebsd@dlp:~ $ 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`. # 仮想マシンへ SSH で接続 freebsd@dlp:~ $ vagrant ssh [vagrant@freebsd13 ~]$ cat /etc/os-release NAME=FreeBSD VERSION="13.2-RELEASE" VERSION_ID="13.2" ID=freebsd ANSI_COLOR="0;31" PRETTY_NAME="FreeBSD 13.2-RELEASE" CPE_NAME="cpe:/o:freebsd:freebsd:13.2" HOME_URL="https://FreeBSD.org/" BUG_REPORT_URL="https://bugs.FreeBSD.org/" [vagrant@freebsd13 ~]$ exit # 仮想マシン停止 freebsd@dlp:~ $ vagrant halt ==> default: Attempting graceful shutdown of VM... # 仮想マシンの設定を変更したい場合は設定ファイルを編集 freebsd@dlp:~ $ vi Vagrantfile # 例として CPU 数とメモリー容量を変更 # 59 行目から以下のようにコメント解除して値を変更
# 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
|
| Sponsored Link |
|
|