This is a port of libvfn for macOS and implemented into xNVMe. It utilizes DriverKit to hook an external PCI NVMe device (through PCIDriverKit), and allows user-space applications to take control of the device.
It also registers as a block storage device, which supports Disk Utility, formating, mounting etc.
This is not suitable for production, as it requires disabling SIP, and everything has to be self-signed. The code might also be buggy or have improper memory management, as this is just a proof-of-concept at this point.
Consider this a beta release. It works fine for prototyping, testing, and development.
Although it's a port of libvfn, there is no way of running any of the example code from the libvfn project, as they heavily depend on Linux-only APIs. Instead, MacVFN has been implemented in xNVMe as a reference solution. All the examples from xNVMe should work.
- Timeouts
InterruptsRegister withBlockStorageDeviceDriverKit
These are the basic steps to build and install the driver:
- Disable SIP
- Run
systemextensionsctl developer onto allow System Extensions from any directory - Identify the newest or matching "tagged xNVMe version" of MacVFN (or go with
master) - Git clone this version of the repo with submodules:
git clone --recurse-submodules --branch xnvme_vX.Y.Z https://github.com/SamsungDS/MacVFN.git - In MacVFN, run
make build install kill log, approve system extension and type sudo-password as needed - Clone xNVMe with the
nextbranch:git clone -b next https://github.com/xnvme/xnvme - In xNVMe, run
make config build install - Check your NVMe device enumerates
xnvme enum - Then take the 'uri' and run a command:
xnvme idfy MacVFN-1234ABCD --cns 0 --be=driverkit - Or two
xnvme_single_sync MacVFN-1234ABCD - Or three
xnvme_single_async MacVFN-1234ABCD
MacVFN also registers as a block storage device. Verify that the drive appears in Disk Utility. You can use the NVMe device just like with the native NVMe driver, while retaining the ability to send custom commands. Just be careful, as sending custom writes to the drive will easily corrupt the filesystem, if not done properly.
Optionally, you can clone and build fio with xNVMe support:
- Git clone fio:
git clone https://github.com/axboe/fio - Install GNU-make:
brew install make - Use
gmaketo build it:gmake -j - Run a test:
./fio --name=test1 --iodepth=64 --rw=write --bs=512 --size=1GB --loops=1 --numjobs=1 --direct=1 --ioengine=xnvme --filename=MacVFN-1234ABCD --thread=1 --xnvme_dev_nsid=1 --xnvme_be=driverkit --xnvme_sync=driverkit --xnvme_async=driverkit --verify=crc32