Last active
June 26, 2018 18:39
-
-
Save ryo1kato/8205791 to your computer and use it in GitHub Desktop.
clean cache and zerofill unused filesystem space for VirtualBox *.vdi image files
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/sh | |
| # | |
| # clean cache and zerofill unused filesystem space for VirtualBox *.vdi image files | |
| # | |
| set -ue | |
| set -x | |
| sudo apt-get clean | |
| if ! type pv > /dev/null 2>&1 | |
| then | |
| sudo apt-get install pv | |
| fi | |
| pv /dev/zero | sudo dd of=/zero || true | |
| sudo rm -f /zero | |
| set +x | |
| echo 'Zero clear of the VM filesystem have done. | |
| (1) Shutdown this VM. | |
| (2) On HOST machine, run modifyhd --compact command like: | |
| $ VBoxManage modifyhd DISK.vdi —compact' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VBoxManage: error: Could not find file for the medium '/Users/viditgoyal/DISK.vdi' (VERR_FILE_NOT_FOUND)
VBoxManage: error: Details: code VBOX_E_FILE_ERROR (0x80bb0004), component MediumWrap, interface IMedium, callee nsISupports
VBoxManage: error: Context: "OpenMedium(Bstr(pszFilenameOrUuid).raw(), enmDevType, enmAccessMode, fForceNewUuidOnOpen, pMedium.asOutParam())" at line 179 of file VBoxManageDisk.cpp