25.02.2016 16:23
25.02.2016 16:20

Cleaning DMRAID metadata

I've got a disk, I partitioned it put into computer with Linux. No problems found until I enabled RAID autodetection. Then weird things start to happen - e.g. systemd was not able to boot the system and dropped to rescue shell even thou this was not a system disk, there were strange errors.

kernel:  sdb: sdb1
kernel: sd 1:0:0:0: [sdb] Attached SCSI disk

systemd-udevd[232]: error: /dev/sdb1: No such file or directory
systemd-udevd[282]: inotify_add_watch(6, /dev/sdb1, 10) failed: No such file or directory

The /dev/ nodes for sbdX were missing, but the disk and partitions were detected by kernel and partprobe was able to create the nodes without issues.


dmraid is usually used to maintain fake raids from various BIOS impementations.

Grub was complaining at the end of config generation.

ERROR: ddf1: wrong # of devices in RAID set "ddf1_raid0" [1/2] on /dev/sdb

Attemps to remove those "metadata" with normal dmraid commands failed. This most probably is because those data are from something completely else and dmraid is making a nonsence of them, seeking out of the disk.

# dmraid -E -r /dev/sdb
ERROR: ddf1: seeking device "/dev/sdb" to 104411191574528
ERROR: writing metadata to /dev/sdb, offset 203928108544 sectors, size 0 bytes returned 0
ERROR: erasing ondisk metadata on /dev/sdb

The problem is "Where those metadata are?". Well at the begining or/and at the end of the disk. My solution was:

dd if=/dev/sbd  of=sbdstart-2048.img bs=512 count=2048         #backup
dd if=/dev/zero of=/dev/sdb          bs=512 count=2047 seek=1  #rewrite with zeros except MBR

dd if=/dev/sdb  of=sdbend-1024.img bs=512 skip=$(( $(blockdev --getsz /dev/sdb) - 1024 )) count=1024 #backup
dd if=/dev/zero of=/dev/sdb        bs=512 seek=$(( $(blockdev --getsz /dev/sdb) - 1024 )) count=1024 #rewrite with zero

Make sure with fdisk that you first partition starts at block 2048 (this is the default now, but older disk may still use 63).

There should be no data at the end of the partition, except the last few where the fake dmraid metadata are.

Email comment