7.22. VBoxManage modifymedium

With the modifymedium command, you can change the characteristics of a disk image after it has been created.

VBoxManage modifymedium  [disk|dvd|floppy]    <uuid|filename>
                         [--type normal|writethrough|immutable|shareable|
                         [--autoreset on|off]
                         [--property <name=[value]>]
                         [--resize <megabytes>|--resizebyte <bytes>]
                         [--move <path>]
                         [--setlocation <path>]

For compatibility with earlier versions of Oracle VM VirtualBox, the modifyvdi and modifyhd commands are also supported and mapped internally to the modifymedium command.

The disk image to modify must be specified either by its UUID, if the medium is registered, or by its filename. Registered images can be listed using VBoxManage list hdds, see Section 7.4, “VBoxManage list”. A filename must be specified as a valid path, either as an absolute path or as a relative path starting from the current directory.

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 immutable hard disks only, the --autoreset on|off option determines whether the disk is automatically reset on every VM startup. See Section 5.4, “Special Image Write Modes”. By default, autoreset is on.

  • The --compact option can be used to compact disk images. Compacting removes blocks that only contains zeroes. Using this option will shrink a dynamically allocated image. 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 differencing 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. Run sdelete -z in the guest to zero the free disk space, before compressing the virtual disk image. For Linux, use the zerofree utility which supports ext2/ext3 filesystems. For Mac OS X guests, use the diskutil secureErase freespace 0 / command from an elevated Terminal.

    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 allocated format. You can use this workaround until compacting is also supported for disk formats other than VDI.

  • The --resize x option, where x is the desired new total space in megabytes enables you to change the capacity of an existing image. This adjusts the logical size of a virtual disk without affecting the physical size much.

    This option currently works only for VDI and VHD formats, and only for the dynamically allocated variants. It can only be used to expand, but not shrink, the capacity. For example, if you originally created a 10 GB disk which is now full, you can use the --resize 15360 command to change the capacity to 15 GB (15,360 MB) without having to create a new image and copy all data from within a virtual machine. Note however that this only changes the drive capacity. You will typically next need to use a partition management tool inside the guest to adjust the main partition to fill the drive.

    The --resizebyte x option does almost the same thing, except that x is expressed in bytes instead of megabytes.

  • The --move <path> option can be used to relocate a medium to a different location <path> on the host file system. The path can be either relative to the current directory or absolute.

  • The --setlocation <path> option can be used to set the new location <path> of the medium on the host file system if the medium has been moved for any reasons. The path can be either relative to the current directory or absolute.


    The new location is used as is, without any sanity checks. The user is responsible for setting the correct path.