0395.html 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Compact VirtualBox VM .vdi Disk Size</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Compact VirtualBox Disk,Compact VirtualBox VM,Shrink VirtualBox Disk,Reduce VirtualBox Disk Usage,VirtualBox,VDI,.vdi,Hypervisor,Virtual Disk Image,Compact,Shrink,Reduce,Trim,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Compact VirtualBox VM .vdi Disk Size">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  12. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  13. <script type="text/javascript" src="includes/js/steps.js"></script>
  14. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  15. </head>
  16. <body>
  17. <div id="gridContainer">
  18. <div class="topMargin"></div>
  19. <div id="listName" class="topMargin">
  20. <h1>Compact VirtualBox VM .vdi Disk Size</h1>
  21. </div>
  22. <div></div>
  23. <div id="content">
  24. <p><em>NOTE: This process only works on dynamically allocated virtual disks. If you&#39;re not sure, launch VirtualBox and go to File &gt; Virtual Media Manager. Select the virtual drive and view the properties</em></p>
  25. <p>Create backups of virtual disks before attempting these steps</p>
  26. <h2>Compacting Windows Guest VM</h2>
  27. <ol>
  28. <li>Launch the Windows VM</li>
  29. <li>Inside the VM, launch a web browser and download the sdelete utility <a href="https://technet.microsoft.com/en-us/sysinternals/bb897443" target="_blank">Download</a></li>
  30. <li>Extract the downloaded sdelete .zip file</li>
  31. <li>Copy sdelete.exe for 32-bit OS or sdelete64.exe for 64-bit OS to the C:\Windows directory</li>
  32. <li>Launch Command Prompt by right clicking the Start button &gt; Run &gt; type cmd &gt; Press Enter</li>
  33. <li>Run the following command to zero out the free space on the disk, replace the drive letter to target additional drives
  34. <div class="codeBlock">sdelete64.exe c: -z</div>
  35. </li>
  36. <li>Once the process completes, shutdown the VM</li>
  37. </ol>
  38. <h2>Compacting Linux Guest VM</h2>
  39. <ol>
  40. <li>Download the SystemRescue live disc <a href="https://www.system-rescue.org/Download/" target="_blank">Download</a></li>
  41. <li>Launch VirtualBox Manager</li>
  42. <li>Right click the VM to be compacted &gt; Settings</li>
  43. <li>Select Storage on the left hand side</li>
  44. <li>Select the optical disc drive</li>
  45. <li>Click the disk selection icon &gt; Choose a disk file...</li>
  46. <li>Navigate to the downloaded SystemRescue .iso file</li>
  47. <li>Click Open and OK to close the settings</li>
  48. <li>Right click the VM &gt; Start &gt; Normal Start</li>
  49. <li>Press Enter to boot SystemRescue using default options</li>
  50. <li>Once SystemRescue has finished booting, run the following commands
  51. <div class="codeBlock"># list the attached disks<br />
  52. fdisk -l<br />
  53. # find the disk to be compacted<br />
  54. # usually listed as /dev/mapper/....<br />
  55. # run the following, replacing the drive identifier as needed<br />
  56. zerofree -v /dev/mapper/<br />
  57. # after zerofree completes, shutdown the VM<br />
  58. shutdown now</div>
  59. </li>
  60. <li>Go back into the VM settings and remove the attached SystemRescue .iso</li>
  61. </ol>
  62. <h2>Compacting the Virtual Disk</h2>
  63. <ol>
  64. <li>Launch VirtualBox Manager on the host device</li>
  65. <li>Right click the VM to be compacted &gt; Show in Explorer</li>
  66. <li>Right click in the white space &gt; Open PowerShell window here...</li>
  67. <li>Run the following command, replacing the file name of the virtual disk
  68. <div class="codeBlock">&quot;%programfiles%\Oracle\VirtualBox\vboxmanage.exe&quot; modifymedium disk &quot;name_of_disk.vdi&quot; --compact</div>
  69. </li>
  70. </ol>
  71. </div>
  72. </div>
  73. </body>
  74. </html>