With the modifyhd
command, you can
change the characteristics of a disk image after it has been
created:
VBoxManage modifyhd <uuid>|<filename> [--type normal|writethrough|immutable|shareable| readonly|multiattach] [--autoreset on|off] [--compact] [--resize <megabytes>|--resizebyte <bytes>]
Despite the "hd" in the subcommand name, the command works with all disk images, not only hard disks. For compatibility with earlier versions of VirtualBox, the "modifyvdi" command is also supported and mapped internally to the "modifyhd" command.
The following options are available:
With the --type
argument, you
can change the type of an existing image between the normal,
immutable, write-through and other modes; see Section 5.4, “Special image write modes” for details.
For immutable (differencing) hard disks only, the
--autoreset on|off
option
determines whether the disk is automatically reset on every VM
startup (again, see Section 5.4, “Special image write modes”). The default
is "on".
With the --compact
option,
can be used to compact disk images, i.e. remove blocks that only
contains zeroes. This will shrink a dynamically expanding image
again; it will reduce the physical size of the
image without affecting the logical size of the virtual disk.
Compaction works both for base images and for diff images created as
part of a snapshot.
For this operation to be effective, it is required that free
space in the guest system first be zeroed out using a suitable
software tool. For Windows guests, you can use the
sdelete
tool provided by Microsoft.
Execute sdelete -c
in the guest to
zero the free disk space before compressing the virtual disk
image.
Please note that compacting is currently only available for VDI images. A similar effect can be achieved by zeroing out free blocks and then cloning the disk to any other dynamically expanding format. You can use this workaround until compacting is also supported for disk formats other than VDI.
The --resize option allows you to expand the capacity of an existing image; this increases the logical size of a virtual disk without affecting the physical size much.[33] This currently works only for the VDI and VHD formats, and only for the dynamically expanding variants. For example, if you originally created a 10G disk which is now full, you can use the --resize command to add more space to the virtual disk without having to create a new image and copy all data from within a virtual machine.