Created
June 14, 2014 10:59
-
-
Save jgcasta/641d7bfede84886e5a8d to your computer and use it in GitHub Desktop.
Change memory size for a running Virtual Box virtual machine
This file contains 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 | |
# | |
# ChangeVBMem.sh | |
# | |
# ver 1.0 | |
# | |
# Jose Gomez Castaño jgcasta@gmail.com | |
# | |
# Change memory size for a running virtual machine. The system will be stopped and restarted | |
# In this version, all data has to be saved before | |
# | |
# nameVB: Virtual Machine name | |
# newSize: RAM size in MB | |
# | |
# Usage: $./ChangeVBMem.sh nameVB newSize | |
# | |
name=$1 | |
newSize=$2 | |
totalMem=$(free | awk '/^Mem:/{print $2}') | |
totalMemM=$((totalMem/1000)) | |
if [ $totalMemM -lt $newSize ];then | |
echo "ERROR: The maximum memory size of your physical machine is "$totalMemM" Mb and you are choosing "$newSize" Mb, please choose a lower value for the virtual machine" | |
exit 0 | |
fi | |
VBoxManage controlvm $name poweroff | |
VBoxManage modifyvm $name --memory $newSize | |
VBoxManage startvm $name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment