Advertisement
Guest User

Untitled

a guest
Mar 26th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. Create/Manage VirtualBox VMs from the Command Line
  2. Note to self, here’s a quick recipe for creating a Virtual Machine using the VirtualBox command line,
  3.  
  4. Create the VM,
  5.  
  6. VBoxManage createvm --name "io" --register
  7. VBoxManage modifyvm "io" --memory 512 --acpi on --boot1 dvd
  8. VBoxManage modifyvm "io" --nic1 bridged --bridgeadapter1 eth0
  9. VBoxManage modifyvm "io" --macaddress1 XXXXXXXXXXXX
  10. VBoxManage modifyvm "io" --ostype Debian
  11. Attach storage, add an IDE controller with a CD/DVD drive attached, and the install ISO inserted into the drive,
  12.  
  13. VBoxManage createhd --filename ./io.vdi --size 10000
  14. VBoxManage storagectl "io" --name "IDE Controller" --add ide
  15.  
  16. VBoxManage storageattach "io" --storagectl "IDE Controller" \
  17. --port 0 --device 0 --type hdd --medium ./io.vdi
  18.  
  19. VBoxManage storageattach "io" --storagectl "IDE Controller" \
  20. --port 1 --device 0 --type dvddrive --medium debian-6.0.2.1-i386-CD-1.iso
  21. Starting the VM for installation,
  22.  
  23. VBoxHeadless --startvm "io" &
  24. This starts the VM and a remote desktop server. Redirect RDP port if necessary,
  25.  
  26. ssh -L 3389:127.0.0.1:3389 <host>
  27. Shutting down the VM,
  28.  
  29. VBoxManage controlvm "io" poweroff
  30. Remove install Media,
  31.  
  32. VBoxManage modifyvm "io" --dvd none
  33. Alternatively install OS using the GUI, configure it then export is as an appliance upload to the server then import it using,
  34.  
  35. VBoxManage export "io" --output ioClone.ovf
  36. VBoxManage import ioClone.ovf
  37. Starting the VM,
  38.  
  39. VBoxHeadless --startvm "io" --vrde off &
  40. This starts the VM without remote desktop support.
  41.  
  42. Delete the VM,
  43.  
  44. VBoxManage unregistervm io --delete
  45. Mount Guest Additions
  46.  
  47. VBoxManage storageattach "io" --storagectl "IDE Controller" \
  48. --port 1 --device 0 --type hdd --medium /usr/share/virtualbox/VBoxGuestAdditions.iso
  49. Install Guest Additions,
  50.  
  51. mkdir /mnt/dvd
  52. mount -t iso9660 -o ro /dev/dvd /mnt/dvd
  53. cd /mnt/dvd
  54. ./VBoxLinuxAdditions.run
  55. Adding/removing shared folders,
  56.  
  57. vboxmanage sharedfolder add "io" --name share-name --hostpath /path/to/folder/ --automount
  58. vboxmanage sharedfolder remove "io" --name share-name
  59. To mount it on the guest,
  60.  
  61. sudo mount -t vboxsf -o uid=$UID share-name /path/to/folder/share/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement