On Wed, Jan 18, 2017 at 3:25 AM, Ian Collins <[email protected]> wrote:

> On 01/18/17 08:31 PM, Matthias Goetzke wrote:
>
> We have a machine which temporarily got 98% full and the boot time of a
> KVM windows server has gotten quite extreme (minutes on the black part of
> the boot alone).
>
> Apart from over-allocating, we guess it might have to do with
> fragmentation of the underlying C drive (just a hunch due to the number of
> writes on C and the fact that overall fragmentation was temporarily >78%)
> since another win machine still booted up quite quickly.
>
>
>
> If a kvm disk were just a file then I could just make a copy of the C
> drive (I have enough space now) into a new file which should (in theory)
> just create new aligned blocks and once I delete the old file it should be
> defragmented mostly.
>
>
> A KVM disk is a sparse provisioned zfs volume, not a file.
>
> Part of the basic maintenance I perform on Windows KVMs is well documented
> here:
>
> https://www.maketecheasier.com/shrink-your-virtualbox-vm.
>
> You will see the REFER number for the volume reduce dramatically when you
> run sdelete.
>
> It is also fairly easy to increase the volsize of the underlying disk and
> expand your windoze partition to fill it.
>

+1 for this method with a particular caveat:
Turn on compression (I recommend LZ4) for your KVM disks, whether by simply
enabling it on the entire zones pool, or on the VM disk directly.

If compression is off, writing out blocks of zeros won't free up space in
the pool. With compression on, blocks of zeros are highly compressible and
thus do free up space.
This of course also requires deleting any snapshots you may have made that
refer to the old garbage on disk.

Step 1: Check if compression is enabled for the disk with "zfs get
compression zones/<uuid>-disk<n>"
Step 1.5: If not, turn it on with "zfs set compression=lz4
zones/<uuid>-disk<n>"
Step 2: Inside the VM, write out lots of zeros (I'm not familiar with
sdelete, but I'd imagine it works)
Step 3: Verify that you've successfully freed up disk space.

Incidentally, I have a feeling that if you zeroed things out with
compression off, you might need to write new garbage and then write new
zeros after turning compression on to free up the disk space.

For others reading this thread who use something like Linux, when I've done
this I generally just use "dd" reading from /dev/zero inside the VM to
write out a file full of zeros to get the same effect.
When using ZFS inside the VM as I have sometimes done, make sure to turn
compression off on the filesystem inside the VM so that it's actually
writing out lots of zeros for the zvol compression to notice. "zpool create
-o compression=off <poolname>/deleteme; dd if=/dev/zero bs=128k
of=/<poolname>/deleteme; zfs destroy <poolname>/deleteme"

-Nahum



-------------------------------------------
smartos-discuss
Archives: https://www.listbox.com/member/archive/184463/=now
RSS Feed: https://www.listbox.com/member/archive/rss/184463/25769125-55cfbc00
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=25769125&id_secret=25769125-7688e9fb
Powered by Listbox: http://www.listbox.com

Reply via email to