Partition
如何在 linux raid 上恢復分區表
我有一個 Linux raid(那些 md 設備),它只包含一個驅動器,並且上面有一個 btrfs 分區。
我不小心做了以下事情:
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
它似乎不允許我保留分區。
而parted rescue根本不顯示分區
接下來我該怎麼辦?
這是我破壞分區表之前的 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
您在該設備上沒有分區表。所以嘗試恢復分區(當你沒有分區時)肯定會失敗。將分區表寫入保存文件系統的設備上,可能會損壞該文件系統。
試圖重新創造你的情況:
# 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
之後,文件系統可以安裝完整的文件。
但是我不能保證同樣適用於你。如果可能,您不應直接在驅動器上執行此實驗,而應使用寫入覆蓋時的副本。