Migrate Centos 7 from Single HDD to mdadm RAID 10 array:

Done on Centos 7.3 very important as clearly based on older guides it was a lot easier and more simpler!  Hint do not use grub2-install!

If you have trouble booting after this check this CentOS mdadm RAID booting/fixing guide.

One huge caveat if you are an oldschool user or sysadmin who has avoided UEFI booting

The normal way will not work here if your Centos was using UEFI.  Newer systems use it by default.

The easiest way to check is to do an fdisk -l if your system disk and check for an EFI partition.

If using EFI you need a EFI partition usually about 200M.

Instead of the typical partition 1 being normal boot this will now be EFI.

  • Partion 1 = EFI Boot 200M
  • Partition 2 = Boot 800M
  • Partition 3 = SWAP
  • Partition 4 = /
     

To match you will now have of course 4 mdadm arrays instead of 3 because of EFI.

Centos boot issue

#1 you MUST have an EFI partiton and you MUST be booted as UEFI!
a.)
So to make it more complicated with UEFI here is how a standard or at least Centos 7 typically works.

/boot partion mounted as /boot
/efi partition mounted as /boot/efi
b.) EFI partition can be mdadm RAID but must be level 1 and --metadata=1.0 and vfat filesystem
grub2-install --target=x86_64-efi /dev/sda
grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg

If you don't tell grub2-mkconfig to update the EFI grub.cfg you will be greeted to a blank grub boot screen with no menu entries.  No clue why grub2-mkconfig does not seem to update the correct EFI grub.cfg on its own.

#after booting getting another issue
dracut-initqueue: Warning: dracut-initqueue timeout -starting timeout scripts
Started dracut initqueue hook
Reached target Remote File Systems (Pre).
Reached target Remote File Systems.
A start job is running for dev-disk-by\x2uuid-8f411f86\x2d....device (7min 58s / no limit)

 

3 arrays:

md0  = /boot ext4

*(note md0 this must be --level 1 and --metadata=0.90 or it will not boot/work)

md1 = swap

md2 = / ext4

 

all mounted in /mnt/

 

 

#install grub2-tools so we can install it

yum -y install grub2-tools grub2-efi-modules

lack of efi modules gives the following error (if you didn't install the above): grub2-install: error: /usr/lib/grub/x86_64-efi/modinfo.sh doesn't exist. Please specify --target or --directory.


mkswap /dev/md1
Setting up swapspace version 1, size = 31440892 KiB
no label, UUID=a30ab8dd-f462-4dab-940d-6658bcae4395

get the UUIDs of each array:

blkid /dev/md0
blkid /dev/md1
blkid /dev/md2

/dev/md0: UUID="5b51dbfb-f361-48c3-bfdf-5da171e4577c" TYPE="ext4"
/dev/md1: UUID="a30ab8dd-f462-4dab-940d-6658bcae4395" TYPE="swap"
/dev/md2: UUID="8f411f86-3816-409b-b291-ebe1a7a170ef" TYPE="ext4"

mount /dev/md2 /target

rsync -Pha --exclude="/boot/*" --exclude="/sys/*" --exclude=/proc/* --exclude=/mnt/* / /target

mount /dev/md0 /target/boot

#if you have an EFI partition /dev/md3 or whatever you've used it for

mount /dev/md3 /target/boot/efi

#rsync the rest

rsync -Pha /boot/ /target/boot/

#if you have an EFI partition

rsync -Pha /boot/efi /target/boot/efi

Change /mnt/md2 to your mounted root /

 

mount=/target
for bind in dev sys proc; do
mount -o bind /$bind /$mount/$bind
done

 chroot /mnt/md2

#run the swapon command on your swap partition othewrise it soudns weird but mdadm WILL not activate the array even if it's in mdadm.conf. 

swapon /dev/md1

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

#you must specify the exact initramfs image and exact kernel name (matching it) or it will not work/be unbootable - much more finicky than Centos 6
dracut /boot/initramfs-3.10.0-514.21.2.el7.x86_64.img 3.10.0-514.21.2.el7.x86_64 --force

#if you get a message like this you specified the wrong kernel details in the second parameter
Kernel version 3.10.0-514.21.2.el7 has no module directory /lib/modules/3.10.0-514.21.2.el7
#in the above case I forgot the .x86_64 at the end

dracut --mdadmconf --fstab --add="mdraid" --filesystems "vfat xfs ext4 ext3 tmpfs devpts sysfs proc" --add-drivers="raid1 raid10" --force 
#this dracut step is critical because by default it will not have mdadm raid support so it will keep looking for devcies that don't get created
#also MAKE sure to use the latest or current initramfs (may not be obvious ifyou are booting from a recovery disc).
dracut --mdadmconf --fstab --add="mdraid" --filesystems "xfs ext4 ext3 tmpfs devpts sysfs proc" --add-drivers="raid1 raid10" /boot/initramfs-3.10.0-514.21.2.el7.x86_64.img --force

Update grub2-config

#to avoid problems remove any old grub.cfg

echo y| rm /boot/efi/EFI/centos/grub.cfg

echo y| rm /boot/grub2/grub.cfg

grub2-mkconfig

#something went wrong as it doesn't boot

The above happens if you are running EFI and didn't specify output to your EFI partition for grub.cfg

If you have EFI

grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg

#not sure why but the above still results in a blank grub screen with no menu entries.  Maybe grub2 needs to be reinstalled as a package or something else first.  I suspect it doesn't contain the right modules to read the boot or efi partition.

 

Install grub2:

#NO NO NO - DO NOT USE GRUB2-INSTALL

This Fedora warning explains it all:

Stop (medium size).png

grub2-install shouldn't be used on EFI systems. The grub2-efi package installs a prebaked grubx64.efi on the EFI System partition, which looks for grub.cfg on the ESP in /EFI/fedora/ whereas the grub2-install command creates a custom grubx64.efi, deletes the original installed one, and looks for grub.cfg in /boot/grub2/.

Solution just do a "yum reinstall grub2-efi"

One other solution is if you really want grub2-install is to make /boot/grub2/grub.cfg a symlnk to /boot/efi/EFI/centos/grub.cfg

ln -s /boot/efi/EFI/centos/grub.cfg /boot/grub2/grub.cfg this doesn't work I am certain grub cannot make use of that symlink

#if you get an error of "grub2-install: error /boot/efi doesn't look like an EFI partition"

It means you haven't mounted your EFI partition OR you haven't set the partition as EFI (in gdisk this is type ef00).   You'll have to stop the mdadm array for EFI and then do a mkfs.vfat on it and try again (partition must be VFAT and no other fs such as ext4/xfs etc.. it won't work unless it's VFAT).


Tags:

migrate, centos, hdd, mdadm, raid, array, guides, simpler, grub, install, caveat, oldschool, user, sysadmin, avoided, uefi, booting, newer, default, easiest, fdisk, disk, efi, partition, partion, swap, arrays, partiton, booted, typically, mounted, metadata, vfat, filesystem, _, dev, sda, mkconfig, redhat, cfg, update, greeted, entries, dracut, initqueue, timeout, scripts, uuid, min, md, ext, mnt, yum, modules, didn, usr, lib, modinfo, sh, doesn, specify, directory, mkswap, swapspace, kib, label, ab, dd, dab, bcae, uuids, blkid, quot, dbfb, bfdf, ebe, ef, mount, rsync, pha, exclude, sys, proc, ve, bind, chroot, swapon, othewrise, soudns, activate, conf, scan, etc, initramfs, kernel, matching, unbootable, finicky, img, specified, parameter, module, mdadmconf, fstab, mdraid, filesystems, xfs, tmpfs, devpts, sysfs, drivers, devcies, ifyou, disc, config, echo, rm, output, reinstalled, contain, fedora, shouldn, installs, prebaked, grubx, esp, whereas, creates, custom, deletes, installed, reinstall, symlnk, ln, symlink, haven, gdisk, ll, mkfs, fs,

Latest Articles

  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint
  • Save money on bandwidth by disabling reflective rpc queries in Linux CentOS RHEL Ubuntu Debian
  • How to access a disk with bad superblock Linux Ubuntu Debian Redhat CentOS ext3 ext4
  • ImageMagick error convert solution - convert-im6.q16: cache resources exhausted
  • PTY allocation request failed on channel 0 solution
  • docker error not supported as upperdir failed to start daemon: error initializing graphdriver: driver not supported
  • Migrated Linux Ubuntu Mint not starting services due to broken /var/run and dbus - Failed to connect to bus: No such file or directory solution
  • qemu-system-x86_64: Initialization of device ide-hd failed: Failed to get