Virtual Box (2) Add and Manage VMs

1. Install extension pack

Check the version number:

Bash
1
vboxmanage |more

For example, I am 6.1.38-153438, just in

http://download.virtualbox.org/virtualbox/

Find the corresponding version, download, install, and enable:

Bash
1
2
3
4
5
6
7
cd ~
mkdir virtualbox
cd virtualbox
wget http://download.virtualbox.org/virtualbox/6.1.38/Oracle_VM_VirtualBox_Extension_Pack-6.1.38-153438.vbox-extpack
vboxmanage extpack install Oracle_VM_VirtualBox_Extension_Pack-6.1.38-153438.vbox-extpack
vboxmanage list extpacks
vboxmanage setproperty vrdeextpack "Oracle VM VirtualBox Extension Pack"

2, virtual disk

execute first

Bash
1
vboxmanage list ostypes

Check the code of each operating system, for example, Windows Server 2019 is Windows2019_64.

Create a Windows Server 2019 virtual machine, create a 40GB virtual disk, and bind the controller:

Bash
1
2
3
4
5
6
7
8
9
# create a virtual machine
vboxmanage createvm --name win2019 --ostype "Windows2019_64" --register

# create disk
vboxmanage create medium disk --filename win-1.vdi --size 40960
vboxmanage storagectl win2019 --name "SATA Controller" --add sata --controller IntelAHCI
vboxmanage storagectl win2019 --name "IDE Controller" --add ide
vboxmanage storageattach win2019 --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium win-1.vdi

3, ISO image

First download the Windows image:

Windows Server ISO image
https://blog.tsinbei.com/archives/893/

The download speed is very fast, no matter domestic or foreign, the speed is stable at 15MB/s.

Taking Windows Server 2019 Essentials as an example, the image is renamed to 2019_es.iso:

Bash
1
2
3
4
5
6
# Bind to DVD
vboxmanage storageattach win2019 --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium "2019_es.iso"

# set disk item
vboxmanage modifyvm win2019 --boot1 disk --boot2 dvd --boot3 none --boot4 none

4, boot

Install the graphics card management tool:

Bash
1
yum install pciutils

View video memory:

Bash
1
lspci | grep -i vga

Write down the output address in the form 00:0x.0, execute:

Bash
1
lspci -v -s 00:0x.0

You can check the memory size, for example, it is 32M for me.

First set to 4-core CPU, 4GB running memory, 16M video memory, and other settings:

Bash
1
2
vboxmanage modifyvm win2019 --cpus 4 --memory 4096 --vram 16 --hwvirtex on
vboxmanage modifyvm win2019 --ioapic on

Set the remote connection port to 33389 (the default is 3389, it may be already occupied)

Bash
1
2
vboxmanage modifyvm win2019 --vrde on --vrdeport 33389
vboxmanage startvm win2019 --type=headless

Then you can use the remote desktop connection of the computer through IP:33389, connect to the server, and install the system.

Note:
The Android version of Remote Desktop Client does not support connecting to this RDP, but after the system is installed, the built-in RDP of the system can be connected.

After the system is installed, user extensions can be installed:

Bash
1
2
wget http://download.virtualbox.org/virtualbox/6.1.38/VBoxGuestAdditions_6.1.38.iso
vboxmanage storageattach win2019 --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium "VBoxGuestAdditions_6.1.38.iso"

After starting, click this DVD in the resource manager, click the corresponding system architecture installation package, restart Windows after the installation is complete, and the problem of two cursors appearing in the (possible) remote desktop connection can be solved.

5, port mapping

After the system is installed, Windows Server enables remote desktop by default, while Windows 7/8/8.1/10/11 needs to enable remote desktop in the control panel/settings.

implement:

Text
1
VBoxManage modifyvm "win2019" --natpf1 "mstsc, tcp,,23389,,3389"

Map port 3389 of Windows to port 23389 of the host.

6, other operations

can use

Bash
1
vboxmanage controlvm win2019 poweroff

Shutdown, but it is recommended to click "Shutdown" in the virtual machine.

After configuring the remote desktop, for safety, you can close VRDE:

Bash
1
VBoxManage modifyvm win2019 --vrde off

Virtual Box (2) Add and Manage VMs

https://blog.tsinbei.com/en/archives/664/

Author
Hsukqi Lee
Posted on

2022-12-13

Edited on

2022-12-13

Licensed under

CC BY-NC-ND 4.0

Comments

Name
Mail
Site
None yet