]> git.phdru.name Git - vbox-scripts.git/blob - create
Feat(get-vbox-guestadd-extpack): Remove previously downloaded files
[vbox-scripts.git] / create
1 #! /bin/sh
2
3 if [ $# -le 1 -o $# -ge 7 ]; then
4    echo "Usage: $0 vm_name iso_file [os_type [disk_size [memory [video_mem]]]]" >&2
5    echo "Example: $0 Debian debian.iso Debian 10000 512" >&2
6    exit 1
7 fi
8
9 VM_NAME="$1"
10 ISO_IMAGE="$2"
11 VM_OS_TYPE="${3:-Linux}"
12 DISK_SIZE="${4:-1024}"
13 VM_MEM="${5:-1024}"
14 VM_VMEM="${6:-128}"
15
16 VBoxManage createvm --name "$VM_NAME" --ostype "$VM_OS_TYPE" --register &&
17 VBoxManage modifyvm "$VM_NAME" --memory "$VM_MEM" --vram "$VM_VMEM" --ioapic on &&
18
19 VBoxManage createhd --filename "$HOME/VirtualBox VMs/$VM_NAME/$VM_NAME".vdi --size "$DISK_SIZE" --format VDI &&
20 VBoxManage storagectl "$VM_NAME" --name "SATA Controller" --add sata --controller IntelAhci --bootable on &&
21 VBoxManage storageattach "$VM_NAME" --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium "$HOME/VirtualBox VMs/$VM_NAME/$VM_NAME".vdi &&
22
23 VBoxManage storagectl "$VM_NAME" --name "IDE Controller" --add ide --controller PIIX4 &&
24 VBoxManage storageattach "$VM_NAME" --storagectl "IDE Controller" --port 1 --device 0 --type dvddrive --medium "$ISO_IMAGE" &&
25 VBoxManage modifyvm "$VM_NAME" --boot1 dvd --boot2 disk --boot3 none --boot4 none &&
26
27 VBoxManage modifyvm "$VM_NAME" --nic1 nat &&
28 VBoxManage modifyvm "$VM_NAME" --natpf1 SSH,tcp,localhost,2022,localhost,22 &&
29
30 #VBoxManage showvminfo "$VM_NAME" &&
31 exec VBoxManage startvm "$VM_NAME"