---
title: "init(fileHandle:readOnly:synchronizationMode:)"
framework: virtualization
role: symbol
role_heading: Initializer
path: "virtualization/vzdiskblockdevicestoragedeviceattachment/init(filehandle:readonly:synchronizationmode:)"
---

# init(fileHandle:readOnly:synchronizationMode:)

Creates a new block storage device attachment from a file handle and with the specified access mode, synchronization mode, and error object that you provide.

## Declaration

```swift
init(fileHandle: FileHandle, readOnly: Bool, synchronizationMode: VZDiskSynchronizationMode) throws
```

## Parameters

- `fileHandle`: The doc://com.apple.documentation/documentation/Foundation/FileHandle to a block device to attach to this VM.
- `readOnly`: A Boolean value that indicates whether this disk attachment is read-only; otherwise, if the file handle allows writes, the device can write data into it.
- `synchronizationMode`: The doc://com.apple.virtualization/documentation/Virtualization/VZDiskSynchronizationMode value that defines how the disk synchronizes with the underlying storage when the guest operating system flushes data.

## Discussion

Discussion note: The disk attachment retains the file handle, and the handle must be open when the virtual machine starts. The readOnly parameter affects how the Virtualization framework exposes the disk to the guest operating system by the storage controller. If you intend to use the disk in read-only mode, it’s also a best practice to open the file handle as read-only.
