Removing and Replacing dm-intergrity Drives In A RAID Array 2026/08/06 Ami Sapphire Last Updated: 2026/08/08 note the suspect drive and cross-check it with smartctl and your integritysetup.sh entry list; they both list you serial or wwn smartctl -i /dev/sdX dmsetup info /dev/dm-X -- unmount the array umount /path/to/array/mount note: you may need to stop the services that have used the drive - php, mysql/mariadb, httpd, smbd, etc. - do not use umount flags -l or -f to remove the array's mount! the command to use if there are any processes using the array's mount dmsetup ls -- disable the array's automount in /etc/fstab by commenting out the entry, as you do have to shut down the machine to replace the drive... unless you have a hot spare installed -- replace the suspect drive's entry with the replacement one in integritysetup.sh - use either the serial number or wwn -- apparently stopping the array makes the next step fail! the command, for the record mdadm --stop /dev/mdX this would only be useful if the array had outright failed before replacement -- fail and remove suspect drive mdadm --manage /dev/mdX --fail /dev/dm-X --remove /dev/dm-X -- replace the suspect drive with a known good one if you do not have a hot spare installed - please cross-check the serial number or wwn of the suspect drive! -- if the drive was just physically replaced, do the following (if an already prepared spare, skip this step) integritysetup format -B -I crc32c -s 512 -t 4 /dev/sdX OR integritysetup format -B -I crc32c -s 4096 -t 4 /dev/sdX OR integritysetup format -B -I sha1 -s 512 -t 20 /dev/sdX OR integritysetup format -B -I sha1 -s 4096 -t 20 /dev/sdX then integritysetup open -B -I crc32c /dev/sdX mdX-idY OR integritysetup open -B -I sha1 /dev/sdX mdX-idY -- add the replacement drive mdadm --manage /dev/mdX --add /dev/mapper/mdX-idY if this fails with writing to the superblock, run your previous command, but with the --integrity-recalculate flag - this will be very slow Note: this should also only be done on a very reliable and known-good hard disk and preferably on a system withh properly working ECC RAM integritysetup open --integrity-recalculate -B -I crc32c /dev/sdX mdX-idY OR integritysetup open --integrity-recalculate -B -I sha1 /dev/sdX mdX-idY and then attempt adding the drive to the array strangely enough, a 'Device or resource busy' was emitted in my --integrity- recalculate example, but then I tried to remove it, and... it was actually added to the array and resyncing?! [Device md0-id0 is still in use.] -- check array detail mdadm --detail /dev/mdX -- check overall array status cat /proc/mdstat -- live version of overall array status watch cat /proc/mdstat or watch -n 1 /proc/mdstat -- after the resync is finished, reboot to test Note: if --integrity-recalculate was used on the replacement disk, this is gone upon next reboot - it will be opened without the flag assuming you edited your integritysetup.sh file correctly -- run the following mdadm --detail /dev/mdX -- if everything is fine, uncomment the commented out entry in /etc/fstab and reboot to test -- you may want to add the following to /etc/mdadm.conf or /etc/mdadm/mdadm.conf if not present ARRAY /dev/mdX metadata=1.2 UUID=[uuid] where [uuid] is your array's UUID that UUID was listed when you checked the array's detail -- run the following update-initramfs -u