Skip to content

Instantly share code, notes, and snippets.

@Snack-X
Last active December 6, 2016 00:45
Show Gist options
  • Save Snack-X/6dceac9f576701becd5d to your computer and use it in GitHub Desktop.
Save Snack-X/6dceac9f576701becd5d to your computer and use it in GitHub Desktop.
VBoxManage로 VM 만들고 관리하기

1. 편의를 위한 변수

export VM="vm-name"

2. VM 디스크 생성

VBoxManage createhd --filename $VM.vdi --size <size in KB>

3. VM 생성

VBoxManage list ostypes | grep -i "^ID:"
VBoxManage createvm --name $VM --ostype <os type> --register

4. HDD, ISO

VBoxManage storagectl $VM --name "SATA Controller" --add sata --controller IntelAHCI
VBoxManage storageattach $VM --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium $VM.vdi

VBoxManage storagectl $VM --name "IDE Controller" --add ide
VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium <isofile>

5. 추가 설정

VBoxManage modifyvm $VM --memory 1024
VBoxManage modifyvm $VM --boot1 dvd --boot2 disk --boot3 none --boot4 none
VBoxManage modifyvm $VM --macaddress1 <mac>
VBoxManage modifyvm $VM --nic1 bridged --bridgeadapter1 em1

6. 원격 설정

VBoxManage setproperty vrdeextpack "Oracle VM VirtualBox Extension Pack"
VBoxManage modifyvm $VM --vrde on
VBoxManage modifyvm $VM --vrdeport <port>
VBoxManage modifyvm $VM --vrdeauthtype external

VBoxManage setproperty vrdeauthlibrary "VBoxAuthSimple"
VBoxManage internalcommands passwordhash "<password>"
VBoxManage setextradata $VM "VBoxAuthSimple/users/<username>" "<hash>"

7. 켜고 끄기

VBoxHeadless --startvm $VM &
VBoxManage controlvm $VM acpipowerbutton

8. 스냅샷

VBoxManage snapshot $VM take "<name>"
VBoxManage snapshot $VM delete "<name>"
VBoxManage clonevm $VM --snapshot "<name>" --name "<new name>" --register

9. 삭제

VBoxManage unregistervm $VM --delete

10. 게스트 확장 설치

VBoxManage storageattach $VM --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /usr/share/virtualbox/VBoxGuestAdditions.iso

(게스트에서)
apt-get install dkms build-essential linux-headers-$(uname -r)
mkdir /mnt/dvd
mount -t iso9660 -o ro /dev/cdrom /mnt/dvd
cd /mnt/dvd
./VBoxLinuxAdditions.run

11. 공유 폴더

VBoxManage sharedfolder add $VM --name <name> --hostpath <path> --automount

(게스트에서)
mount -t vboxsf <name> <path>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment