Recovering / Extracting Data from a Terramaster TNAS Drive Using Windows
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 should be 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:
- After installation, open Ubuntu by typing wsl into PowerShell:
wsl
- After installation, open Ubuntu by typing wsl into PowerShell:
-
Set up Ubuntu:
- On the first run, you’ll be prompted to create a new user account and password for Ubuntu.
-
Update package lists to ensure you have the latest software information:
sudo apt update
-
Install necessary tools (
lvm2
andmdadm
):sudo apt install lvm2 mdadm
mdadm
is used for managing RAID arrays.lvm2
is used for managing Logical Volume Manager (LVM) volumes.
Step 2: Connect Your Drive
Physically connecting the TNAS drive to your Windows PC allows WSL to access it.
1. Physically Connect the Drive
- Shut down your PC to prevent any hardware damage.
- Open your computer case carefully.
- Connect the TNAS drive:
- Use a SATA cable to connect the drive to an available SATA port on your motherboard.
- Connect the drive to your power supply unit (PSU) using a power cable.
- Secure the drive inside the case to prevent movement.
- Close your computer case and restart your PC.
2. Bring the Drive Online in Windows
- Access Disk Management:
- Press
Win + X
and select Disk Management from the menu.
- Press
- Initialize the Drive if Necessary:
- If prompted to initialize the disk, do not proceed. This could erase your data.
- Bring the Drive Online:
- If the drive appears as Offline, right-click on it and select Online.
- Verify the Drive:
- The drive may show partitions with unknown file systems. This is expected.
Step 3: Mount the Physical Disk in WSL
By default, WSL 2 does not have access to physical disks connected to Windows. We’ll need to mount the disk manually to interact with it in WSL.
1. Identify the Physical Drive in Windows
-
Open PowerShell as Administrator.
-
List all connected disks to identify your TNAS drive:
Get-CimInstance -ClassName Win32_DiskDrive | Select-Object DeviceID, Size, Model
-
Identify your drive:
- Look for the disk with the size matching your TNAS drive.
- Note the
DeviceID
(e.g.,\\.\PhysicalDrive2
).
2. Mount the Disk in WSL
-
Mount the disk without attempting to auto-mount partitions:
wsl --mount \\.\PhysicalDrive2 --bare
- Replace
\\.\PhysicalDrive2
with theDeviceID
of your drive. - The
--bare
option prevents Windows from trying to interpret the partitions.
- Replace
3. Verify the Disk in WSL
-
Switch to your Ubuntu WSL terminal.
-
List block devices:
lsblk
-
Confirm the drive is listed:
- You should see your TNAS drive listed as
/dev/sdX
(e.g.,/dev/sdb
), along with its partitions.
- You should see your TNAS drive listed as
Step 4: Identify the Drive and Partitions in WSL
Now that the drive is accessible in WSL, we need to identify the correct partition containing your data.
1. List All Drives and Partitions
-
Run:
lsblk
-
Review the output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 500G 0 disk ├─sda1 8:1 0 499G 0 part / sdb 8:16 0 4.0T 0 disk ├─sdb1 8:17 0 512M 0 part ├─sdb2 8:18 0 2.1G 0 part ├─sdb3 8:19 0 1.1G 0 part └─sdb4 8:20 0 3.6T 0 part
-
Identify your TNAS drive and partitions:
- In this example,
/dev/sdb
is the TNAS drive. - The largest partition (e.g.,
/dev/sdb4
) usually contains your data.
- In this example,
2. Examine RAID Metadata
-
Check RAID information on the data partition:
sudo mdadm --examine /dev/sdb4
- Replace
/dev/sdb4
with your actual partition.
- Replace
-
Interpret the output:
- Look for lines indicating RAID configuration, such as
Raid Level
,Array UUID
, andNumber of Devices
.
- Look for lines indicating RAID configuration, such as
Step 5: Assemble the RAID Array
The TNAS drive uses RAID configurations, which we need to assemble to access the data.
1. Assemble the RAID
-
Attempt to assemble the RAID array:
sudo mdadm --assemble --run /dev/md0 /dev/sdb4
/dev/md0
is the RAID device we are creating.- Ensure
/dev/md0
is not already in use. If it is, choose a different name like/dev/md127
.
-
Expected Output:
mdadm: /dev/md0 has been started with 1 drive.
-
Troubleshooting:
- If the assembly fails, you may need to specify additional options or confirm that the partition is correct.
2. Verify RAID Status
-
Check the status of the RAID array:
cat /proc/mdstat
-
Review the output:
Personalities : [raid1] md0 : active raid1 sdb4[0] 3900000000 blocks super 1.2 [1/1] [U]
-
Confirm that the RAID array is active and lists your partition.
Step 6: Activate the LVM
Many NAS devices use Logical Volume Manager (LVM) to manage disk space. We need to activate the LVM to access the logical volumes.
1. Scan for Volume Groups
-
Scan the system for volume groups:
sudo vgscan
-
Expected Output:
Found volume group "vg0" using metadata type lvm2
-
Explanation:
vg0
is the name of the volume group used by the TNAS device.
2. Activate the Volume Group
-
Activate all logical volumes in the volume group:
sudo vgchange -ay
-
Expected Output:
1 logical volume(s) in volume group "vg0" now active
3. List Logical Volumes
-
List all logical volumes:
sudo lvscan
-
Expected Output:
ACTIVE '/dev/vg0/lv0' [3.6 TiB] inherit
-
Explanation:
/dev/vg0/lv0
is the logical volume that contains your data.
Step 7: Mount the Logical Volume
Now that the logical volume is active, we can mount it to access the files.
1. Check the File System Type
-
Verify the file system on the logical volume:
sudo file -s /dev/vg0/lv0
-
Expected Output (you may see one of these):
/dev/vg0/lv0: Linux rev 1.0 btrfs filesystem data
or
/dev/vg0/lv0: symbolic link to ../dm-0
-
Explanation:
- If you see
btrfs filesystem data
, the volume uses the btrfs filesystem. - If you see
symbolic link to ../dm-0
, this means the logical volume is using device mapper. In this case, check the actual device:sudo file -s /dev/dm-0
- The filesystem could be ext4 or BTRFS, both commonly used in NAS systems.
- If you see
2. Create a Mount Point
-
Create a directory to serve as the mount point:
mkdir ~/raid-mount
-
Explanation:
- This directory will be used to access the contents of the logical volume.
3. Mount the Logical Volume
-
Mount the logical volume to the mount point:
# If file -s showed a direct filesystem: sudo mount /dev/vg0/lv0 ~/raid-mount # If file -s showed a symbolic link to dm-0: sudo mount /dev/dm-0 ~/raid-mount
- Use the appropriate device path based on your
file -s
output from step 1. - If mounting fails, you may need to specify the filesystem type with
-t
:sudo mount -t btrfs /dev/dm-0 ~/raid-mount # for BTRFS # or sudo mount -t ext4 /dev/dm-0 ~/raid-mount # for ext4
- Use the appropriate device path based on your
-
Verify the mount:
- Run
df -h
to see if the volume is mounted.
- Run
4. Verify the Files
-
List the contents of the mounted volume:
ls ~/raid-mount
-
Expected Output:
@appdata @backup @docker @ftp @home public
-
Explanation:
- The
public
directory typically contains user data and shared files.
- The
Step 8: Recover Your Data
With the logical volume mounted, you can now copy your data to your Windows file system.
1. Accessing Windows File System from WSL
- Understand the mount points:
- In WSL, your Windows drives are accessible under
/mnt
, e.g.,C:
drive is/mnt/c
.
- In WSL, your Windows drives are accessible under
2. Create a Destination Directory in Windows
-
Create a directory for recovered files:
mkdir /mnt/c/RecoveredFiles
-
Explanation:
- This directory will store the copied files on your Windows
C:
drive.
- This directory will store the copied files on your Windows
3. Copy Your Data
-
Copy the data from the TNAS drive to Windows:
sudo cp -r ~/raid-mount/public/* /mnt/c/RecoveredFiles
- Explanation:
sudo
is used to ensure you have the necessary permissions.- The
-r
flag copies directories recursively.
- Explanation:
-
Monitor the Copy Process:
- Be patient; copying large amounts of data can take time.
- Check for errors during the copy process.
4. Verify the Copied Data
- Navigate to the directory in Windows Explorer:
- Open
C:\RecoveredFiles
to confirm your data has been copied.
- Open
Step 9: Unmount and Clean Up
After successfully recovering your data, it’s important to unmount the volumes and clean up.
1. Unmount the Logical Volume
-
Run:
sudo umount ~/raid-mount
-
Explanation:
- This safely unmounts the logical volume from the mount point.
2. Deactivate the Volume Group
-
Run:
sudo vgchange -an vg0
-
Explanation:
- This deactivates the volume group, closing access to the logical volumes.
3. Stop the RAID Array
-
Run:
sudo mdadm --stop /dev/md0
-
Explanation:
- This stops the RAID array we assembled earlier.
4. Remove the Mount Point
-
Optional: Remove the directory used for mounting:
rmdir ~/raid-mount
-
Explanation:
- This cleans up the directory structure in your home directory.
5. Unmount the Disk from WSL
-
In PowerShell, unmount the physical disk:
wsl --unmount \\.\PhysicalDrive2
- Replace
\\.\PhysicalDrive2
with your disk’sDeviceID
.
- Replace
-
Explanation:
- This detaches the physical disk from WSL, making it safe to remove.
Disclaimer: This guide is provided for informational purposes only. Proceed at your own risk.