Tuesday, November 25, 2025

VirtualBox : Create Virtual Machine

 

VirtualBox : Create Virtual Machine


 

Create a Virtual Machine.
On this example, create VM to install Debian 13.

[1]Create a Virtual Machine.
# create a directory for VM

root@dlp:~# 
mkdir /var/lib/vbox
# create a VM

root@dlp:~# VBoxManage createvm \
--name Debian_13 \
--ostype Debian_64 \
--register \
--basefolder /var/lib/vbox 
Virtual machine 'Debian_13' is created and registered.
UUID: b3c73f51-a5ed-4a4d-8c5c-1b8cffa29ea4
Settings file: '/var/lib/vbox/Debian_13/Debian_13.vbox'

# modify settings for VM
# replace interface name [enp1s0] to your own environment
root@dlp:~# VBoxManage modifyvm Debian_13 \
--cpus 4 \
--memory 4096 \
--nic1 bridged \
--bridgeadapter1 enp1s0 \
--boot1 dvd \
--graphicscontroller vmsvga \
--vrde on \
--vrdeport 5001 

# configure storage for VM
root@dlp:~# VBoxManage storagectl Debian_13 --name "Debian_13_SATA" --add sata 
root@dlp:~# VBoxManage createhd \
--filename /var/lib/vbox/Debian_13/Debian_13.vdi \
--size 20480 \
--format VDI \
--variant Standard 
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: e15650f9-5de6-4522-b898-591900b66561

root@dlp:~# VBoxManage storageattach Debian_13 \
--storagectl Debian_13_SATA \
--port 1 \
--type hdd \
--medium /var/lib/vbox/Debian_13/Debian_13.vdi 

# configure DVD drive for VM
# example below, it specifies an ISO file for installation
root@dlp:~# VBoxManage storageattach Debian_13 \
--storagectl Debian_13_SATA \
--port 0 \
--type dvddrive \
--medium /home/debian-13.0.0-amd64-DVD-1.iso 

# confirm settings for VM
root@dlp:~# VBoxManage showvminfo Debian_13 
Name:                        Debian_13
Encryption:                  disabled
Groups:                      /
Platform Architecture:       x86
Guest OS:                    Debian (64-bit)
UUID:                        b3c73f51-a5ed-4a4d-8c5c-1b8cffa29ea4
Config file:                 /var/lib/vbox/Debian_13/Debian_13.vbox
Snapshot folder:             /var/lib/vbox/Debian_13/Snapshots
Log folder:                  /var/lib/vbox/Debian_13/Logs
Hardware UUID:               b3c73f51-a5ed-4a4d-8c5c-1b8cffa29ea4
Memory size:                 4096MB
Page Fusion:                 disabled
VRAM size:                   8MB
CPU exec cap:                100%
CPUProfile:                  host
Chipset:                     piix3
Firmware:                    BIOS
Number of CPUs:              4
HPET:                        disabled
PAE:                         disabled
Long Mode:                   enabled
Triple Fault Reset:          disabled
APIC:                        enabled
X2APIC:                      enabled
Nested VT-x/AMD-V:           disabled
CPUID overrides:             None
Hardware Virtualization:     enabled
Nested Paging:               enabled
Large Pages:                 disabled
VT-x VPID:                   enabled
VT-x Unrestricted Exec.:     enabled
AMD-V Virt. Vmsave/Vmload:   enabled
CPUID Portability Level:     0
Boot menu mode:              message and menu
.....
.....

# * if detach DVD, run like follows

root@dlp:~# 
VBoxManage storageattach Debian_13 --storagectl Debian_13_SATA --port 0 --device 0 --medium none

[2]Start a Virtual Machine.
root@dlp:~# VBoxManage startvm Debian_13 --type headless 
Waiting for VM "Debian_13" to power on...
VM "Debian_13" has been successfully started.

# * if stop VM, run like follows
root@dlp:~# VBoxManage controlvm Debian_13 poweroff 

# * if remove VM, run like follows
root@dlp:~# VBoxManage unregistervm Debian_13 
[3]On enabled VRDP environment, it's possible to connect with RDP.
The example below is on Windows 11.
Run Remote Desktop Client and specify [(VirtualBox Server's Hostname or IP address):(vrdeport set for the VM)] to connect to VM.
[4]After connected successfully, VM console is shown.
[5]Installation finished and Virtual Machine is running normally.

No comments:

Post a Comment