---
title: VZDiskImageStorageDeviceAttachment
framework: virtualization
role: symbol
role_heading: Class
path: virtualization/vzdiskimagestoragedeviceattachment
---

# VZDiskImageStorageDeviceAttachment

A device that stores content in a disk image.

## Declaration

```swift
class VZDiskImageStorageDeviceAttachment
```

## Overview

Overview Use a VZDiskImageStorageDeviceAttachment object to manage the storage for a disk in a virtual machine (VM). The guest operating system sees the storage as a disk, and when the guest operating system writes files to the disk, the virtual machine stores the files in the disk image you provide. The virtualization framework supports two disk image formats: Create the disk image Create disk images using diskutil, a command-line utility you can access through the Terminal app. The diskutil utility performs a number of functions. The command uses a specific structure that tells the app what function it’s performing, including many arguments documented in its online manual page documents. For more information, see the diskutil manual page by using the command man diskutil in Terminal. The command to creates disk image files you use with VMs starts with diskutil image create blank, followed by three required arguments that describe the structure, size, and location of the disk image. The general format of the command follows the pattern shown here: diskutil image create blank --fs none --format FORMAT --size SIZE IMAGE_PATH Use these parameters to specify the configuration of the disk image: warning: Using diskutil improperly can result in data loss. Most commands don’t present confirmation prompts, so check to ensure you’re writing to the volume you expect. Also, back up your data before using any of these commands. To create a RAW disk image in the file system of the host computer, open Terminal and run the following command, replacing the placeholder values with your own, for example: diskutil image create blank --fs none --format RAW --size SIZE IMAGE_PATH A best practice is to give disk images a common and easily recognizable file extension, such as .img; for example VM_Image.img. To create an ASIF image, replace RAW with ASIF, as shown here: diskutil image create blank --fs none --format ASIF --size SIZE IMAGE_PATH You can execute diskutil commands under app control to create disk images programmatically. You can also create ASIF or RAW disk images interactively using Disk Utility, a utility app that Apple provides with macOS. To create volumes with Disk Utility, open the app, then select File > New Image > Blank Image. Configure the form by selecting the disk format (either ASIF or RAW), volume size, and location for the new volume, and then click Save. For more information on using Disk Utility, see Disk Utility User Guide. Alternatively, you can create a raw disk image programmatically using the UNIX open() and truncate() standard library functions as shown here: Initialize the disk image After creating the disk image, you use it to initialize a VM’s VZDiskImageStorageDeviceAttachment object. Use the attachment object to configure the VZVirtioBlockDeviceConfiguration object that you add to your virtual machine’s configuration, as shown here:

## Topics

### Creating the attachment point

- [init(url:readOnly:)](virtualization/vzdiskimagestoragedeviceattachment/init(url:readonly:)-9qeco.md)
- [init(url:readOnly:cachingMode:synchronizationMode:)](virtualization/vzdiskimagestoragedeviceattachment/init(url:readonly:cachingmode:synchronizationmode:)-36gc5.md)
- [init(url:readOnly:cachingMode:synchronizationMode:)](virtualization/vzdiskimagestoragedeviceattachment/init(url:readonly:cachingmode:synchronizationmode:)-36gc5.md)

### Getting the disk image details

- [url](virtualization/vzdiskimagestoragedeviceattachment/url.md)
- [isReadOnly](virtualization/vzdiskimagestoragedeviceattachment/isreadonly.md)
- [cachingMode](virtualization/vzdiskimagestoragedeviceattachment/cachingmode.md)
- [synchronizationMode](virtualization/vzdiskimagestoragedeviceattachment/synchronizationmode.md)

### Initializers

- [init(URL:readOnly:)](virtualization/vzdiskimagestoragedeviceattachment/init(url:readonly:)-498l.md)
- [init(URL:readOnly:cachingMode:synchronizationMode:)](virtualization/vzdiskimagestoragedeviceattachment/init(url:readonly:cachingmode:synchronizationmode:)-3wk02.md)
- [init(diskImage:cachingMode:synchronizationMode:)](virtualization/vzdiskimagestoragedeviceattachment/init(diskimage:cachingmode:synchronizationmode:).md)

## Relationships

### Inherits From

- [VZStorageDeviceAttachment](virtualization/vzstoragedeviceattachment.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Attachment points

- [VZDiskBlockDeviceStorageDeviceAttachment](virtualization/vzdiskblockdevicestoragedeviceattachment.md)
- [VZNetworkBlockDeviceStorageDeviceAttachment](virtualization/vznetworkblockdevicestoragedeviceattachment.md)
- [VZStorageDeviceAttachment](virtualization/vzstoragedeviceattachment.md)
