-
-
Save bs135/600ed563450661c1836d2e48523ff69b to your computer and use it in GitHub Desktop.
Automatically create and start a Debian VM on VirtualBOX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MACHINENAME=$1 | |
# Download debian.iso | |
if [ ! -f ./debian.iso ]; then | |
wget https://cdimage.debian.org/mirror/cdimage/archive/11.2.0/amd64/iso-cd/debian-11.2.0-amd64-netinst.iso -O debian.iso | |
fi | |
#Create VM | |
VBoxManage createvm --name $MACHINENAME --ostype "Debian_64" --register --basefolder `pwd` | |
#Set memory and network | |
VBoxManage modifyvm $MACHINENAME --ioapic on | |
VBoxManage modifyvm $MACHINENAME --memory 1024 --vram 128 | |
VBoxManage modifyvm $MACHINENAME --nic1 nat | |
#Create Disk and connect Debian Iso | |
VBoxManage createhd --filename `pwd`/$MACHINENAME/${MACHINENAME}_DISK.vdi --size 80000 --format VDI | |
VBoxManage storagectl $MACHINENAME --name "SATA Controller" --add sata --controller IntelAhci | |
VBoxManage storageattach $MACHINENAME --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium `pwd`/$MACHINENAME/${MACHINENAME}_DISK.vdi | |
VBoxManage storagectl $MACHINENAME --name "IDE Controller" --add ide --controller PIIX4 | |
VBoxManage storageattach $MACHINENAME --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium `pwd`/debian.iso | |
VBoxManage modifyvm $MACHINENAME --boot1 dvd --boot2 disk --boot3 none --boot4 none | |
#Enable RDP | |
VBoxManage modifyvm $MACHINENAME --vrde on | |
VBoxManage modifyvm $MACHINENAME --vrdemulticon on --vrdeport 10001 | |
#Start the VM | |
VBoxHeadless --startvm $MACHINENAME |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment