Mounting a filesystem with dmsetup
Posted: 18 Nov 2023, 18:36
I have a disk removed from an mdadm RAID1 array which mdadm refuses to work with. However testdisk can find the EXT4 filesystem and browse the files.
There are several TB of files to recover which I need to rsync to a new disk so I would like to mount the filesystem using dmsetup but I'm not having any success. (I'm a bit out of my depth: I have very little experience of dmsetup or calculating offsets etc.)
The second dmsetup sample command in the /debug logs - which I am assuming is for the ext4 filesystem (the first being for the RAID partition), when run, gives:
testdisk /debug log:
There are several TB of files to recover which I need to rsync to a new disk so I would like to mount the filesystem using dmsetup but I'm not having any success. (I'm a bit out of my depth: I have very little experience of dmsetup or calculating offsets etc.)
The second dmsetup sample command in the /debug logs - which I am assuming is for the ext4 filesystem (the first being for the RAID partition), when run, gives:
Various attempts at the maths to calculate the table myself have generally resulted in a successful dmsetup command but I've not then been able to mount the filesystem so I'm obviously getting something wrong. (My best guess was "0 976721360 linear /dev/sdf 258048")echo "0 7813771264 linear /dev/sdf 266240" | sudo dmsetup create test1
device-mapper: reload ioctl on test1 (253:0) failed: Invalid argument
Command failed.
testdisk /debug log:
OS: Linux, kernel 6.2.0-36-generic (#37~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Oct 9 15:34:04 UTC 2) x86_64
Compiler: GCC 11.2
ext2fs lib: 1.46.5, ntfs lib: libntfs-3g, reiserfs lib: none, ewf lib: none, curses lib: ncurses 6.3
Hard disk list
Disk /dev/sdf - 4000 GB / 3726 GiB - CHS 476930 64 32, sector size=4096 - ST4000DM 004-2CV104, FW:0001
Partition table type (auto): Intel
Disk /dev/sdf - 4000 GB / 3726 GiB - ST4000DM 004-2CV104
Partition table type: Intel
Analyse Disk /dev/sdf - 4000 GB / 3726 GiB - CHS 476930 64 32
Geometry from i386 MBR: head=64 sector=32
Raid magic value at 0/8/1
Raid apparent size: 3403207372 sectors
check_MD 1.2
fileserver:2 md 1.x L.Endian Raid 1 - Array Slot : 1 (empty, 0)
get_geometry_from_list_part_aux head=8 nbr=2
Current partition structure:
1 * Linux RAID 0 8 1 476914 55 32 976721408 [fileserver:2]
search_part()
Disk /dev/sdf - 4000 GB / 3726 GiB - CHS 476930 64 32
Raid magic value at 0/8/1
Raid apparent size: 3403207372 sectors
fileserver:2 md 1.x L.Endian Raid 1 - Array Slot : 1 (empty, 0)
Linux RAID 0 8 1 476914 54 17 976721361 [fileserver:2]
md 1.x L.Endian Raid 1 - Array Slot : 1 (empty, 0), 4000 GB / 3725 GiB
get_geometry_from_list_part_aux head=8 nbr=1
Warning: the current number of heads per cylinder is 64 but the correct value may be 8.
Results
* Linux RAID 0 8 1 476914 55 32 976721408 [fileserver:2]
md 1.x L.Endian Raid 1 - Array Slot : 1 (empty, 0), 4000 GB / 3725 GiB
Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 7813771264 linear /dev/sdf 2048" | dmsetup create test0
interface_write()
1 * Linux RAID 0 8 1 476914 55 32 976721408 [fileserver:2]
search_part()
Disk /dev/sdf - 4000 GB / 3726 GiB - CHS 476930 64 32
Raid magic value at 0/8/1
Raid apparent size: 3403207372 sectors
fileserver:2 md 1.x L.Endian Raid 1 - Array Slot : 1 (empty, 0)
Linux RAID 0 8 1 476914 54 17 976721361 [fileserver:2]
md 1.x L.Endian Raid 1 - Array Slot : 1 (empty, 0), 4000 GB / 3725 GiB
recover_EXT2: s_block_group_nr=0/29807, s_mnt_count=49/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 976721360
recover_EXT2: part_size 976721360
Filesystem created: Tue Sep 18 09:20:54 2018
Last mount time: Fri Nov 10 15:52:00 2023
Linux 16 16 1 476930 62 16 976721360
ext4 blocksize=4096 Large_file Sparse_SB, 4000 GB / 3725 GiB
block_group_nr 1
recover_EXT2: "e2fsck -b 32768 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=1/29807, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 976721360
recover_EXT2: part_size 976721360
Filesystem created: Tue Sep 18 09:20:54 2018
Linux 16 16 1 476930 62 16 976721360
ext4 blocksize=4096 Large_file Sparse_SB Backup_SB, 4000 GB / 3725 GiB
block_group_nr 3
recover_EXT2: "e2fsck -b 98304 -B 4096 device" may be needed
recover_EXT2: s_block_group_nr=3/29807, s_mnt_count=0/4294967295, s_blocks_per_group=32768, s_inodes_per_group=8192
recover_EXT2: s_blocksize=4096
recover_EXT2: s_blocks_count 976721360
recover_EXT2: part_size 976721360
Filesystem created: Tue Sep 18 09:20:54 2018
Linux 16 16 1 476930 62 16 976721360
ext4 blocksize=4096 Large_file Sparse_SB Backup_SB, 4000 GB / 3725 GiB
Search for partition aborted
get_geometry_from_list_part_aux head=8 nbr=2
get_geometry_from_list_part_aux head=16 nbr=1
Warning: the current number of heads per cylinder is 64 but the correct value may be 8.
Results
Linux RAID 0 8 1 476914 55 32 976721408 [fileserver:2]
md 1.x L.Endian Raid 1 - Array Slot : 1 (empty, 0), 4000 GB / 3725 GiB
Linux 16 16 1 476930 63 32 976721408
ext4 blocksize=4096 Large_file Sparse_SB, 4000 GB / 3725 GiB
Hint for advanced users: dmsetup may be used if you prefer to avoid rewriting the partition table for the moment:
echo "0 7813771264 linear /dev/sdf 2048" | dmsetup create test0
echo "0 7813771264 linear /dev/sdf 266240" | dmsetup create test1
interface_write()
1 P Linux RAID 0 8 1 476914 55 32 976721408 [fileserver:2]
dir_partition inode=2
Linux 16 16 1 476930 63 32 976721408
ext4 blocksize=4096 Large_file Sparse_SB, 4000 GB / 3725 GiB
Directory /
2 drwxr-xr-x 0 0 4096 18-Sep-2018 09:48 .
2 drwxr-xr-x 0 0 4096 18-Sep-2018 09:48 ..
11 drwx------ 0 0 16384 18-Sep-2018 09:20 lost+found
68550657 drwxr-xr-x 1000 114 4096 14-Nov-2023 18:41 shares
interface_write()
1 P Linux RAID 0 8 1 476914 55 32 976721408 [fileserver:2]
simulate write!
write_mbr_i386: starting...
write_all_log_i386: starting...
No extended partition
TestDisk exited normally.