3 ms·
I think Optimize-VHD will do the same thing as messing with diskpart. It's a shame you can't just turn on live TRIM support. This kind of disk image is a bunc
by Dylan16807 1y ago
I think Optimize-VHD will do the same thing as messing with diskpart.
It's a shame you can't just turn on live TRIM support.
This kind of disk image is a bunch of multi-megabyte blocks of data, plus a list of where each block goes on the virtual disk. Implementations can support TRIM by deleting the block that's zeroed and moving the block at the end of the file into that spot. VirtualBox can do this, shrinking the file when the guest OS TRIMs, but Hyper-V can't.
- wtallis 1y agoIt seems like just using a sparse file would make things simpler. I guess there would be potential inefficiency when you try to move the VM to another drive, but for just storing and using the VM in place it doesn't seem like this has to be hard: a TRIM inside the VM gets translated into a hole punch in the disk image file, which gets translated into a TRIM sent to the underlying storage.
- Dylan16807 1y agoSparse files would be useful but I'm pretty sure sparse files on NTFS always reserve their full size. Eating 1TB of free space for my ext4.vhdx is a non-starter.
- wtallis 1y agoBased on https://learn.microsoft.com/en-us/windows/win32/fileio/sparse-files https://learn.microsoft.com/en-us/windows/win32/fileio/spars... and subsequent links, it sounds like sparse files count against disk quotas as if they weren't sparse, but otherwise sparse files actually work on NTFS. If sparse files didn't save on actual space allocations, it would simply be a lie to call them sparse files. Granted, that's totally something Microsoft would do, and has done for other features they lack, but that doesn't seem to be the case here.
- banana_giraffe 1y agohttps://gist.github.com/Q726kbXuN/c80028aa1714032546d3b442c1d7f1c3 https://gist.github.com/Q726kbXuN/c80028aa1714032546d3b442c1... Nope, they don't eat up space. One of the fun side effects of sparse files on NTFS is calling WriteFile on the sparse file can lead to an ERROR_DISK_QUOTA_EXCEEDED error, which applications tend to not expect.
- bayindirh 1y agorsync in Linux can move sparse files as efficiently as possible, but I don't know if there's an equivalent in Windows. It'd be very strange if there is not.
- mjmas 1y agoas far as i know robocopy should
- vrighter 1y agoand the vhdx format already allows for this too. You can mark a block as "present, but zeroed out" (contents of never accessed blocks is undefined). These types of blocks don't have an actual block of data in the file, but still have well defined semantics.