mirror of
https://bitbucket.org/mangelo/snippets.git
synced 2024-11-22 02:41:00 +02:00
142 lines
4.5 KiB
Plaintext
142 lines
4.5 KiB
Plaintext
#### VirtualBox command line.
|
|
|
|
# Set the directory for the vms.
|
|
VBoxManage setproperty machinefolder /home/user/path/to/vms/
|
|
|
|
# See info.
|
|
VBoxManage list systemproperties
|
|
VBoxManage list hostinfo
|
|
VBoxManage list bridgedifs
|
|
VBoxManage list ostypes
|
|
|
|
# Create a vm.
|
|
VBoxManage createvm -name VMNAME
|
|
|
|
# VM in non standard directory.
|
|
mv /old/path/to/vm/VMNAME.vbox /new/path/to/vm/VMNAME.vbox
|
|
rmdir /old/path/to/vm
|
|
|
|
# Register the vm.
|
|
VBoxManage registervm /new/path/to/vm/VMNAME.vbox
|
|
|
|
# Configure the vm.
|
|
VBoxManage modifyvm VMNAME \
|
|
--ostype debian \
|
|
--memory 512 \
|
|
--vram 32 \
|
|
--acpi on \
|
|
--ioapic on \
|
|
--cpus 1 \
|
|
--pae on \
|
|
--accelerate3d off \
|
|
--accelerate2dvideo off \
|
|
--firmware bios \
|
|
--chipset piix3 \
|
|
--boot1 dvd --boot2 none --boot3 none --boot4 none \
|
|
--uart1 off --uart2 off --uart3 off --uart4 off \
|
|
--lpt1 off --lpt2 off \
|
|
--audio none \
|
|
--usb off --usbehci off \
|
|
--teleporter off \
|
|
--tracing-enabled off \
|
|
--usbcardreader off \
|
|
--autostart-enabled off \
|
|
--videocap off \
|
|
--snapshotfolder default \
|
|
--rtcuseutc on \
|
|
--mouse ps2 \
|
|
--keyboard ps2 \
|
|
--clipboard disabled \
|
|
--draganddrop disabled \
|
|
--vrde off \
|
|
--nic1 none --nic2 none --nic3 none --nic4 none --nic5 none --nic6 none --nic7 none --nic8 none \
|
|
--nictype1 Am79C970A --nictype2 Am79C970A --nictype3 Am79C970A --nictype4 Am79C970A \
|
|
--nictype5 Am79C970A --nictype6 Am79C970A --nictype7 Am79C970A --nictype8 Am79C970A \
|
|
--cableconnected1 on --cableconnected2 on --cableconnected3 on --cableconnected4 on \
|
|
--cableconnected5 on --cableconnected6 on --cableconnected7 on --cableconnected8 on \
|
|
--macaddress1 00001D3C5F00 --macaddress2 00001D3C5F01 --macaddress3 00001D3C5F02 --macaddress4 00001D3C5F03 \
|
|
--macaddress5 00001D3C5F04 --macaddress6 00001D3C5F05 --macaddress7 00001D3C5F06 --macaddress8 00001D3C5F07 \
|
|
|
|
# NIC with NAT.
|
|
VBoxManage modifyvm VMNAME --nic1 nat
|
|
|
|
# NIC host only.
|
|
VBoxManage modifyvm VMNAME --nic1 hostonly --hostonlyadapter1 vboxnet0
|
|
|
|
# NIC with udp tunnel.
|
|
VBoxManage modifyvm VMNAME --nic1 generic --nicgenericdrv1 UDPTunnel --nicproperty1 dest=127.0.0.1 --nicproperty1 dport=9000 --nicproperty1 sport=9001
|
|
|
|
# NIC bridged with real host interface.
|
|
VBoxManage modifyvm VMNAME --nic1 bridged --bridgeadapter1 eth1
|
|
|
|
# VM serial port to host unix socket.
|
|
VBoxManage modifyvm VMNAME --uart1 0x3f8 4 --uartmode1 server /tmp/uart
|
|
|
|
# VM serial port to host tcp server socket.
|
|
VBoxManage modifyvm VMNAME --uart1 0x3f8 4 --uartmode1 tcpserver 2000
|
|
|
|
# See the vm configuration.
|
|
VBoxManage showvminfo VMNAME
|
|
|
|
# Add SATA controller.
|
|
VBoxManage storagectl VMNAME --name sata --add sata --sataportcount 4 --hostiocache on --bootable on
|
|
|
|
# Add IDE controller.
|
|
VBoxManage storagectl VMNAME --name ide --add ide --controller PIIX3
|
|
|
|
# Create a hdd disk.
|
|
VBoxManage createmedium disk --filename hdddisk.vdi --size 2048 --format VDI --variant Standard
|
|
|
|
# Compact a hdd disk.
|
|
VBoxManage modifymedium hdddisk.vdi --compact
|
|
|
|
# Change hdd disk uuid.
|
|
VBoxManage internalcommands sethduuid hdddisk.vdi
|
|
|
|
# Add hdd to vm.
|
|
VBoxManage storageattach VMNAME --storagectl sata --port 0 --type hdd --mtype normal --medium FILENAME.vdi
|
|
|
|
# Add a cd/dvd to vm.
|
|
VBoxManage storageattach VMNAME --storagectl ide --port 0 --device 0 --type dvddrive --medium FILENAME.iso
|
|
|
|
# Start the vm.
|
|
VBoxManage startvm VMNAME --type headless
|
|
|
|
# Extract the cd/dvd.
|
|
VBoxManage storageattach VMNAME --storagectl ide --port 0 --device 0 --type dvddrive --medium none
|
|
|
|
# Delete the IDE controller.
|
|
VBoxManage storagectl VMNAME --name ide --remove
|
|
|
|
# Poweroff the vm.
|
|
VBoxManage controlvm VMNAME acpipowerbutton
|
|
VBoxManage controlvm VMNAME poweroff
|
|
|
|
# Remove a hdd.
|
|
VBoxManage storageattach VMNAME --storagectl sata --port 1 --type hdd --medium none
|
|
|
|
# Boot from hdd only.
|
|
VBoxManage modifyvm VMNAME --boot1 disk --boot2 none --boot3 none --boot4 none
|
|
|
|
|
|
#----- Serial port to host pipe -----
|
|
|
|
# Install socat:
|
|
apt-get install socat
|
|
|
|
# Configure the serial port in the vm.
|
|
# Select Host Pipe: /tmp/uart.
|
|
# Select create if not exist.
|
|
# Start the vm.
|
|
# In the host machine:
|
|
socat /tmp/uart -
|
|
|
|
|
|
#---- Mount a hdd vdi -----
|
|
apt-get install qemu-kvm
|
|
modprobe nbd
|
|
qemu-nbd -c /dev/nbd0 HDDFILE.vdi --> creates /dev/nbd0p1
|
|
mount /dev/nbd0p1 /mnt
|
|
umount /mnt
|
|
qemu-nbd -d /dev/nbd0
|