LoginSignup
0
2

More than 3 years have passed since last update.

Windows 10 の VirtualBox + Vagrant 環境に於ける CentOS Stream 8 仮想マシン起動手順

Last updated at Posted at 2021-04-02

前提

今回の手順を検証した環境は以下の通り。

  • Windows 10 Pro 20H2
  • VirtualBox 6.1.18
  • Vagrant 2.2.15

手順

仮想マシン起動

  1. VirtualBox と Vagrant をインストールする。

    1. Downloads – Oracle VM VirtualBox
    2. Downloads | Vagrant by HashiCorp
  2. Windows のスタートボタンを右クリックし, コマンドプロンプトをクリックする。

  3. vagrant ディレクトリーを作成する。

    > mkdir vagrant
    
  4. 作業ディレクトリーを移動して, CentOS 用のディレクトリーを作成する。

    > cd vagrant
    > mkdir centos
    
  5. 作業ディレクトリーを移動して, Vagrant の設定ファイルを生成する。

    > cd centos
    > vagrant init
    
  6. メモ帳で設定ファイルを開き, Box を base から centos/stream8 変更する。

    > notepad Vagrantfile
    
    Vagrantfile
    --- Vagrantfile.org     2021-04-02 20:40:20.328164000 +0900
    +++ Vagrantfile 2021-04-02 20:41:36.510341300 +0900
    @@ -12,7 +12,7 @@
    
       # Every Vagrant development environment requires a box. You can search for
       # boxes at https://vagrantcloud.com/search.
    -  config.vm.box = "base"
    +  config.vm.box = "centos/stream8"
    
       # Disable automatic box update checking. If you disable this, then
       # boxes will only be checked for updates when the user runs
    
  7. 仮想マシンを起動する。ただし, Box のダウンロードが遅い場合は Box のダウンロードが死ぬほど遅い場合 を参照すること。

    > vagrant up
    

ログイン, ログアウト, シャットダウン

プロンプト記号が > の場合はコマンドプロンプトで, $ の場合は CentOS にログインした状態で実行すること。

  1. 仮想マシンにログイン (SSH 接続) する。

    > vagrant ssh
    
  2. 仮想マシンからログアウトする。

    $ exit
    
  3. 仮想マシンをシャットダウンする。

    $ sudo systemctl poweroff
    
  4. 仮想マシンがシャットダウンされていることを確認する。

    > vagrant status
    

参考文献

Box のダウンロードが死ぬほど遅い場合

多少マシになる程度の対策。

  1. Web ブラウザーを開き, CentOS Cloud images にアクセスする。
  2. VirtualBox 用 Vagrant Box のリンクをコピーする。
    • 今回は CentOS-Stream-Vagrant-8-20210210.0.x86_64.vagrant-virtualbox.box とする。
  3. Windows のスタートボタンを右クリックし, コマンドプロンプトをクリックする。
  4. ダウンロード用のディレクトリーに移動し, Box をダウンロードする。

    > cd Downloads
    > curl -LO https://cloud.centos.org/centos/8-stream/x86_64/images/CentOS-Stream-Vagrant-8-20210210.0.x86_64.vagrant-virtualbox.box
    
  5. Box を追加する。

    > vagrant box add centos/stream8 CentOS-Stream-Vagrant-8-20210210.0.x86_64.vagrant-virtualbox.box
    

他の仮想マシンを試す場合

Vagrant Cloud で検索する。

どっとはらい。

0
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
2