1. Background and pre-requisites

The Btrfs file system is a younger file system than Ext4, with more playable features such as support for snapshots, subvolumes, checksums and self-tests, soft RAID and even transparent compression.

However, it is recommended not to use Btrfs file system without O&M capability. This article documents the process of reading data after removing the disk from the Btrfs file system under a Synology DSM system.

In my DSM system, there are two hard disks forming a RAID1 array, using the Btrfs file system. I removed one of the hard disks and inserted it into another Apple machine.

Also, the requirements here are that the DSM version is no less than 6.2, and that the MacOS system has Parallels Desktop with Ubuntu version no less than 18.04 installed.

If you have a Windows machine, then you can also try to use the WinBtrfs drive for file reading.

2. Mount the drive on MacOS

  • View the newly inserted hard disk

View the newly inserted hard disk

You can see that MacOS does not recognize the Btrfs file system directly. Ignore the image showing disk3, this is a complementary image, which was initially disk2.

  • View disk information on MacOS
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
diskutil list

/dev/disk0 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *1.0 TB     disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                 Apple_APFS Container disk1         1000.0 GB  disk0s2
...
/dev/disk2 (internal, physical):
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                                                   *4.0 TB     disk2
  • Use the PD command tool to mount the drive to a local file

Go to the Home directory

1
cd ~

Create a new hard disk to point to a physical disk

1
/Applications/Parallels\ Desktop.app/Contents/MacOS/prl_disk_tool create -p --hdd disk2.hdd --ext-disk-path /dev/disk2

3. Mount the hard disk to the Ubuntu virtual machine in PD

Go to Ubuntu and shut down the host, then edit the virtual machine, add a hard drive, select an existing hard drive, and select the HDD format file in disk2.hdd created above.

Mount the hard disk to the Ubuntu virtual machine in PD

4. Reading Btrfs partitions on Ubuntu

  • Switch to the root user
1
sudo -i
  • Install the base software
1
apt-get install -y mdadm lvm2
  • Identify the file system

In the Disks utility, you can see the disk

In the Disks utility, you can see the disk

Automatically mount partitions

1
mdadm -Asf && vgchange -ay

Automatically mount partitions

Check the /dev/md4 partition, if it is inactive, you can uninstall it and try again.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
mdadm -D /dev/md4

/dev/md4:
           Version : 1.2
     Creation Time : Thu Apr 30 20:16:28 2020
        Raid Level : raid1
        Array Size : 3902187456 (3721.42 GiB 3995.84 GB)
     Used Dev Size : 3902187456 (3721.42 GiB 3995.84 GB)
      Raid Devices : 2
     Total Devices : 1
       Persistence : Superblock is persistent

       Update Time : Sat Dec 18 07:38:07 2021
             State : clean, degraded 
    Active Devices : 1
   Working Devices : 1
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : resync

              Name : DiskStation:4
              UUID : 9cf8faf4:c1c76801:3a4efd95:f021908b
            Events : 16609

    Number   Major   Minor   RaidDevice State
       -       0        0        0      removed
       1       8       21        1      active sync   /dev/sdb5
  • mount
1
mount /dev/vg1/volume_1 /data

mount /dev/vg1/volume_1 /data

At this point, the data of the Btrfs disk partition is already accessible in the /data directory on the Ubuntu system.

5. Mount Ubuntu directory on MacOS to access files

Since it is not convenient to access the data of Btrfs disk partition in Ubuntu, we mount the directory in PD Ubuntu to MacOS system.

  • Install sshfs and dependencies
1
brew install macfuse sshfs-mac curlftpfs-mac
  • Mount the Ubuntu system’s data directory to MacOS
1
sshfs shaowenchen@10.211.55.12:/data /Users/shaowenchen/Data
  • View data from Btrfs disk partitions on MacOS

View data from Btrfs disk partitions on MacOS