How to recover data from Synology NAS after a failure during migration from RAID 1 to RAID 5?

Imagine that you add a drive to a Synology NAS and start migrating from RAID 1 to RAID 5 to increase storage capacity. But during the rebuild, power is suddenly lost and the NAS shuts down. After power is restored, it turns out that one of the original drives is no longer detected, and there is no access to the files. What should you do if there is no current backup of the required data? Can files be recovered from the two surviving drives when the migration to the new RAID level was never completed?

How to recover data from Synology NAS after a failure during migration from RAID 1 to RAID 5?

Go to view
Synology NAS Data Recovery After a Failed RAID 1 to RAID 5 Migration

Synology NAS Data Recovery After a Failed RAID 1 to RAID 5 Migration

Test environment and data loss scenario

We used a Synology DS409 with DSM 4.2 and three 320 GB Seagate Pipeline HD.2 ST3320311CS HDDs.

Three 320 GB Seagate HDDs used for RAID 1 to RAID 5 migration
Three 320 GB Seagate HDDs used for RAID 1 to RAID 5 migration

Initially, two drives were combined into RAID 1 — a mirrored array in which data was duplicated on both drives. A volume with the Ext4 file system was created on it, and approximately 110 gigabytes of test data were written: documents, photos, videos, and archives. The files were placed in directories with several levels of nesting so that we could later verify the preservation of both their contents and folder structure.

Selecting two HDDs for RAID 1
Selecting two HDDs for RAID 1

Then the third drive was added to the array, and Storage Manager was used to start the RAID level change from RAID 1 to RAID 5.

Synology DS409: the RAID level change from RAID 1 to RAID 5 was started in Storage Manager
Selecting RAID 5 in the migration wizard
Confirming the RAID type change
Confirming the RAID type change
Initial reshape stage
Initial reshape stage

When the rebuild indicator showed 29.55 percent, power to the NAS was intentionally disconnected without a proper shutdown. After that, one of the two original RAID 1 drives was removed, simulating complete inaccessibility.

As a result, two drives remained available for recovery: one drive from the original mirror and the third drive added for the transition to RAID 5. The rebuild was not completed, so part of the data had already been relocated, while the rest was still stored according to the previous scheme. These two drives will be used for the next steps.

Do not resume migration, run Repair or initialize drives before creating sector-by-sector images. Analyze copies and save recovered files to separate storage.

Connecting the drives to a Windows computer

We move to a Windows computer with Hetman RAID Recovery 3.1 Unlimited Edition installed.

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

We connect the two surviving drives via a USB docking station:

  • one of the original RAID 1 drives;
  • the drive added for the transition to RAID 5.

We launch the program. In the RAID Arrays section, we see the automatically detected array DiskStation:2.

Hetman RAID Recovery: automatically detected array DiskStation:2
Automatic detection of DiskStation:2

We select it and review the information on the Preview panel on the right. The program has identified the RAID 5 type, Left Synchronous block order, and a block size of 64 KiB.

Hetman RAID Recovery: array DiskStation:2 information on the Preview panel on the right
RAID 5: Left Synchronous, 64 KiB, one missing drive

Below, in the RAID Disks list, we can see two connected drives and an Empty disk position corresponding to the missing member. For both available drives, the same data start offset is specified — we will return to this parameter during manual reconstruction.

The list also contains two small RAID 1 arrays of approximately 2.37 and 2 gigabytes. They correspond to Synology system areas.

These arrays should not be confused with the original mirror that contained our test files.

Hetman RAID Recovery: two small RAID 1 arrays
Synology system RAID 1 arrays

The original RAID 1 with user data is no longer displayed separately.

Analyzing the automatically detected RAID 5

Let us check what is available through the automatically detected RAID 5 configuration. To do this, open the Ext4 volume in this array by double-clicking it. In the analysis wizard, select Fast scan and click Next to start searching for files.

Hetman RAID Recovery: Fast scan selected in the analysis wizard
Fast scan of the RAID 5 ext4 volume

After analyzing RAID 5, the program found 390 folders and 8,239 files. In the results, we can see the My Data folder and nested directories with test files. Part of the original structure was preserved: the program shows folder and file names and their locations.

Hetman RAID Recovery: My Data folder and nested directories with test files
Detected RAID 5 folder structure

Thus, even with two available members of the interrupted array, part of its contents could be read. To save the required files, select them, click Recovery, and specify a folder on a separate drive that is not part of the array being recovered to avoid overwriting the source data.

Hetman RAID Recovery: to save the required files, select them and click Recovery
Saving recovered RAID 5 files

However, not all files written before the test are present in the results. Before the migration, the data was stored on two drives as mirrored copies. During the transition to RAID 5, the system gradually changed the block layout, distributing it across three drives and creating parity.

As a result, areas with different data organization remained on the surviving drives. The RAID 5 layout corresponds to the block placement in the already rebuilt areas, while the previous RAID 1 organization remains in the rest, although the mirror itself is no longer automatically detected.

Therefore, the absence of a file in these results does not yet prove that its contents are completely lost.

Manual RAID 5 reconstruction

In our case, the program automatically identified RAID 5 and its parameters. But what if the configuration must be specified manually or some settings are unknown? For this purpose, Hetman RAID Recovery includes the RAID Constructor. Using the detected RAID 5 as an example, let us examine its capabilities and then use this tool to reconstruct the original RAID 1.

Hetman RAID Recovery: RAID Constructor
Manual RAID Constructor mode

We open the RAID Constructor, select RAID 5, and add the two available drives. The missing member is marked as Empty disk. This gives us three positions corresponding to the array composition during migration.

Hetman RAID Recovery: the missing disk is marked as Empty disk
Adding an Empty disk entry

In the RAID 5 configurations we tested on Synology, the Left Synchronous block order and 64 KiB block size were often encountered, so we will use this combination in the constructor. In our case, it also matches the parameters of the automatically detected array.

Hetman RAID Recovery: Left Synchronous block order and 64 KiB block size
Left Synchronous and 64 KiB block size

However, these values are not universal: for another set of drives or storage device, they must be checked separately, taking into account the array configuration and change history.

Determining the data start offset

The offset indicates which initial portion of the drive must be skipped before reading the blocks of the user array. On the physical disk diagram, we can see the Synology system partitions and the partition used to store our files. In this test, it starts at sector 9,437,184. This is our reference point. The RAID data itself starts slightly later, because there is space for system information at the beginning of the partition.

Hetman RAID Recovery: open the physical disk in HEX Editor
Physical disk in HEX-Editor

We open the physical disk in HEX Editor. To go to the beginning of the required partition, first convert its starting sector to a byte address. On the calculator, multiply 9,437,184 by the sector size — 512 bytes. The result is 4,831,838,208 bytes. Convert the result to hexadecimal and go to this address in the editor.

Hetman RAID Recovery: converting the starting sector to a byte address
Calculating the partition start address

Starting at the partition, search in HEX-Editor for the Linux MD RAID signature FC 4E 2B A9 (0xA92B4EFC in little-endian). This is not the ext4 signature (0xEF53).

Searching for the Linux MD signature
Searching for the Linux MD signature

The required match is found at address 0x120001000. Nearby, in the text part of the editor, we can see the name DiskStation:2. The signature alone is not sufficient, since such a byte sequence can also occur within other data.

The MD version 1.2 superblock is located 4096 bytes from the partition start. Check data_offset separately for each drive.

Hetman RAID Recovery: the required match is found at address 0x120001000
DiskStation:2 superblock at 0x120001000

Now let us find the data_offset field, which indicates the RAID data start offset within the partition. In this superblock format, it is located 128 bytes from the beginning and occupies eight bytes. In our case, this is the first eight bytes of the line at address 0x120001080.

Hetman RAID Recovery: RAID data start offset within the partition
MD superblock data_offset field

The value is stored in little-endian order. In standard notation, this number is 0x800 in hexadecimal format. Enter it into the calculator and switch to decimal format — the result is 2048 sectors. This is the distance from the beginning of the partition to the beginning of the RAID data. Therefore, we add 2048 to the partition’s starting sector. We get 9,439,232 sectors. Multiply by 512 bytes — the final offset from the beginning of the physical disk is 4,832,886,784 bytes. It matches the value in the properties of the automatically detected RAID 5.

(9437184 + 2048) × 512 = 4832886784

ParameterValue
Partition start9437184 × 512 B = 0x120000000
MD superblock address0x120001000
MD signatureFC 4E 2B A9
data_offset field0x80 (128 B)
data_offset value00 08 00 00 00 00 00 00
Relative offset, sectors2048
Absolute offset, sectors9439232
Offset, bytes4832886784
Size in RAID Constructor, bytes315240046592
Absolute offset: 4,832,886,784 bytes
Absolute offset: 4,832,886,784 bytes

The MD superblock field data_size contains 0x24B2CD80 sectors (315,237,269,504 bytes). This is distinct from the Size value entered in RAID Constructor in this test.

Automatic detection of RAID parameters

We return to the RAID Constructor and specify the determined offset for each available drive. Now we can use automatic detection of the unknown parameters.

In this test, RAID Constructor uses Offset 4,832,886,784 bytes and Size 315,240,046,592 bytes for each available drive.

Hetman RAID Recovery: specifying the determined offset for each available drive
RAID 5 member Offset and Size

If the block size or block order is unknown, you can select Detect automatically in the Block size and Block order fields. To determine the member order, there is a separate Detect the disk order automatically option. For example, we can leave RAID 5, Left Synchronous, and a 64 KiB block size, but let the program determine the disk order.

After proceeding to the next step, the program begins searching for configurations that match the specified conditions. The found options are displayed in a list. Select the required configuration and click Add.

Hetman RAID Recovery: found array configurations are displayed in a list
Detected RAID 5 configuration

The Damaged status in the list of detected configurations does not rule out file recovery. Verify the result by scanning the array.

Manual RAID 5 reconstruction with automatic disk-order detection also recovered files. Subsequent analysis follows the automatic scenario.

Hetman RAID Recovery: assembled RAID on the main screen of the program
Reconstructed RAID 5 in the array list

Searching for data in the original RAID 1 configuration

We return to the RAID Constructor and select RAID 1. We add the surviving drive of the original mirror, and mark the missing member as Empty disk.

Hetman RAID Recovery: return to RAID Constructor and select RAID 1
Selecting the original RAID 1

We specify the verified data start offset. This tells the program how to read the data according to the previous scheme. This is a virtual reconstruction for analysis: it does not undo the migration or restore the drives to their pre-incident state.

Hetman RAID Recovery: specify the verified data start offset
RAID 1 member offset
Hetman RAID Recovery: assembled RAID 1 on the main screen of the program
Virtually reconstructed RAID 1

We open it by double-clicking and select Full analysis in the analysis wizard. Select the Ext2/3/4 (Linux) option and start the analysis.

Hetman RAID Recovery: Full analysis of the assembled RAID 1
Full analysis with Ext2/3/4

After completion, the program found 979 folders and 14,049 files. For comparison, after Fast scan of the RAID 5 configuration, we obtained 390 folders and 8,239 files. These numbers do not indicate the number of unique valid files: the results may contain duplicates and require verification.

Hetman RAID Recovery: the program found 979 folders and 14,049 files
979 folders and 14,049 files

We review the found data. The original directory structure was not fully reconstructed, and some of the found objects are located in Lost and Found.

Hetman RAID Recovery: review the found data
Detected RAID 1 folders and files

Restoring the folder tree requires preserved file system metadata structures and the relationships between them. After an interrupted migration, data of an individual file may be readable in the selected configuration, while the records that linked it to the original directory may be unavailable. Therefore, the absence of a familiar folder does not necessarily mean that all of its contents are lost.

To find the required files more quickly, use the Find File function. In the search window, enter the full name or part of it and click Find. If necessary, you can enable case-sensitive search or restrict the search to whole-word matches only.

Hetman RAID Recovery: use the Find File function
Searching by name using Find File

After manually reconstructing RAID 1, we recovered additional files unavailable in the RAID 5 analysis. The screenshot shows a readable deleted BMP in Lost and Found.

Readable deleted BMP (48.48 MB in the application) after manual RAID 1 reconstruction
Readable deleted BMP (48.48 MB in the application) after manual RAID 1 reconstruction

Recovery results and limitations

In this test, we examined the loss of a drive after an interrupted Synology migration from RAID 1 to RAID 5. Hetman RAID Recovery automatically detected RAID 5 based on the preserved metadata, but only part of the original data was available through this configuration.

Analyzing both geometries, the new RAID 5 and original RAID 1, recovered additional files. Found-object counts do not equal unique intact files, and reshape progress does not equal the proportion of migrated files.

Related experiments:

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