หลังจากพยายามทดสอบการใช้งาน VirtualBox แบบไม่พึ่ง Graphic จุดประสงค์หลักก็คือ ติดตั้ง Server ที่จะใช้ VM หลายๆ ตัวบนนั้น โดยใช้ VirtualBox แต่ไม่อยากเปิด Graphic ไว้ที่ Server จากการทดสอบก็พอเป็นเรื่องเป็นราวดังนี้
- พบว่ายังต้องลง pkgs ที่พ่วงสำหรับลง VirtualBox อีกหลายตัวเหมือนกัน
- ต้องเรียนรู้คำสั่งเพื่อควบคุม VirtualBox ผ่านทาง command line แต่มี doc ให้แบบละเอียดพอสมควร
- ถ้าให้ง่ายๆ ต้องลงจากที่ง่ายๆ ไปก่อนแล้วค่อยไป import เข้า
- ถ้าติดตั้งบน Server เลยก็สนุกดีผ่านทาง Remote Desktop บน OS X ใช้ของมันเองไม่ Work ต้องหามาลง ชื่อว่า Microsoft Remote Desktop ของ Microsoft เอง
- ทำงานผ่าน Remote Desktop รู้สึกว่าช้ามาก
- เจอปัญหา Board Atom ที่ใช้ไม่ Support VT-X เลยลง Guest OS แบบ 32 bit เท่านั้น
คร่าวๆ สำหรับสิ่งที่พบเจอคราวนี้มาดูขั้นตอนเบื้องต้นสำหรับการใช้งาน VirtualBox แบบ Command Line กัน
- สร้าง VM ขึ้นมาใหม่ให้ชื่อว่า vm0
VBoxManage createvm –name “vm0” –register
ผลออกมาประมาณนี้
Virtual machine 'vm0' is created and registered. UUID: 53d7f0de-ced7-4c53-b930-2d29400d69bd Settings file: '/root/VirtualBox VMs/vm0/vm0.vbox'
- กำหนดรายละเอียดของ VM ว่าจะให้มีอะไรเบื้องต้นยังไง
VBoxManage modifyvm "vm0" --memory 512 --acpi on --boot1 dvd --nic1 bridged --bridgeadapter1 eth0 --ostype Redhat
- สร้าง Virtual Disk สำหรับเป็น HDD ให้กับ VM
VBoxManage createvdi –filename ~/VirtualBox\ VMs/vm0/vm0-disk01.vdi –size 10000
ผลออกมาประมาณนี้
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100% Disk image created. UUID: fbf6febd-44de-4b48-833f-e87a587a121a
- เพิ่ม HDD Controller ให้กับ VM
VBoxManage storagectl “vm0” –name “IDE Controller” –add ide
- Attach HDD และ CD เข้าไปยัง Controller ที่สร้างไว้ สำหรับ CD Image คือ ISO ตัวติดตั้งครับ
VBoxManage storageattach "vm0" --storagectl "IDE Controller" --port 0 --device 0 --type hdd --medium ~/VirtualBox\ VMs/vm0/vm0-disk01.vdi VBoxManage storageattach "vm0" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium /root/CentOS-6.4-i386-minimal.iso
- สำหรับเครื่องที่มีปัญหาเรื่อง CPU ไม่ Support VT-x ให้ปิดก่อนครับ แต่ส่วนใหญ่มัน Support หมดแหละ
VBoxManage modifyvm “vm0” –hwvirtex off
- ตรวจสอบรายละเอียดของ VM ที่เราสร้างขึ้นมา
VBoxManage showvminfo vm0
ผลที่ได้จะประมาณนี้
Name: vm0 Groups: / Guest OS: Red Hat UUID: 53d7f0de-ced7-4c53-b930-2d29400d69bd Config file: /root/VirtualBox VMs/vm0/vm0.vbox Snapshot folder: /root/VirtualBox VMs/vm0/Snapshots Log folder: /root/VirtualBox VMs/vm0/Logs Hardware UUID: 53d7f0de-ced7-4c53-b930-2d29400d69bd Memory size: 512MB Page Fusion: off VRAM size: 8MB CPU exec cap: 100% HPET: off Chipset: piix3 Firmware: BIOS Number of CPUs: 1 PAE: on Long Mode: on Synthetic CPU: off CPUID overrides: None Boot menu mode: message and menu Boot Device (1): DVD Boot Device (2): DVD Boot Device (3): HardDisk Boot Device (4): Not Assigned ACPI: on IOAPIC: off Time offset: 0ms RTC: local time Hardw. virt.ext: off Nested Paging: on Large Pages: off VT-x VPID: on VT-x unr. exec.: on State: powered off (since 2013-12-15T10:22:45.000000000) Monitor count: 1 3D Acceleration: off 2D Video Acceleration: off Teleporter Enabled: off Teleporter Port: 0 Teleporter Address: Teleporter Password: Tracing Enabled: off Allow Tracing to Access VM: off Tracing Configuration: Autostart Enabled: off Autostart Delay: 0 Default Frontend: 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): /root/VirtualBox VMs/vm0/vm0-disk01.vdi (UUID: fbf6febd-44de-4b48-833f-e87a587a121a) IDE Controller (1, 0): /root/CentOS-6.4-i386-minimal.iso (UUID: ab3bc771-af71-4b46-8118-feef1aa5c511) NIC 1: MAC: 080027BFD1E7, Attachment: Bridged Interface 'eth0', Cable connected: on, Trace: off (file: none), Type: Am79C973, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, 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 LPT 1: disabled LPT 2: disabled Audio: disabled Clipboard Mode: disabled Drag'n'drop Mode: disabled VRDE: disabled USB: disabled EHCI: disabled USB Device Filters: <none> Available remote USB devices: <none> Currently Attached USB Devices: <none> Bandwidth groups: <none> Shared folders: <none> VRDE Connection: not active Clients so far: 0 Video capturing: not active Capture screens: 0 Capture file: /root/VirtualBox VMs/vm0/vm0.webm Capture dimensions: 1024x768 Capture rate: 512 kbps Capture FPS: 25 Guest: Configured memory balloon size: 0 MB
- ถือว่าเป็นการเสร็จพิธีปลุกเสก ตอนนี้ก็สามารถเรียกใช้งานได้แล้ว โดยแทนที่ IP ของเครื่อง Server ลงไป
VBoxVRDP -s vm0 -e “TCP/Address=10.x.x.x”
- เปิด Remote Desktop Client แล้วติดต่อเข้ามายัง IP Server ถ้าเข้าไม่ได้ก็ลองเปิด firewall ดูครับ
- ถ้าเกิดเหตุที่ไม่สามารถติดต่อหรือเข้าใช้งานได้และอยากจะปิด VM ก็ให้สั่ง
VBoxManage controlvm vm0 poweroff
ครั้งต่อๆ ไปถ้าเรา config เสร็จเรียบร้อยมี IP ในตัว VM แล้วก็ไม่จำเป็นต้องใช้ Remote Desktop แล้วนะครับ ลองเอาไปประยุกต์ใช้และเล่นกันดูครับ
แหล่งอ้างอิง
Leave a Reply