<!--
{
  "availability" : [
    "macOS: 15.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FSKit",
  "identifier" : "/documentation/FSKit/FSBlockDeviceResource",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "FSKit"
    ],
    "preciseIdentifier" : "c:objc(cs)FSBlockDeviceResource"
  },
  "title" : "FSBlockDeviceResource"
}
-->

# FSBlockDeviceResource

A resource that represents a block storage disk partition.

```
class FSBlockDeviceResource
```

## Overview

A `FSBlockDeviceResource` can exist in either a proxied or nonproxied version.
Only the `fskitd` daemon creates “real” (nonproxied) instances of this class.
Client applications and daemons create proxy objects for requests, and `fskitd` opens the underlying device during the processing of the request.

This class wraps a file descriptor for a disk device or partition.
Its fundamental identifier is the BSD disk name ([`bsdName`](/documentation/FSKit/FSBlockDeviceResource/bsdName)) for the underlying IOMedia object.
However, [`FSBlockDeviceResource`](/documentation/FSKit/FSBlockDeviceResource) doesn’t expose the underlying file descriptor.
Instead, it provides accessor methods that can read from and write to the partition, either directly or using the kernel buffer cache.

When you use a `FSBlockDeviceResource`, your file system implementation also conforms to a maintenance operation protocol.
These protocols add support for checking, repairing, and optionally formatting file systems.
The system doesn’t mount block device file systems until they pass a file system check.
For an [`FSUnaryFileSystem`](/documentation/FSKit/FSUnaryFileSystem) that uses `FSBlockDeviceResource`, conform to `FSManageableResourceMaintenanceOperations`.

> Important: Don’t mix direct I/O operations (``read(into:startingAt:length:)`` and ``write(from:startingAt:length:)``) with metadata operations (``doc://FSKit/documentation/FSKit/FSBlockDeviceResource/metadataRead(into:startingAt:length:)``, ``doc://FSKit/documentation/FSKit/FSBlockDeviceResource/metadataWrite(from:startingAt:length:)``, and ``doc://FSKit/documentation/FSKit/FSBlockDeviceResource/delayedMetadataWrite(from:startingAt:length:)``) on the same range. Direct I/O bypasses the buffer cache, so mixing the two may result in stale or inconsistent data.

## Topics

### Accessing resource properties

[`bsdName`](/documentation/FSKit/FSBlockDeviceResource/bsdName)

The device name of the resource.

[`isWritable`](/documentation/FSKit/FSBlockDeviceResource/isWritable)

A Boolean property that indicates whether the resource can write data to the device.

[`blockCount`](/documentation/FSKit/FSBlockDeviceResource/blockCount)

The block count on this resource.

[`blockSize`](/documentation/FSKit/FSBlockDeviceResource/blockSize)

The logical block size, the size of data blocks used by the file system.

[`physicalBlockSize`](/documentation/FSKit/FSBlockDeviceResource/physicalBlockSize)

The sector size of the device.

### Reading and writing data

[`read(into:startingAt:length:)`](/documentation/FSKit/FSBlockDeviceResource/read(into:startingAt:length:)-4ax6s)

Synchronously reads data from the resource into a buffer.

[`readInto:startingAt:length:error:`](/documentation/FSKit/FSBlockDeviceResource/readInto:startingAt:length:error:)

Synchronously reads data from the resource into a buffer.

[`read(into:startingAt:length:)`](/documentation/FSKit/FSBlockDeviceResource/read(into:startingAt:length:)-5yozi)

Asychronously reads data from the resource into a buffer.

[`read(into:startingAt:length:completionHandler:)`](/documentation/FSKit/FSBlockDeviceResource/read(into:startingAt:length:completionHandler:))

Reads data from the resource into a buffer and executes a closure afterwards.

[`readInto:startingAt:length:completionHandler:`](/documentation/FSKit/FSBlockDeviceResource/readInto:startingAt:length:completionHandler:)

Reads data from the resource into a buffer and executes a block afterwards.

[`write(from:startingAt:length:)`](/documentation/FSKit/FSBlockDeviceResource/write(from:startingAt:length:)-2fmgt)

Synchronously writes data from from a buffer to the resource and executes a block afterwards.

[`writeFrom:startingAt:length:error:`](/documentation/FSKit/FSBlockDeviceResource/writeFrom:startingAt:length:error:)

Synchronously writes data from from a buffer to the resource and executes a block afterwards.

[`write(from:startingAt:length:)`](/documentation/FSKit/FSBlockDeviceResource/write(from:startingAt:length:)-9oa1x)

Asynchronously writes data from from a buffer to the resource.

[`write(from:startingAt:length:completionHandler:)`](/documentation/FSKit/FSBlockDeviceResource/write(from:startingAt:length:completionHandler:))

Writes data from from a buffer to the resource and executes a closure afterwards.

[`writeFrom:startingAt:length:completionHandler:`](/documentation/FSKit/FSBlockDeviceResource/writeFrom:startingAt:length:completionHandler:)

Writes data from from a buffer to the resource and executes a block afterwards.

### Reading and writing data with kernel buffer cache

[`metadataRead(into:startingAt:length:)`](/documentation/FSKit/FSBlockDeviceResource/metadataRead(into:startingAt:length:))

Synchronously reads file system metadata from the resource into a buffer.

[`metadataReadInto:startingAt:length:error:`](/documentation/FSKit/FSBlockDeviceResource/metadataReadInto:startingAt:length:error:)

Synchronously reads file system metadata from the resource into a buffer.

[`metadataWrite(from:startingAt:length:)`](/documentation/FSKit/FSBlockDeviceResource/metadataWrite(from:startingAt:length:))

Synchronously writes file system metadata from a buffer to the resource.

[`metadataWriteFrom:startingAt:length:error:`](/documentation/FSKit/FSBlockDeviceResource/metadataWriteFrom:startingAt:length:error:)

Synchronously writes file system metadata from a buffer to the resource.

[`delayedMetadataWrite(from:startingAt:length:)`](/documentation/FSKit/FSBlockDeviceResource/delayedMetadataWrite(from:startingAt:length:))

Writes file system metadata from a buffer to a cache, prior to flushing it to the resource.

[`delayedMetadataWriteFrom:startingAt:length:error:`](/documentation/FSKit/FSBlockDeviceResource/delayedMetadataWriteFrom:startingAt:length:error:)

Writes file system metadata from a buffer to a cache, prior to flushing it to the resource.

[`metadataFlush()`](/documentation/FSKit/FSBlockDeviceResource/metadataFlush())

Synchronously flushes the resource’s buffer cache.

[`asynchronousMetadataFlush()`](/documentation/FSKit/FSBlockDeviceResource/asynchronousMetadataFlush())

Asynchronously flushes the resource’s buffer cache.

[`metadataClear(_:withDelayedWrites:)`](/documentation/FSKit/FSBlockDeviceResource/metadataClear(_:withDelayedWrites:))

Clears the given ranges within the buffer cache.

[`metadataPurge(_:)`](/documentation/FSKit/FSBlockDeviceResource/metadataPurge(_:))

Synchronously purges the given ranges from the buffer cache.

[`FSMetadataRange`](/documentation/FSKit/FSMetadataRange)

A range that describes contiguous metadata segments on disk.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)