November 24, 2024 · 9 min read

Recovering / Extracting Data from a Terramaster TNAS Drive Using Windows

A comprehensive guide on recovering files from a Terramaster TNAS hard drive using Windows Subsystem for Linux (WSL) while retaining metadata and folders.

This guide will walk you through the steps to recover files from a Terramaster TNAS drive.

I had a Terramaster TNAS NAS fail without any underlying data integrity issues. Rather than get a replacement and swap the drive back in, I decided to extract all of the files from the drive so I could format it.

Drives used in TNAS are formatted with a variety of partitions, most of which are not readable by Windows. RAID is also used which adds complexities.

I simply removed the drive from the NAS and connected it to my PC via a SATA cable (+ power from the PSU).

I tried lots of Desktop GUI tools but they either recovered the files without any names / file structures or required payments to actually export the files.

This method is 100% free and relatively simple.


Step 1: Set Up WSL and Install Necessary Tools

To access the Linux-specific file systems and manage RAID configurations, we need a Linux environment. WSL allows us to run a Linux distribution directly within Windows without the need for a virtual machine or dual boot setup.

1. Install WSL with Ubuntu

  • Open PowerShell as Administrator:

    • Click on the Start menu, type "PowerShell," right-click on Windows PowerShell, and select Run as administrator.
  • Install WSL and Ubuntu by running the following command:

    wsl --install -d Ubuntu
    
    • This command installs WSL 2 along with the Ubuntu distribution.

    • Note: If WSL is already installed, ensure it's updated to WSL 2:

      wsl --update
      wsl --set-default-version 2
      
  • Restart your computer if prompted.

2. Launch Ubuntu in WSL

  • Open Ubuntu:

    • Search for "Ubuntu" in the Start menu and click on it.

    • Alternatively, open Command Prompt or PowerShell and type:

      wsl
      
  • Set up your Ubuntu user account if this is your first time running Ubuntu.

3. Update the Package List

Once Ubuntu is running, update the package list to ensure you have the latest information about available packages:

sudo apt update

4. Install Essential Tools

Install the necessary tools for managing RAID and file systems:

sudo apt install mdadm lvm2 ntfs-3g rsync -y
  • mdadm: For managing software RAID arrays.
  • lvm2: For managing Logical Volume Manager (LVM) volumes.
  • ntfs-3g: For reading and writing NTFS file systems.
  • rsync: For efficiently copying files while preserving metadata.

Step 2: Identify and Access the TNAS Drive

1. List Available Drives

First, identify the TNAS drive connected to your system:

sudo fdisk -l

This command lists all connected drives and their partitions. Look for your TNAS drive, which will typically have multiple partitions with different file system types.

Example Output:

Disk /dev/sdb: 1.82 TiB, 2000398934016 bytes, 3907029168 sectors
Disk model: ST2000DM008-2FR1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 12345678-1234-1234-1234-123456789abc

Device       Start        End    Sectors   Size Type
/dev/sdb1     2048    1050623    1048576   512M EFI System
/dev/sdb2  1050624    3147775    2097152     1G Linux filesystem
/dev/sdb3  3147776 3907028991 3903881216   1.8T Linux LVM

In this example, /dev/sdb is the TNAS drive with three partitions.

2. Examine RAID Configuration

TNAS drives often use software RAID. Check if there are any RAID arrays:

sudo mdadm --examine --scan

If RAID arrays are detected, you might see output like:

ARRAY /dev/md0 metadata=1.2 name=tnas:0 UUID=abcdef12-3456-7890-abcd-ef1234567890

3. Assemble RAID Arrays (if applicable)

If RAID arrays are present, assemble them:

sudo mdadm --assemble --scan

This command automatically assembles all detected RAID arrays.

4. Check LVM Volumes

TNAS systems often use LVM for flexible storage management. Scan for LVM physical volumes:

sudo pvscan

Activate any detected volume groups:

sudo vgchange -ay

List logical volumes:

sudo lvs

Example Output:

  LV   VG   Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  data tnas -wi-a-----   1.80t

Step 3: Mount the File System

1. Create Mount Points

Create directories to mount the file systems:

sudo mkdir -p /mnt/tnas

2. Mount the Data Partition

Mount the main data partition. This could be a direct partition, a RAID device, or an LVM logical volume.

For a direct partition:

sudo mount /dev/sdb3 /mnt/tnas

For a RAID device:

sudo mount /dev/md0 /mnt/tnas

For an LVM logical volume:

sudo mount /dev/tnas/data /mnt/tnas

3. Verify the Mount

Check if the file system is mounted correctly:

ls -la /mnt/tnas

You should see the directory structure of your TNAS data.


Step 4: Copy Files to Windows

1. Access Windows File System from WSL

WSL provides access to your Windows drives through the /mnt/ directory. For example:

  • C: drive: /mnt/c/
  • D: drive: /mnt/d/

2. Create a Destination Directory

Create a directory on your Windows drive to store the recovered files:

mkdir -p /mnt/c/RecoveredTNAS

3. Copy Files with rsync

Use rsync to copy files while preserving metadata, permissions, and directory structure:

sudo rsync -avh --progress /mnt/tnas/ /mnt/c/RecoveredTNAS/

Explanation of rsync options:

  • -a: Archive mode (preserves permissions, timestamps, symbolic links, etc.)
  • -v: Verbose (shows files being copied)
  • -h: Human-readable output (shows file sizes in KB, MB, GB)
  • --progress: Shows progress during transfer

4. Monitor the Copy Process

The copy process may take a long time depending on the amount of data. The --progress option will show you the current file being copied and the overall progress.

Example Output:

sending incremental file list
Documents/
Documents/file1.txt
          1,234 100%    1.18MB/s    0:00:00 (xfr#1, to-chk=1234/5678)
Documents/file2.pdf
         12,345 100%   11.77MB/s    0:00:00 (xfr#2, to-chk=1233/5678)
...

Step 5: Verify and Clean Up

1. Verify File Integrity

After the copy process completes, verify that the files have been copied correctly:

ls -la /mnt/c/RecoveredTNAS

You can also compare file counts:

find /mnt/tnas -type f | wc -l
find /mnt/c/RecoveredTNAS -type f | wc -l

Both commands should return the same number of files.

2. Check File Permissions

Since the files are now on a Windows NTFS file system, the Linux permissions may not be directly applicable. However, the files should be accessible from Windows.

3. Unmount File Systems

Once you've verified that the files have been copied successfully, unmount the TNAS file systems:

sudo umount /mnt/tnas

If you assembled RAID arrays, you can stop them:

sudo mdadm --stop /dev/md0

4. Deactivate LVM Volumes

If you activated LVM volumes, deactivate them:

sudo vgchange -an

Step 6: Access Files from Windows

1. Navigate to the Recovered Files

Open File Explorer in Windows and navigate to the directory where you copied the files (e.g., C:\RecoveredTNAS).

2. Verify File Structure

Check that the directory structure and files are intact. You should see all your folders and files with their original names and organization.

3. Test File Access

Open a few files to ensure they're not corrupted and are accessible.


Troubleshooting

Issue: "Permission Denied" Errors

Solution: Ensure you're using sudo for commands that require administrative privileges, especially when mounting file systems and copying files.

Issue: File System Not Recognized

Solution: The TNAS drive might use a file system that's not automatically recognized. Try installing additional file system support:

sudo apt install exfat-fuse exfat-utils

Issue: RAID Array Won't Assemble

Solution: If you have multiple drives from a RAID array, ensure all drives are connected. For degraded arrays, you might need to force assembly:

sudo mdadm --assemble --force /dev/md0 /dev/sdb3

Warning: Only use --force if you understand the risks and have backups.

Issue: LVM Volumes Not Detected

Solution: Try manually scanning for physical volumes:

sudo pvscan --cache
sudo vgscan --mknodes
sudo lvscan

Issue: Slow Copy Speed

Solution: If the copy process is very slow, you can:

  1. Use a different rsync command with fewer preservation options:

    sudo rsync -rh --progress /mnt/tnas/ /mnt/c/RecoveredTNAS/
    
  2. Copy to a Linux directory first, then move to Windows:

    sudo rsync -avh --progress /mnt/tnas/ /tmp/tnas_backup/
    sudo rsync -rh --progress /tmp/tnas_backup/ /mnt/c/RecoveredTNAS/
    

Issue: Not Enough Space

Solution: If you don't have enough space on your Windows drive:

  1. Use an external drive:

    sudo rsync -avh --progress /mnt/tnas/ /mnt/d/RecoveredTNAS/
    
  2. Copy files in batches:

    sudo rsync -avh --progress /mnt/tnas/Documents/ /mnt/c/RecoveredTNAS/Documents/
    sudo rsync -avh --progress /mnt/tnas/Pictures/ /mnt/c/RecoveredTNAS/Pictures/
    

Alternative Methods

Using GUI Tools in WSL

If you prefer a graphical interface, you can install GUI file managers in WSL:

sudo apt install nautilus

Then run:

nautilus /mnt/tnas

Note: This requires an X server for Windows, such as VcXsrv or WSLg (available in Windows 11).

Using Windows Subsystem for Linux GUI (WSLg)

If you're using Windows 11, WSLg provides built-in GUI support. You can install and run Linux GUI applications directly.


Security Considerations

  1. Data Privacy: Ensure that sensitive data is handled appropriately during the recovery process.

  2. Drive Security: After successful data recovery, consider securely wiping the TNAS drive if you plan to dispose of it or repurpose it.

  3. Backup Verification: Always verify that your recovered data is complete and uncorrupted before relying on it as your primary copy.


Conclusion

This method provides a comprehensive approach to recovering data from a Terramaster TNAS drive using Windows and WSL. The process preserves file metadata, directory structures, and ensures that your data is recovered in its original form.

Key advantages of this method:

  • Free: No paid software required
  • Comprehensive: Handles RAID, LVM, and various file systems
  • Preserves metadata: File timestamps, permissions, and structure are maintained
  • Flexible: Can handle different TNAS configurations
  • Safe: Non-destructive process that doesn't modify the original drive

Remember to always have multiple backups of important data to avoid data loss situations in the future. Consider implementing a robust backup strategy that includes both local and cloud-based solutions.

If you encounter issues not covered in this guide, the Linux community forums and documentation for mdadm, lvm2, and rsync are excellent resources for additional troubleshooting steps.