Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shrinking the virtual disk #68

Open
mcandre opened this issue Nov 24, 2020 · 0 comments
Open

Shrinking the virtual disk #68

mcandre opened this issue Nov 24, 2020 · 0 comments

Comments

@mcandre
Copy link

mcandre commented Nov 24, 2020

(Are we already doing this in the default macinbox build?)

Hey, I noticed that some of the macinbox VM's published to Vagrant Cloud are quite large, 100 GB of virtual capacity expressed in 40 GB of host box storage. That seems excessive. Remember that a Vagrant box does not exist just once on the host, but gets copied to an instance, and then copied even more times when extending a box to create an app-specific box. Users end up needing a TB host drive or larger, or else risk quickly running out of usable space. Not to mention the errors and restarts when attempting to download such a beast over a decent Internet connection.

I'm more used to ~40 GB for solid development support, with physical size not exceeding 8 GB to 20 GB. That's including base macOS + Xcode + Ruby + Homebrew + GHC Haskell + Python 3 + MacPorts + JDK + fink + a dozen other development and analysis components. At least, those were the numbers back in Mojave. I suspect we can achieve similar savings for Catalina, unless it's just an inherently larger guest. Seems strange to see so many "macOS and nothing else" boxes online that take up 100 GB virtual, 40 GB physical.

In the past, a simple, built-in command can help to reduce waste at the end of provisioning. Unfortunately, the same command is now rejected by macOS, as Apple thinks the command would harm a physical SSD, even though our disk is in fact virtual.

$ sudo diskutil secureErase freespace 0 '/Volumes/Macintosh HD'
Erasing freespace only works on mounted and writable volumes

We may require different commands to achieve the same result, shrinking the disk image.

For VMware guests, VMware does offer a utility to shrink the disk. Ideally, we would use a hypervisor-agnostic solution. But if we can find a VirtualBox disk shrinking utility, that would be just as good.

I'm surprised that dd doesn't Just Work^TM from inside the running guest. But I wonder if Gparted, an Ubuntu install disc, or similar livecd could analyze APFS partitions and manually erase the free space as a post-VM build step, just before handing the VM off to our users. What do you think?

Worth noting that some Catalina VM's posted to Vagrant Cloud report a virtual capacity of 100 GB, with nearly 40 GB consumed by guest files. Perhaps we can remove some of this bloat. For example, in older mac VM's I would delete some of the default services, as long as I was reasonably sure they wouldn't corrupt macOS. And making sure to empty out the temp directory, other caches, and so on.

I ask, do we really need 100 GB of virtual capacity in our VM's? A virtual capacity of 40 GB to 50 GB, suitable for booting, sshd, rsyncd, and performing medium-size software application compilations, would fulfill a lot of use cases. Any user requiring more than this could attempt to resize the virtual disk, or attach a new disk, or build their own VM's with the particular capacity they require for their project needs.

@mcandre mcandre changed the title Remember to shrink the virtual disk Shrinking the virtual disk Nov 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant