How to Recover Deleted Files from an Encrypted ZFS dRAID1

How do you recover deleted files from an encrypted ZFS dRAID1 pool when one drive is unavailable? Using three pools on FreeBSD as examples, this article covers recovery after file deletion, destruction of a pool and its GPT partitions, and retrieval of earlier file versions from ZFS snapshots with Hetman RAID Recovery.

How to Recover Deleted Files from an Encrypted ZFS dRAID1

dRAID provides protection against drive failures within the array’s redundancy limits, but not against erroneous commands, file deletion or loss of the encryption key. In our test, we analyzed only three of the four drives and accessed the encrypted contents using a known passphrase.

Go to view
How to Recover Data from an Encrypted ZFS dRAID1 Pool

How to Recover Data from an Encrypted ZFS dRAID1 Pool

ZFS dRAID1 test storage configuration

On a FreeBSD server, we used four SSDs accessible as mfid2, mfid3, mfid4 and mfid5. We created a GPT partition table and three freebsd-zfs partitions on each drive. Partitions with the same number across the drives were combined into separate pools: pool1, pool2 and pool3.

FreeBSD: three freebsd-zfs partitions on drive mfid2
Each pool uses its own partition on each of the four drives.
ParameterTest configuration
Storage devices4 SSDs, 59G each as reported by FreeBSD
Partition layoutGPT, 3 partitions per drive, 21,160,263,680 bytes each
Partition starting LBAs2048, 41330688, 82659328
Geometry of each pooldraid1:2d:4c:1s
Ashift12 (4096 bytes)
Encryptionaes-256-gcm, keyformat=passphrase, keylocation=prompt
Recovery environmentWindows 10 in a bhyve VM, three of four drives

In the draid1:2d:4c:1s configuration, draid1 specifies one parity block per redundancy group, 2d specifies two data blocks, 4c specifies four child devices in the vdev, and 1s specifies distributed spare capacity equivalent to one child device. Since the members here are partitions, each pool’s spare capacity is equivalent to one partition, not a whole physical drive. Data, parity and spare capacity are distributed across the members. The spare speeds up redundancy restoration but does not provide a second independent parity block: dRAID1 is designed to tolerate the loss of one member.

FreeBSD terminal: draid1:2d:4c:1s-0, ONLINE members and distributed spare marked AVAIL
Before simulating data loss, the pools operated with all members present.

To create pool1 in the lab, we ran zpool create -o ashift=12 -O encryption=aes-256-gcm -O keyformat=passphrase -O keylocation=prompt -m /pool1 pool1 draid1:2d:4c:1s /dev/gpt/pool1_mfid2 /dev/gpt/pool1_mfid3 /dev/gpt/pool1_mfid4 /dev/gpt/pool1_mfid5. We prepared pool2 and pool3 in the same way, using the corresponding GPT labels and mount points.

This describes how the test environment was created. Do not run pool creation or destruction commands on storage devices containing lost data.

zpool create command with draid1:2d:4c:1s geometry and AES-256-GCM settings
Encryption was configured for the root dataset of each test pool at creation.

Native ZFS encryption works at the dataset level, not at the level of individual physical drives. Some structural pool metadata remains accessible without a key. Detecting the dRAID structure and decrypting files are therefore separate stages: access to the contents requires the correct passphrase and intact essential encryption metadata. See the OpenZFS documentation for more about dRAID geometry.

Test data preparation and three data loss scenarios

We copied test files into the General directory of each pool. Its visible contents consisted of 24 files totaling 368.2 MiB and one subdirectory. The files included BMP, JPG and PNG images, DOCX documents, XLSX spreadsheets, MP4 videos, and RAR and ZIP archives. This allowed us to test recovery of different data types rather than just directory metadata.

Thunar: test files in the General directory before deletion
The original set contains images, documents, videos and archives.

Scenario 1: deleted files in pool1

We deleted some files using Shift+Delete, bypassing the Trash, and then exported pool1 from FreeBSD to stop using it. The GPT partitions and pool remained, but some files were no longer present in the current filesystem state.

Scenario 2: destroyed pool2 and deleted GPT partitions

In pool2, we first deleted some files. In Thunar, 16 files in the General directory were selected for deletion. We then ran zpool destroy pool2 in the lab and deleted the second GPT partition on each of the four drives.

Thunar: confirmation dialog for permanently deleting 16 files in pool2
Some data was deleted before destroying the pool to test whether previously deleted files could also be recovered.
FreeBSD terminal: zpool destroy pool2 and a pool list without pool2
After the laboratory operation, the pool no longer appears among imported pools.

Do not repeat these destructive operations to recover data. Deleting a pool or its partitions can cause irreversible data loss.

Scenario 3: file deletion after creating pool3 snapshots

In pool3, after copying the original data, we created the pool3@files-uploaded snapshot. We then added a Video directory containing 16 files totaling 136 MiB and created a second snapshot, pool3@additional-files-uploaded. After that, we deleted some of the original files and exported the pool. In the lab, we created snapshots using zfs snapshot pool3@files-uploaded and zfs snapshot pool3@additional-files-uploaded, and checked their list with zfs list -t snapshot -r pool3.

FreeBSD terminal: list of files-uploaded and additional-files-uploaded snapshots
The two snapshots capture different dataset states before subsequent file deletion.

A ZFS snapshot preserves the state of a dataset at the time it was created by retaining the necessary earlier blocks. If a file existed in that state, it can be retrieved from the retained snapshot without rolling back the entire current dataset. However, a snapshot is not an independent backup: it depends on the availability of blocks within the same pool.

Safely connecting ZFS drives for recovery

Stop using the storage after data loss. Do not initialize or format the drives, create a new pool, perform a forced import with transaction rollback, or run scrub, resilver or other repair operations on the original devices. Avoid automatic read-write mounting, background writes and TRIM/discard. If safe, create sector-by-sector images of all available drives on separate healthy storage devices and analyze the copies. If a drive is physically damaged or unstable, even imaging may worsen its condition; consult a specialist.

Hetman RAID Recovery runs on Windows, Linux and macOS. You can connect drives directly to a computer or via a compatible docking station, analyze their images, or connect to the server via SSH if its block devices are accessible. Learn more: how to prepare RAID drives for recovery.

For recovering data from failed RAID arrays, NAS devices, and other multi-disk storage systems.

In our test, the drives remained on the FreeBSD server, and three of them were presented to the Windows 10 guest through emulated bhyve AHCI controllers. The VM’s system disk was stored separately from the test drives. This is the mapping of host block devices to virtual disks, not PCI passthrough of a physical controller.

STEP 1. Check the partition layout and pool status on the host

Check the drive identifiers and GPT partition layout. In our configuration, we used the following command:

gpart show -l mfid2 mfid3 mfid4 mfid5

The output shows partitions for pool1 and pool3, with approximately 20G of free space where the second partition was deleted. The entire drive must be presented to the VM so that the software can also analyze this area.

gpart show: free space between the pool1 and pool3 partitions
After deleting the GPT entries, the former pool2 areas remained available for low-level analysis.

Check which pools are imported on the host:

zpool status

In our test, only the system pool zroot on mfid0p4 remained. Before connecting the drives, make sure no service or application on the host is writing to them. If a pool is still active, first assess its condition and the risks of stopping it; do not perform forced operations on damaged storage.

zpool status: only the system pool zroot is imported
FreeBSD is no longer using the test pools as imported storage.

STEP 2. Configure AHCI disks in bhyve

Shut down the VM completely. In Bhyve Manager, locate its directory and open the configuration file. In our test, it was /zroot/bhyvemgr/windows10/bhyve_config.conf. Make a copy of the configuration before editing it.

Create a separate AHCI controller with an unused PCI address for each drive. Specify the hd type, the path to the entire block device rather than a partition, and the protection parameters. The following settings are from the configuration shown in the video; they are not universal addresses for other servers.

Configuration parameterValue for the first drive
pci.0.3.0.deviceahci
pci.0.3.0.port.0.nodeletetrue
pci.0.3.0.port.0.path/dev/mfid2
pci.0.3.0.port.0.rotrue
pci.0.3.0.port.0.typehd

In the configuration shown, the remaining drives are configured in the same way: pci.0.4.0 for /dev/mfid3 and pci.0.5.0 for /dev/mfid4, with port.0, type hd and both protection parameters. All lines in a given block must use the same PCI prefix.

bhyve_config.conf excerpt: three AHCI controllers, paths mfid2–mfid4, ro=true and nodelete=true
The guest receives access to whole drives through separate virtual controllers.

According to the bhyve_config documentation, ro=true prevents writes to the corresponding block device through bhyve, while nodelete=true disables translation of guest TRIM requests into DIOCGDELETE. These settings do not protect against host-side writes, undo previous TRIM operations or replace working with disk images.

STEP 3. Start Windows

Save the configuration, refresh its display in Bhyve Manager and check the added devices under Device settings, in the Storage section. Start the VM. If Windows prompts you to initialize or format unknown drives, decline.

Bhyve Manager: added ahci-hd devices at PCI addresses 0.3.0, 0.4.0 and 0.5.0
The three test block devices are added separately from the Windows system disk.

How to recover deleted files and a destroyed dRAID1 pool

STEP 1. Automatically detect the pools and missing drive

Launch Hetman RAID Recovery. We used Hetman RAID Recovery 3.1 (Unlimited Edition) in this test. The software automatically detected all three pools, including the destroyed pool2. Select the required pool and inspect its properties in the right-hand pane. The software identified the dRAID1 type and ZFS encryption. The Locked status means a passphrase is still required to access the encrypted contents.

Hetman RAID Recovery: automatically detected pool1, pool2 and pool3 and dRAID1 properties
The pool structure can be reconstructed before unlocking the encrypted data.

Check each pool's members. In the initial reconstruction screenshots, partitions from three drives were available: mfid2, mfid3 and mfid4; the fourth member (mfid5) was absent from the reconstructed pools and marked Missing disk. Later advanced search screenshots show mfid3–mfid5 in the list of found partitions. These screenshots do not establish that mfid5 was the missing drive in every session. This state does not mean the pool has been repaired: the software reconstructs it for reading and analysis.

Hetman RAID Recovery: members of the destroyed pool2 with Missing disk indicator
The destroyed pool was identified from the three available members.

Further down the device list, the software also displayed the physical drives and found partitions, including those formerly belonging to pool2. This is a separate result of disk structure detection, not yet proof of the integrity of all files.

Hetman RAID Recovery: former pool2 partitions found on physical drives
Disk areas outside current GPT partitions are also important when analyzing a destroyed pool.

STEP 2. Unlock pool1 and run a quick scan

Double-click pool1. When prompted for a password, enter the passphrase set when configuring ZFS encryption.

Hetman RAID Recovery: password dialog for an encrypted ZFS pool
The correct passphrase is required to read encrypted files.

Select Fast scan and wait for the analysis to finish. Open the General directory in the results. The wizard reported 4 folders and 96 files found in pool1. The software displayed the directory structure, existing files and found deleted files marked with a red cross.

Hetman RAID Recovery: existing and deleted General files in pool1
The quick scan found deleted files in a pool that had not been destroyed.

If the required files are missing after a quick scan, try Full analysis for ZFS if this mode is available in your software version. Work with copies, especially if repeated scans are needed. A full analysis does not guarantee recovery of overwritten blocks or blocks made inaccessible by TRIM.

STEP 3. Analyze the destroyed pool2

Double-click pool2, enter the password and start Fast scan. When it finishes, open the found directories. The quick scan wizard for pool2 also reported 4 folders and 96 files. Despite the destruction of the pool and deletion of its partitions, the test found both files that remained at the time of destruction and some files deleted earlier.

Hetman RAID Recovery: playback of a deleted MP4 from pool2 and thumbnails of other found files
Readable contents of a specific file confirm the recovery result after multiple destructive operations.

Check the required images, documents or other supported formats in the preview pane. A name and size alone do not prove that contents are intact. A correct thumbnail or preview generated from the file data confirms that the corresponding file can be recovered with a very high likelihood that its contents are intact. On Windows 10, the software cannot generate previews or thumbnails for every file. The absence of a thumbnail alone does not mean a file is corrupt or recovery has failed. In this test, files without displayed thumbnails were also recovered. For such files, check their contents in the appropriate application after saving them to another storage device.

STEP 4. Save the recovered files

Select the required files and click Recovery. In the wizard, choose to save to a disk and specify a directory on a different physical drive. Wait for copying to finish. If needed, save the files found in pool1 in the same way.

Do not save the results to any drive from which the pool is being recovered, even if the target partition appears empty. Writes may overwrite lost blocks belonging to other pools on those same drives.

Hetman RAID Recovery: wizard for saving four deleted files from pool2 to C:\Restored Files
Save recovered data to a separate healthy storage device.

How to recover files from encrypted ZFS snapshots

Snapshots allow you to retrieve a previous file version or a file deleted after the snapshots were created. In this scenario, you do not need to run zfs rollback or change the pool's current state. Hetman RAID Recovery lets you browse detected snapshots and copy individual files.

STEP 1. View the current contents of pool3

Open pool3, enter the passphrase and start Fast scan. The test results displayed the General and Video directories and the Snapshots section. The wizard reported 17 folders and 320 files found; these are counts of found objects, not confirmed counts of recovered files. The General directory contained existing files and found deleted files marked with red crosses.

Hetman RAID Recovery: completed Fast scan of pool3, 17 folders and 320 files
The wizard's counters show how many objects were found.
Hetman RAID Recovery: current General in pool3, red crosses and DOCX, MP4 and PNG thumbnails
Deleted files are distinguished from files present in the current state.

STEP 2. Compare the two snapshots

Open Snapshots and the first snapshot, files-uploaded. It contains the original General directory, while Video does not yet exist there. For example, mp4_40mb_deleted.mp4 and png_14mb_deleted.png are marked as deleted in the current state but appear without red crosses and with thumbnails in the first snapshot.

General in the files-uploaded snapshot: MP4 and PNG thumbnails without deletion indicators
The snapshot preserved versions of files that were subsequently deleted from the current dataset.

Return to the snapshot list and open additional-files-uploaded. Both directories, General and Video, are present here. Check the required files in the corresponding state: if a file was deleted later, it may still be present in a snapshot as a regular existing file, without a red cross.

additional-files-uploaded snapshot: Video directory with 16 files, some with thumbnails
The second snapshot includes the video files added later.

STEP 3. Search current data and snapshots for files

If you know the filename or part of it, use Find File. Open the root of pool3, enter a search expression and click Find. The search covers the current directory and its subdirectories, so starting at the pool root lets you search the detected snapshots as well. In the test, searching for the filename fragment ocean returned 24 results, including a video with an available preview.

Search results for ocean in pool3: 24 objects and a video preview
Searching from the root covers the current directories and detected snapshots.

In the Advanced section, you can also specify file size, date or attributes. In the example of a search for files larger than 1 MB, the software reported 248 found objects. Compare the found copies and their locations to select the required state.

Hetman RAID Recovery: Find File, Advanced, search for objects larger than 1 MB in pool3
Searching from the pool root helps locate copies in different filesystem states.

STEP 4. Collect and save files from different states

If the required files are in different directories or snapshots, right-click a file and select Add For Recovery. The Recovery list pane will open. Navigate to other directories and snapshots and drag the required files into the list.

Hetman RAID Recovery: four files in the Recovery list and a snapshot video preview
Files from different directories and snapshots can be collected for a single recovery session.

Click Recover in the list pane and save the selected data to a separate physical drive. If the list contains multiple versions of the same file, make sure the copies you need are not replaced by others when saving.

Test results and limitations

ScenarioTest result
pool1: file deletionAutomatic detection, unlocking with a password, existing and found deleted files after Fast scan.
pool2: file deletion, destruction of the pool and its partitionsAutomatic detection of the destroyed pool, detection of former GPT partitions, preview and saving of selected files, including previously deleted ones.
pool3: deletion after creating two snapshotsAccess to current contents and two snapshots, searching and saving selected files from different states.

In all three scenarios, a quick scan was sufficient for analysis, and three of the four dRAID1 members were sufficient for reconstruction. After saving the selected files, we opened them in the appropriate applications and checked that the contents were displayed. The test also recovered files for which the Windows version of the software did not display thumbnails. This does not constitute a byte-for-byte comparison with the originals or confirmation that every file from every pool was recovered.

Recovery depends on the preservation of ZFS metadata, block availability, dRAID geometry, the correct passphrase and the condition of the drives. Distributed spare capacity does not make dRAID1 tolerant of simultaneous loss of two members. On SSDs, previously issued TRIM operations and internal drive processes may make some data inaccessible. Recovering files does not mean that the original pool has been repaired or can safely be returned to service.

For another ZFS configuration on FreeBSD, see also recovering a deleted RAIDZ2 pool and files from a snapshot. If you recover the required data, verify it and create an independent backup.

Vladimir Artiukh

Author: , Technical Writer

Vladimir Artiukh is a technical writer for Hetman Software, as well as the voice and face of their English-speaking YouTube channel, Hetman Software: Data Recovery for Windows. He handles tutorials, how-tos, and detailed reviews on how the company’s tools work with all kinds of data storage devices.

Oleg Afonin

Editor: , Technical Writer

Oleg Afonin is an expert in mobile forensics, data recovery and computer systems. He often attends large data security conferences, and writes several blogs for such resources as xaker.ru, Elcomsoft and Habr. In addition to his online activities, Oleg’s articles are also published in professional magazines. Also, Oleg Afonin is the co-author of a well-known book, Mobile Forensics - Advanced Investigative Strategies.

Recommended For You