Terence Eden. He has a beard and is smiling.
Theme Switcher:

HomeAssistant - shrink a HAOS qcow2 filesystem

· 1 comment · 300 words · Viewed ~686 times

🄯 CC BY-SADigital Object Identifier10.59350/d5bqe-bpb05


Mostly notes to myself, I hope they're helpful to you too!

My HomeAssistant OS (HAOS) was originally thinly provisioned with a 30GB virtual disk stored in a qcow2 file. In theory, the file should only take up as much space as the virtual filesystem. In reality, it grows to accommodate the maximum size allowed.

My HAOS was showing only 10GB used:

Disk usage showing 10.8GB used out of 30GB.

But running ls -lh showed 32GB was allocated. To see the actual space on disk, I ran du -h haos.qcow2 which showed 28GB.

As it is 2026, I can't afford to simply buy a few more TB of SSD, so here's how to manually shrink the file so it only takes up the space it needs.

  1. Within HomeAssistant's web interface, completely shut down.
    • Settings → ⋮ → Restart Home Assistant → More options → Shut Down System
    • Screenshot showing how to restart HomeAssistant.
    • Wait a few minutes for everything to finish shutting down.
  2. Within your host Operating System, backup your existing file!
    • sudo cp haos.qcow2 haos.qcow2.bak
  3. Check the size of the disk:
    • sudo qemu-img info haos.qcow2
  4. Shrink (sparsify) the disk.
    • sudo virt-sparsify --in-place haos.qcow2
    • This may take a few moments.
  5. Check the size of the disk to make sure it has shrunk:
    • sudo qemu-img info haos.qcow2
  6. Once that has finished, you can start the virtual machine again.
    • virsh list --all to find the name of the VM.
    • virsh start haos
  7. Wait a few minutes and your HomeAssistant should come back to life. If all is well, you can delete the backup.
    • sudo rm haos.qcow2.bak

There doesn't seem to be an automated way to do this. If you do know a way to make this easier - please leave a comment in the box.


Share this post on…

One thought on “HomeAssistant - shrink a HAOS qcow2 filesystem”

What are your reckons?

All comments are moderated and may not be published immediately. Your email address will not be published.

See allowed HTML elements: <a href="" title="">
<abbr title="">
<acronym title="">
<b>
<blockquote cite="">
<br>
<cite>
<code>
<del datetime="">
<em>
<i>
<img src="" alt="" title="" srcset="" width="" height="">
<p>
<pre>
<q cite="">
<s>
<strike>
<strong>

Your post must include a link to this post.

How does this work?
To respond on your own website, write a post which contains a link to this post - then enter the URl of your page here. Learn more about WebMentions.