Virtualbox
Create NAT Network
vboxmanage natnetwork add --netname NAT_NAME --network 192.168.1.0/24 --dhcp on --enable
Create VM
vboxmanage createvm --name 'VM_NAME' --ostype Ubuntu_64 --register
vboxmanage modifyvm $VM_UUID --firmware efi --memory 4096 --vram 256 --cpus 4 --boot1 dvd --boot2 disk --graphicscontroller vboxsvga --clipboard-mode bidirectional
# Assign network type.
vboxmanage modifyvm $VM_UUID --nic1 bridged --nicpromisc1 allow-all --bridgeadapter1 enp34s0
vboxmanage modifyvm $VM_UUID --nic1 natnetwork --nicpromisc1 allow-all --nat-network1 NAT_NAME
# Setup vrde.
vboxmanage modifyvm $VM_UUID --vrde on --vrdeaddress 192.168.0.2 --vrdeport 3389 --vrdeauthtype external --vrdeauthlibrary default
vboxmanage createmedium disk --filename '/.../VM_DISK.vdi' --size 204800 --variant Standard
vboxmanage storagectl $VM_UUID --name sata --add sata --portcount 2
vboxmanage storageattach $VM_UUID --storagectl sata --device 0 --port 0 --type dvddrive --medium '/.../Ubuntu-22.04-64-bit.iso'
vboxmanage storageattach $VM_UUID --storagectl sata --device 0 --port 1 --type hdd --medium $DISK_UUID --nonrotational on
# Satrt VM in headless mode.
vboxheadless -s $VM_UUID --vrde on
vboxmanage startvm $VM_UUID --type headless
vboxmanage storageattach $VM_UUID --storagectl sata --device 0 --port 0 --type dvddrive --medium additions
vboxmanage storageattach $VM_UUID --storagectl sata --device 0 --port 0 --type dvddrive --medium emptydrive
Clone VM
vboxmanage clonevm OLD_VM_UUID --mode=all --name=VM_NAME --register
vboxmanage modifyvm VM_UUID --mac-address1 auto
vboxmanage modifyvm VM_UUID --vrdeport 3389
# Run this inside new vm with root.
dbus-uuidgen > /etc/machine-id
No Comments