Linux raidでパーティションテーブルを回復する方法

Linux raidでパーティションテーブルを回復する方法

1つのドライブのみを含み、btrfsパーティションを持つLinux raid(対応するmdデバイス)があります。

誤って以下を行いました。

fdisk /dev/md126

警告は表示されません。

The old btrfs signature will be removed by a write command.

Device does not contain a recognized partition table. Created a new
DOS disklabel with disk identifier 0x3cf67d6f

終了するにはwと入力してください。

これでパーティションテーブルが消えました。

試してみましたが、 testdisk /dev/md126パーティションが選択されましたが、

Disk /dev/md126 - 1993 GB / 1856 GiB - CHS 486640640 2 4                                                                                                                                                                                       

The harddisk (1993 GB / 1856 GiB) seems too small! (< 1993 GB / 1856 GiB)                                                                                                                                                                      
Check the harddisk size: HD jumpers settings, BIOS detection...                                                                                                                                                                                

The following partition can't be recovered:                                                                                                                                                                                                    
     Partition               Start        End    Size in sectors                                                                                                                                                                               
>  Linux                16368   0  1 486657007   1  4 3893125120 [2018.10.18-11:37:13 v15254]                                                                                                                                                  










[ Continue ]                                                                                                                                                                                                                                   
btrfs blocksize=4096, 1993 GB / 1856 GiB

パーティションの保存を許可していないようです。

また、別々の構造では、パーティションはまったく表示されません。

次は何をすべきですか?


これはパーティションテーブルを削除する前の fdisk -l 出力です。

Disk /dev/sdb: 1.8 TiB, 2000365380096 bytes, 3906963633 sectors
Disk model: EARX-00PASB0    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcca96a8e

Device     Boot   Start        End    Sectors  Size Id Type
/dev/sdb1          2048    4982527    4980480  2.4G fd Linux raid autodetect
/dev/sdb2       4982528    9176831    4194304    2G fd Linux raid autodetect
/dev/sdb3       9437184 3902564351 3893127168  1.8T fd Linux raid autodetect

Disk /dev/md126: 1.8 TiB, 19933000280061440 bytes, 3893125120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

後ろに:

Disk /dev/sdb: 1.8 TiB, 2000365380096 bytes, 3906963633 sectors
Disk model: EARX-00PASB0    
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xcca96a8e

Device     Boot   Start        End    Sectors  Size Id Type
/dev/sdb1          2048    4982527    4980480  2.4G fd Linux raid autodetect
/dev/sdb2       4982528    9176831    4194304    2G fd Linux raid autodetect
/dev/sdb3       9437184 3902564351 3893127168  1.8T fd Linux raid autodetect


Disk /dev/md126: 1.8 TiB, 1993280061440 bytes, 3893125120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x3cf67d6f

以下は現在の状況のた​​めの別々の印刷物です。

Model: Linux Software RAID Array (md)
Disk /dev/md126: 1993GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start  End  Size  Type  File system  Flags

同様の構成を持つ他のドライブの出力は次のとおりです。

Model: Linux Software RAID Array (md)
Disk /dev/md123: 1995GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags: 

Number  Start  End     Size    File system  Flags
 1      0.00B  1995GB  1995GB  btrfs

ベストアンサー1

このデバイスにはパーティションテーブルはありません。したがって、パーティションがない場合、パーティションを回復しようとする試みは失敗するしかありません。ファイルシステムを保持するデバイスにパーティションテーブルを書き込むと、ファイルシステムが破損する可能性があります。

状況を再現してみてください。

# file -s /dev/md100
/dev/md100: BTRFS Filesystem sectorsize 4096, nodesize 16384, leafsize 16384, UUID=fbae0a54-9d6b-4d20-9981-a1a385a0a91f, 120848384/205520896 bytes used, 1 devices
# fdisk /dev/md100
# file -s /dev/md100
/dev/md100: DOS/MBR boot sector

次のステップは回復に役立ちました。

wipefs作成したmsdosパーティションヘッダーを削除するには:

# wipefs --all --types dos /dev/md100
/dev/md100: 2 bytes were erased at offset 0x000001fe (dos): 55 aa
/dev/md100: calling ioctl to re-read partition table: Success
# file -s /dev/md100
/dev/md100: data

btrfs-select-superバックアップスーパーブロックを復元するには、次の手順を実行します。

メモ:私は何らかの理由で問題を解決できないか、解決する意志がないbtrfs-select-superため、これを使用しました。btrfs check続行する前にマニュアルページをお読みください。

# btrfs-select-super -s 1 /dev/md100
using SB copy 1, bytenr 67108864
# file -s /dev/md100
/dev/md100: BTRFS Filesystem sectorsize 4096, nodesize 16384, leafsize 16384, UUID=fbae0a54-9d6b-4d20-9981-a1a385a0a91f, 120848384/205520896 bytes used, 1 devices

その後、ファイルシステムを完全なファイルとしてマウントできます。

ただし、同じ方法があなたに効果があることを保証することはできません。可能であれば、この実験をドライブで直接実行しないでください。記録中にコピーを上書きする

おすすめ記事