VirtualBox

Opened 14 years ago

Closed 8 years ago

Last modified 8 years ago

#5582 reopened enhancement (fixed)

Suggestion: allow disk image data to be aligned in VDI files, for optimal use with SSDs — at Version 2

Reported by: Donuts Owned by:
Component: other Version: VirtualBox 3.0.12
Keywords: Cc:
Guest type: other Host type: other

Description (last modified by aeichner)

First, see this blog post which has some background information: http://thunk.org/tytso/blog/2009/02/20/aligning-filesystems-to-an-ssds-erase-block-size/

In summary, the smallest chunk of data that SSDs (solid-state flash drives) can write is larger than the 512-byte size that the SSD emulates/fakes for the host computer. The smallest chunk size might be 4KB, for example. If filesystem writes are not aligned to 4KB boundaries performance will suffer, especially for first-generation SSDs.

For example, if the host computer writes 4KB to (512-byte) sectors 63 to 70, the SSD will read the 4KB corresponding to sectors 56-63, update the sector 63 data and write it to flash. Similarly with the 4KB block corresponding to sectors 64-71. This read-modify-write causes more wear on the SSD.

Windows XP and earlier (and probably most non-Windows partitioning software) by default creates the first partition starting at (512-byte) sector 63. That is an "odd" alignment, not aligned on a 1KB boundary let alone 4KB or more.

What does this have to do with VirtualBox? My suggestion is that the VDI format be updated to allow the user to specify the alignment of the data. VirtualBox would add a few sectors worth of padding before the actual data. For use with SSDs, the user could set the alignment so sector 63 is on a 4KB boundary in the VDI file. The fixed-size VDI header appears to be $600 bytes long, so an extra $C00 bytes padding would be needed in that case. Doing that might also be a minor performance win for conventional hard drives, if the host filesystem uses a 4KB cluster size. Of course the exact amount of padding to use needs to be user-configurable; for a Vista VDI it would be $A00 bytes.

Change History (2)

comment:1 by Donuts, 14 years ago

I have posted instructions on how to manually add padding to a new (dynamically-expanding) VDI file to http://forums.virtualbox.org/viewtopic.php?f=1&t=25336

Contrary to what I wrote about SSDs above, this is also relevant to conventional hard disks. The issue is that the guest filesystem clusters (typically 4KB) may not be aligned on a cluster boundary in the host partition.

comment:2 by aeichner, 8 years ago

Description: modified (diff)
Resolution: fixed
Status: newclosed

VDI images are aligned to a 1MB boundary which should be enough for the near future. Additionally the alignment for VDI images can be set by the user with vbox-img when creating a base image. Closing as fixed.

Note: See TracTickets for help on using tickets.

© 2023 Oracle
ContactPrivacy policyTerms of Use