如何在无头服务器上输入无头虚拟机的命令行?

如何在无头服务器上输入无头虚拟机的命令行?

我正在 Arch Linux 上运行一个服务器,我想使用 Virtual Box 将其分成几个虚拟机。服务器和虚拟机都是无头机器,都将运行 Arch Linux。我按照 Oracle 提供的指南(我的客户操作系统不同,因此设置略有不同)和提供的文档创建了虚拟机:

设置

创建虚拟机:

输入:

vboxmanage createvm --name test --basefolder vm --ostype Arch_Linux64 --register

建立网络连接:

VBoxManage modifyvm test --nic1 bridged --bridgeadapter1 eth0 --nicpromisc1 allow-all --bridgeadapter1 eno1

创建硬盘:

vboxmanage createhd --filename vm/testhd.vdi --size 5000 --variant Fixed

添加 IDE 控制器:

vboxmanage storagectl test --name "IDE Controller" --add ide

附加高清:

vboxmanage storageattach test --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium vm/testhd.vdi 

附加 Arch Linux iso:

vboxmanage storageattach test --storagectl "IDE Controller" --port 0 --device 1 --type dvddrive --medium archlinux.iso

激活VRDE:

vboxmanage modifyvm test --vrde on

VM 结果

一旦完成,这就是 Virtual Box 描述的机器:

vboxmanage showvminfo test

Name:                        test
Groups:                      /
Guest OS:                    Arch_Linux64
UUID:                        c501670b-5b2d-451b-bcd8-b3c66845bf97
Config file:                 /home/eric/.config/VirtualBox/vm/test/test.vbox
Snapshot folder:             /home/eric/.config/VirtualBox/vm/test/Snapshots
Log folder:                  /home/eric/.config/VirtualBox/vm/test/Logs
Hardware UUID:               c501670b-5b2d-451b-bcd8-b3c66845bf97
Memory size                  128MB
Page Fusion:                 disabled
VRAM size:                   8MB
CPU exec cap:                100%
HPET:                        disabled
CPUProfile:                  host
Chipset:                     piix3
Firmware:                    BIOS
Number of CPUs:              1
PAE:                         enabled
Long Mode:                   enabled
Triple Fault Reset:          disabled
APIC:                        enabled
X2APIC:                      disabled
Nested VT-x/AMD-V:           disabled
CPUID Portability Level:     0
CPUID overrides:             None
Boot menu mode:              message and menu
Boot Device 1:               Floppy
Boot Device 2:               DVD
Boot Device 3:               HardDisk
Boot Device 4:               Not Assigned
ACPI:                        enabled
IOAPIC:                      enabled
BIOS APIC mode:              APIC
Time offset:                 0ms
RTC:                         local time
Hardware Virtualization:     enabled
Nested Paging:               enabled
Large Pages:                 disabled
VT-x VPID:                   enabled
VT-x Unrestricted Exec.:     enabled
Paravirt. Provider:          Default
Effective Paravirt. Prov.:   None
State:                       powered off (since 2020-07-26T14:50:34.000000000)
Graphics Controller:         VBoxVGA
Monitor count:               1
3D Acceleration:             disabled
2D Video Acceleration:       disabled
Teleporter Enabled:          disabled
Teleporter Port:             0
Teleporter Address:          
Teleporter Password:         
Tracing Enabled:             disabled
Allow Tracing to Access VM:  disabled
Tracing Configuration:       
Autostart Enabled:           disabled
Autostart Delay:             0
Default Frontend:            
VM process priority:         default
Storage Controller Name (0):            IDE Controller
Storage Controller Type (0):            PIIX4
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  2
Storage Controller Port Count (0):      2
Storage Controller Bootable (0):        on
IDE Controller (0, 0): /home/eric/vm/testhd.vdi (UUID: 628a95cf-f6c2-4c6a-8c14-6c64e8fd4512)
IDE Controller (0, 1): /home/eric/archlinux.iso (UUID: 4b760f28-1e86-44b9-98b3-146728a9077f)
NIC 1:                       MAC: 080027CC8BB8, Attachment: Bridged Interface 'eno1', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: allow-all, Bandwidth group: none
NIC 2:                       disabled
NIC 3:                       disabled
NIC 4:                       disabled
NIC 5:                       disabled
NIC 6:                       disabled
NIC 7:                       disabled
NIC 8:                       disabled
Pointing Device:             PS/2 Mouse
Keyboard Device:             PS/2 Keyboard
UART 1:                      disabled
UART 2:                      disabled
UART 3:                      disabled
UART 4:                      disabled
LPT 1:                       disabled
LPT 2:                       disabled
Audio:                       enabled (Driver: ALSA, Controller: AC97, Codec: STAC9700)
Audio playback:              disabled
Audio capture:               disabled
Clipboard Mode:              disabled
Drag and drop Mode:          disabled
VRDE:                        enabled (Address 0.0.0.0, Ports 3389, MultiConn: off, ReuseSingleConn: off, Authentication type: null)
Video redirection:           disabled
OHCI USB:                    disabled
EHCI USB:                    disabled
xHCI USB:                    disabled

USB Device Filters:

<none>

Bandwidth groups:  <none>

Shared folders:<none>

Capturing:                   not active
Capture audio:               not active
Capture screens:             0
Capture file:                /home/eric/.config/VirtualBox/vm/test/test.webm
Capture dimensions:          1024x768
Capture rate:                512kbps
Capture FPS:                 25kbps
Capture options:             

Guest:

Configured memory balloon size: 0MB

vboxmanage guestproperty enumerate test

Name: /VirtualBox/HostInfo/VBoxVerExt, value: 6.1.0, timestamp: 1595776246189995001, flags: TRANSIENT, RDONLYGUEST
Name: /VirtualBox/VMInfo/ResumeCounter, value: 0, timestamp: 1595776246170655000, flags: TRANSIENT, RDONLYGUEST
Name: /VirtualBox/HostGuest/SysprepExec, value: , timestamp: 1595776246170655000, flags: TRANSIENT, RDONLYGUEST
Name: /VirtualBox/HostGuest/SysprepArgs, value: , timestamp: 1595776246170655000, flags: TRANSIENT, RDONLYGUEST
Name: /VirtualBox/VMInfo/ResetCounter, value: 0, timestamp: 1595776246170655000, flags: TRANSIENT, RDONLYGUEST
Name: /VirtualBox/HostInfo/VBoxRev, value: 135406, timestamp: 1595776246189995002, flags: TRANSIENT, RDONLYGUEST
Name: /VirtualBox/HostInfo/VBoxVer, value: 6.1.0, timestamp: 1595776246189995000, flags: TRANSIENT, RDONLYGUEST

运行虚拟机

我尝试使用以下命令激活虚拟机:

vboxmanage startvm test --type headless

输出

Waiting for VM "test" to power on...
VM "test" has been successfully started.

vboxheadless --startvm test

输出

Oracle VM VirtualBox Headless Interface 6.1.0
(C) 2008-2019 Oracle Corporation
All rights reserved.

我被困的地方

此时,机器似乎正在运行,但我无法通过 SSH 或任何远程桌面访问它。有人知道这是怎么回事吗?Arch Linux 的安装过程非常复杂,所以我需要能够真正进入 VM 环境并设置机器的其余部分。我该如何进入?

谢谢!

相关内容