When using Intel hardware fake raid there are possibilities you will be stuck at dracut shell after changing the harddisk on Centos 7. However, supposed we can still boot the server by typing ‘exit’ command. How to know if the server using fake raid? If your server using ‘Intel Rapid Storage Technology’ most probably you are using fake raid(imsm). The raid rebuilding will be done from within the OS.
To check if you are using fake raid run the below command;

[[email protected] ~]# cat /proc/mdstat
Personalities : [raid1]
md126 : active raid1 sda[1] sdb[0]
3711641600 blocks super external:/md127/0 [2/2] [UU]

md127 : inactive sdb[1](S) sda[0](S)
10402 blocks super external:imsm

unused devices: <none>
[[email protected] ~]#

Why it happens?
Actually, after change the harddisk of the failed raid, the UUID for the raid device will change. That is why the boot stuck at dracut shell. It just failed to boot to root device because bootloader point to the old UUID of the device. Supposed we can still boot the server by using ‘exit’ command.

Centos stuck at dracut
Centos stuck at dracut

What we need to do?
1. Change /etc/mdadm.conf to the new UUID of the raid. The below command will do, but you just need to remove the existing UUID first.

mdadm --detail --scan >> /etc/mdadm.conf

In my case, I just comment it out. ‘cat’ is not the command to edit the file.

[[email protected] ~]# cat /etc/mdadm.conf
# mdadm.conf written out by anaconda
AUTO +imsm +1.x -all
#ARRAY /dev/md/Volume0_0 UUID=06e7381e:1127a1dd:0f8e52f3:b8e51cc2
#ARRAY /dev/md/imsm0 UUID=ca3d7504:3f9d43a2:fe09cab6:5c4be3ed
ARRAY /dev/md/imsm0 metadata=imsm UUID=ca3d7504:3f9d43a2:fe09cab6:5c4be3ed
ARRAY /dev/md/Volume0 container=/dev/md/imsm0 member=0 UUID=c0718acf:a2049099:004a8192:7b39b033

Double check the UUID;

[[email protected] ~]# mdadm --detail /dev/md126
Container : /dev/md/imsm0, member 0
Raid Level : raid1
Array Size : 3711641600 (3.46 TiB 3.80 TB)
Used Dev Size : 3711641600 (3.46 TiB 3.80 TB)
Raid Devices : 2
Total Devices : 2

State : active
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

Consistency Policy : resync

UUID : c0718acf:a2049099:004a8192:7b39b033
Number   Major   Minor   RaidDevice State
1       8        0        0      active sync   /dev/sda
0       8       16        1      active sync   /dev/sdb
[[email protected] ~]# mdadm --detail /dev/md127
Version : imsm
Raid Level : container
Total Devices : 2

Working Devices : 2

UUID : ca3d7504:3f9d43a2:fe09cab6:5c4be3ed
Member Arrays : /dev/md/Volume0

Number   Major   Minor   RaidDevice

-       8        0        -        /dev/sda
-       8       16        -        /dev/sdb
[[email protected] ~]#

2. Update grub to new UUID.
Next is to update the UUID in grub bootloader.

grub2-mkconfig -o /boot/grub2/grub.cfg

3. Reboot.