Ubuntu 24.04 VirtualBox 仮想マシンを作成する方法

環境
Ubuntu 24.04

概要
仮想マシンを作成します。
はホスト OS と同じ Ubuntu 24.04 をインストールして仮想マシンを作成します

1.任意の仮想マシン格納ディレクトリを作成する
# mkdir /var/vbox

2. 仮想マシンを作成する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage createvm \
--name Ubuntu_2404 \
--ostype Ubuntu_64 \
--register \
--basefolder /var/vbox
Virtual machine 'Ubuntu_2404' is created and registered.
UUID: 3c33d3b4-329f-4691-95f5-e05d7f419154
Settings file: '/var/vbox/Ubuntu_2404/Ubuntu_2404.vbox'
# VBoxManage createvm \ --name Ubuntu_2404 \ --ostype Ubuntu_64 \ --register \ --basefolder /var/vbox Virtual machine 'Ubuntu_2404' is created and registered. UUID: 3c33d3b4-329f-4691-95f5-e05d7f419154 Settings file: '/var/vbox/Ubuntu_2404/Ubuntu_2404.vbox'
# VBoxManage createvm \
--name Ubuntu_2404 \
--ostype Ubuntu_64 \
--register \
--basefolder /var/vbox
Virtual machine 'Ubuntu_2404' is created and registered.
UUID: 3c33d3b4-329f-4691-95f5-e05d7f419154
Settings file: '/var/vbox/Ubuntu_2404/Ubuntu_2404.vbox'

3.仮想マシンの設定を変更する
# [ens16 は自身の環境でのインターフェース名に置き換え

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage modifyvm Ubuntu_2404 \
--cpus 4 \
--memory 8192 \
--nic1 nat \
--boot1 dvd \
--vrde on \
--vrdeport 5001
# VBoxManage modifyvm Ubuntu_2404 \ --cpus 4 \ --memory 8192 \ --nic1 nat \ --boot1 dvd \ --vrde on \ --vrdeport 5001
# VBoxManage modifyvm Ubuntu_2404 \
--cpus 4 \
--memory 8192 \
--nic1 nat \
--boot1 dvd \
--vrde on \
--vrdeport 5001

 

4.仮想マシンのストレージを設定する
# VBoxManage storagectl Ubuntu_2404 –name “Ubuntu_2404_SATA" –add sata

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage createhd \
--filename /var/vbox/Ubuntu_2404/Ubuntu_2404.vdi \
--size 20480 \
--format VDI \
--variant Standard
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 229cbe70-62e3-4232-86c7-4406aa58b083
# VBoxManage createhd \ --filename /var/vbox/Ubuntu_2404/Ubuntu_2404.vdi \ --size 20480 \ --format VDI \ --variant Standard 0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Medium created. UUID: 229cbe70-62e3-4232-86c7-4406aa58b083
# VBoxManage createhd \
--filename /var/vbox/Ubuntu_2404/Ubuntu_2404.vdi \
--size 20480 \
--format VDI \
--variant Standard
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: 229cbe70-62e3-4232-86c7-4406aa58b083
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage storageattach Ubuntu_2404 \
--storagectl Ubuntu_2404_SATA \
--port 1 \
--type hdd \
--medium /var/vbox/Ubuntu_2404/Ubuntu_2404.vdi
# VBoxManage storageattach Ubuntu_2404 \ --storagectl Ubuntu_2404_SATA \ --port 1 \ --type hdd \ --medium /var/vbox/Ubuntu_2404/Ubuntu_2404.vdi
# VBoxManage storageattach Ubuntu_2404 \
--storagectl Ubuntu_2404_SATA \
--port 1 \
--type hdd \
--medium /var/vbox/Ubuntu_2404/Ubuntu_2404.vdi

5. 仮想マシンの DVD ドライブを設定する
# 下例は事前にダウンロードした ISO ファイルを指定している

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage storageattach Ubuntu_2404 \
--storagectl Ubuntu_2404_SATA \
--port 0 \
--type dvddrive \
--medium /home/ubuntu-24.04-live-server-amd64.iso
# VBoxManage storageattach Ubuntu_2404 \ --storagectl Ubuntu_2404_SATA \ --port 0 \ --type dvddrive \ --medium /home/ubuntu-24.04-live-server-amd64.iso
# VBoxManage storageattach Ubuntu_2404 \
--storagectl Ubuntu_2404_SATA \
--port 0 \
--type dvddrive \
--medium /home/ubuntu-24.04-live-server-amd64.iso

6.設定確認
# VBoxManage showvminfo Ubuntu_2404

7.DVD ドライブを接続解除する場合は以下のコマンドを実行する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage storageattach Ubuntu_2404 --storagectl Ubuntu_2404_SATA --port 0 --device 0 --medium none
# VBoxManage storageattach Ubuntu_2404 --storagectl Ubuntu_2404_SATA --port 0 --device 0 --medium none
# VBoxManage storageattach Ubuntu_2404 --storagectl Ubuntu_2404_SATA --port 0 --device 0 --medium none

8.仮想マシンを起動します。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage startvm Ubuntu_2404 --type headless
# VBoxManage startvm Ubuntu_2404 --type headless
# VBoxManage startvm Ubuntu_2404 --type headless

仮想マシンを停止する場合は以下のコマンドを実行する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage controlvm Ubuntu_2404 poweroff
# VBoxManage controlvm Ubuntu_2404 poweroff
# VBoxManage controlvm Ubuntu_2404 poweroff

仮想マシンを削除する場合は以下のコマンドを実行する

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# VBoxManage unregistervm Ubuntu_2404
# VBoxManage unregistervm Ubuntu_2404
# VBoxManage unregistervm Ubuntu_2404

 

IT

Posted by arkgame