Post

💣 Shrinking a Kali or Parrot OS VirtualBox Disk (VDI)

💣 Shrinking a Kali or Parrot OS VirtualBox Disk (VDI)

🧩 How to Shrink a Kali or Parrot OS VirtualBox Disk (VDI) Safely

This guide helps you reduce the size of a VirtualBox VDI disk after your Linux guest (Kali or Parrot) starts occupying too much space on Windows.


🧭 Step 1: Check Your Disk Layout

1
lsblk

Take note of the partition that holds / (root). In my case, it’s:

1
/dev/sda1 on / 

image

🧹 Step 2: Clean Unused Files

Run these commands in your Kali or Parrot terminal:

1
2
3
sudo apt autoremove -y
sudo apt clean
sudo journalctl --vacuum-time=3d

This removes unnecessary packages, cleans cache, and truncates old logs.


💾 Step 3: Fill Free Space with Zeros (Prepares for Compression)

In your Linux VM, run:

1
2
3
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo sync
sudo rm -f /EMPTY

image

⚠️ The dd command will fill your disk to 100% temporarily — that’s expected. Once it errors with “No space left on device”, continue.

This replaces all unused space with zeros, which makes compression more effective.


🧰 Step 4: (Optional) Use Zerofree for EXT Partitions

If your root filesystem is ext4, you can use zerofree — but since your system uses Btrfs, skip this step.

If you ever work with ext4, do this instead:

  1. Boot from a Live CD (Kali or Ubuntu ISO).
  2. Open terminal and find your root partition (e.g. /dev/sda1).
  3. Run:

    1
    
    sudo zerofree -v /dev/sda1
    

🧩 Step 5: Compact the VDI from Windows Host

After shutting down your VM, open Command Prompt as Administrator and run:

cd "C:\Program Files\Oracle\VirtualBox"
VBoxManage modifymedium "C:\Users\<Your username>\VirtualBox VMs\Parrot-Os\Parrot-Os.vdi" --compact

Adjust the .vdi path to match your VM’s location.

If VBoxManage is not recognized, add VirtualBox to your PATH or run the command from the folder where it’s installed.


🧾 Step 6: Verify the Space Reduction

Go to your VM folder on Windows and check the VDI file size before and after compacting. You should see a noticeable decrease.


✅ Optional Tips

  • Take a snapshot before doing this, just in case.
  • Disable automatic snapshots in VirtualBox if disk size grows again.
  • Use btrfs filesystem df / to check actual space usage inside the VM.

🔒 Summary

StepActionPurpose
1Check partitionsIdentify mounted disk
2Clean junkFree real space
3Write zerosPrepare free space for compression
4Use Zerofree (optional)EXT4 optimization
5Compact VDIPhysically reduce file size
6VerifyConfirm reduction

Now your Kali or Parrot VDI should take much less space on your Windows host.

This post is licensed under CC BY 4.0 by the author.