RAID 6阵列分区丢失恢复咨询:硬盘完好但部分分区无msftdata标志
Hi there, let's work through this problem step by step—glad to hear all your drives are physically healthy, that's a huge win already! Here's what you can try to recover your RAID 6 array and fix the partition flag issue:
First, critical pre-step: Stop all write operations
Don't save any files, run disk tools that modify data, or mount partitions unless absolutely necessary. Writing to the drives could overwrite the RAID metadata you need to rebuild the array. If possible, disconnect the drives from any system that might auto-mount them.
1. Backup your partition tables immediately
Before touching anything, create backups of each drive's partition table so you can roll back if something goes wrong. Run this command for each drive (replace sda with sdb, sdc, etc.):
dd if=/dev/sda of=sda-partition-backup.img bs=512 count=1
Store these backup files on a separate, safe drive.
2. Check mdadm metadata on each partition
Since you're using mdadm for RAID 6, each partition should have RAID metadata stored somewhere (usually at the start or end of the partition). Run this command to scan all your RAID partitions:
mdadm --examine /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1
Look for consistent metadata across all partitions—things like the array UUID, member disk roles, and total array size. If the metadata is intact on all 8 partitions, even the ones missing the msftdata flag, mdadm might still recognize them as part of the original array.
3. Fix the missing msftdata flag
The msftdata flag is just a GPT partition attribute (since you have 8 primary partitions, you're definitely using GPT, not MBR). Losing this flag doesn't erase the partition's content—it just changes how some systems recognize the partition. To add it back, use parted for each affected drive:
- Run
parted /dev/sda(replace with/dev/sdeor/dev/sdhfor the other drives) - At the parted prompt, run
set 1 msftdata on(the1refers to the first partition on the drive) - Type
quitto exit parted
Repeat this for/dev/sdeand/dev/sdh. Remember, you already backed up the partition tables, so this is safe to try.
4. Attempt to reassemble the RAID array
If the metadata check from step 2 shows valid, consistent info, try reassembling the array with mdadm. Replace /dev/md0 with your original RAID device name (you can check old logs if you don't remember):
mdadm --assemble --force /dev/md0 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1 /dev/sdg1 /dev/sdh1
If some drives are marked as failed, add the --run flag to force the array to start:
mdadm --assemble --force --run /dev/md0 /dev/sda1 ... /dev/sdh1
If the array assembles successfully, immediately run a file system check to fix any inconsistencies (replace ext4 with your actual file system type):
fsck.ext4 /dev/md0
5. If metadata is damaged: Use partition recovery tools
If mdadm can't find valid metadata, tools like testdisk or gpart can scan your drives for partition signatures and restore the original partition structure. Here's a quick outline for testdisk:
- Install testdisk (if not already installed)
- Run
testdiskand select the drive you want to scan - Choose the partition table type (GPT, since you're using primary partitions on 8 drives)
- Run a "Deep Scan" to find lost partitions
- When it finds your original RAID partitions, select them and choose "Restore" to write the partition table back to the drive
Repeat this for all 8 drives, then try reassembling the array again withmdadm.
6. Last resort: Data recovery via RAID reconstruction
If the array won't assemble, but you can still access individual partitions, you can use mdadm in recovery mode or specialized tools to rebuild the RAID logic manually. This requires knowing the original RAID parameters (stripe size, chunk size, drive order). You can often find these in old system logs (check /var/log/messages or /var/log/syslog for mdadm entries from when the array was created).
Key reminders:
- If you're unsure about any step, it's safer to consult a professional data recovery service—especially if the data is critical.
- Always work on disk images instead of the original drives if possible. You can create images with
dd if=/dev/sda of=/path/to/large/drive/sda-image.imgand work on the images to avoid risking the original data.
备注:内容来源于stack exchange,提问作者Green Root

