Re: Verify RAID1

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Apr 27, 2018 at 09:32:08PM -0700, Nick Leli wrote:
> The RAID is utilized with LVM, but I would like to inspect the
> individual disks, to ensure that data is replicated in case of
> failure.

You can run a RAID check and then see that mismatch_cnt is 0. 
This should be enough to make sure all data is correct.

If you don't trust the RAID system at all, and provided all 
devices are using the same data offsets, you can use cmp.

Setup:

# truncate -s 100M a.img b.img
# losetup --find --show a.img
/dev/loop0
# losetup --find --show b.img
/dev/loop1
# mdadm --create /dev/md42 --level=1 --raid-devices=2 /dev/loop[01]
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md42 started.
# mkfs.ext4 /dev/md42
# mkdir loop
# mount /dev/md42 loop/
# echo Hello World > loop/HelloWorld.txt
# umount /dev/md42

Test:

# cmp -l /dev/loop0 /dev/loop1
               4257   0   1
               4265 103 161
               4266 210  64
               4267 155 124
               4268 313 203
               4269 273  45
               4270 154 216
               4271 200  40
               4272 351 206
               4273 361 114
               4274 264 262
               4275 204 145
               4276  21 204
               4277 366 345
               4278 140 144
               4279  61 105
               4280 126 265
               4313 134  77
               4314  53 372
               4315 311 104
               4316 264 333

So there are a few bytes difference, to be expected in metadata.
(device role 0 vs. device role 1, device UUID, checksum)

If you don't want to compare metadata, you'd have to map out a 
loop device with losetup --offset / --sizelimit that represents 
actual data on the RAID itself.

Checksums will only tell you that something is different, 
not why and where (unless you do checksum per chunks of data).

Note this will only work for 1:1 mirrored RAID modes.

cmp would naturally complain about parity, or data offsets.
So for other RAID levels you have to rely on the built-in check 
or use a tool that is aware of the specific RAID layout.

Regards
Andreas Klauer
--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux