Ease System Overload in Your Linux Vmware by Regaining Lost Storage Capacity Quickly
Ease System Overload in Your Linux Vmware by Regaining Lost Storage Capacity Quickly
Key Takeaways
- VirtualBox doesn’t automatically shrink Linux guest disks, but you can manually reclaim disk space by zeroing out data and compacting the volume.
- You should enable dynamic allocation in VirtualBox and back up your data before proceeding with the disk compacting process.
- Use the “dd” command to zero-out empty space in the Linux guest and then use VBoxManage to compact the virtual disk image.
VirtualBox lets you run Linux in a virtual machine, and you’ll often find your virtual disks continually growing in size, even though you’ve been clearing them of files. I’ll show you how to shrink these volumes back down to size, compacting them and saving your disk space.
Why Your VirtualBox Linux Guest Isn’t Automatically Shrinking
If you’ve used VirtualBox with Windows guests (in virtual machine terminology the “guest” is the operating system running within the virtual machine), you’re probably used to your VirtualBox disk volumes shrinking as you delete files from them, so that they only use up as much space on your physical disk as they need to contain the files in them.
This is the intended purpose of VirtualBox’s dynamic allocation feature, but it doesn’t work with Linux guests . When using a Linux guests, many users find the disks grow to their full size, and then never shrink back down as files are deleted from them.
This is due to how Linux manages its filesystems and how it interacts with its VirtualBox host. Linux doesn’t “zero out” (overwrite with empty data) files when they are deleted for performance reasons, so VirtualBox has no way to tell what data on a virtual disk is active data and which is deleted.
You can solve this issue by zeroing that data yourself, and telling VirtualBox to compact the volume, bringing it back down to its actual size. Here’s how it’s done.
How to Reclaim Disk Space From a Linux Virtual Machine in VirtualBox
The first thing you need to do to reclaim disk space from your Linux guests’ virtual disks is ensure that dynamic allocation is enabled. If it is not, you will need to convert your disk to a dynamically allocated disk .
Next, back up your virtual disk . If something goes wrong (like a mistyped command, or your power going out part way through the process), you risk losing all the data in your Linux guest.
Next, on your Linux guest run the following command in the terminal :
sudo dd if=/dev/zero of=/var/deleteme
This command will write zero’d out (empty) data to the file /var/deleteme until the disk is completely full. This overwrites all of your previously deleted files, solving the problem that Linux doesn’t overwrite deleted data automatically.
Be careful using the dd command as it will overwrite data without warning! Check your commands and paths carefully before running them.
This process could take some time depending on the size of the volume, so be patient and do not interrupt it. Once it has finished, the process will exit (possibly with an error saying that it is out of space). Once this has happened, you can delete the zeroed-out file and shut down your Linux guest:
sudo rm -rf /var/deleteme
sudo shutdown now -h
Now the unused space on your virtual disk is zeroed out and VirtualBox will be able to reclaim the space on your host by shrinking it. The final step is to use the vboxmanage command to compact the virtual disk image. Do this by running:
`vboxmanage modifymedium disk /path/to/image.vdi -compact`
You must change /path/to/image.vdi to the path of the virtual disk you want to compact. If you are on Windows, you will need to use VBoxManage.exe like so:
VBoxManage.exe modifymedium disk /path/to/image.vdi -compact
If VBoxManage.exe is not available from the command line on your Windows system, read on for instructions on how to enable it.
What Did the dd Linux Command Do?
This method for compacting a VirtualBox Linux guest utilizes the dd command to write an empty file to disk so that empty space can be identified by VirtualBox.
The dd (data duplicator) command converts and copies files, and can also be used to write data. The “if” option passed to it supplies the input file (in this case /dev/zero supplies a constant stream of zero-value data or null data). The “of” option specifies the output file, and this stream of zero data is written to it. This will continue until the disk is full as /dev/zero never stops providing null data.
Using VboxManage.exe in Windows
By default, VBoxManage.exe isn’t available on the Windows command line. You can add it by updating your Windows system path to include the VirtualBox installation directory, or calling the full path to the executable when using it:
& “C:/Path/To/VBoxManage.exe” modifymedium disk /path/to/image.vdi -compact
The “&” symbol, called the call operator, that executes the quoted command. This lets you use spaces in path to the executable.
More About Managing VirtualBox Guests
As your guests grow, you can increase the size of their virtual disks as well as reduce them . Snapshotting lets you take the state of your virtual machine at a certain point in time and save it; if you later want to go back to how things were at that exact moment (for example after testing a configuration change), you can simply roll back and everything will be as it was.
VirtualBox is a powerful virtualization tool that is used both professionally by developers to build and test software, and home users to run older software and games on modern computers, or run other operating systems without having to purchase a second machine. You can run Windows , Linux , ChromeOS , Android, and other operating systems on MacOS, Windows, and Linux Hosts.
Also read:
- [New] How to Execute Flawless WireCast Broadcasts on YouTube for 2024
- [New] Navigating Instagram's Video Limit Regulations for 2024
- [New] Time Travel Through Free Visual Storerooms for 2024
- 2024 Approved Pivotal Information in the Realm of ASMR
- Ending Dual Access to Your Camera (Error 0xA00F4243)
- Ensuring Privacy with Best Windows Crypto Apps (152 Chars)
- Essential Preparations for Revitalizing Your PC with Windows
- How to Bypass Google FRP Lock from Infinix Devices
- Instagram Videography Guide - Size Matters for 2024
- Navigating Windows XP Error Code: 0X80300024
- Overcoming Invalid Verification Error by Steam's VAC
- Personalize Your Digital Notepad: A Guide to Windows 11 Customization
- Premier Voice Recorders for Android - Comprehensive and Cost-Free for 2024
- The Ultimate Guide to Picking a Software Dependency Provider
- Thinking About Changing Your Netflix Region Without a VPN On Motorola Moto G14? | Dr.fone
- Top 7 Skype Hacker to Hack Any Skype Account On your ZTE Axon 40 Lite | Dr.fone
- Toplogiciels De Migration Sécurisés Pour Les SSDs Kingston - Guide Complet
- Tracking Windows Logins: Identifying Successes & Failures
- Unveiling Windows Registry Shortcomings: Solutions
- Title: Ease System Overload in Your Linux Vmware by Regaining Lost Storage Capacity Quickly
- Author: Joseph
- Created at : 2024-10-18 21:34:44
- Updated at : 2024-10-24 18:25:38
- Link: https://windows11.techidaily.com/ease-system-overload-in-your-linux-vmware-by-regaining-lost-storage-capacity-quickly/
- License: This work is licensed under CC BY-NC-SA 4.0.