CentOS 7 Clone Server from mdadm lvm system

The below info is only super quick notes during a clone I ran recently,
this is not a complete HOW-TO!!

My preference is to use LVM snapshot backups using fsarchiver.
I typically have a layout like so:

/dev/md0  –  /boot

/dev/md1 – LVM PV

/dev/vg1/root – root
(I may split out /root further, but depends on my build needs, usually not anymore)

With the above I use my own script that auto-creates an lvm snapshot,
runs fsarchiver to backup, and dismount/clear the snapshot.  I take
those .fsa files and recover to new system.   I also do a
“read-only” remount on /dev/md0 /boot to fsarchiver directly.
(this could be dangerous, but has never failed me in 8-10 years)

——————-  NOTES/PROCEDURE ——————

Centos 7 clone server

Get FSA clones from orig.

Launch Live Install CD for CentOS7 - into troubleshooting, 
rescue, Skip any mounts and go into shell.

Create Partitions

NOTE: if on >2TB , make it a GPT partition!
Make sure 1M part1 is bios_grub type!! And raid type on MD's

Create MD’s.

** HOMEHOST ISSUES **  make sure there is not mdadm.conf 
with any hostname settings, remove otherwise. Also 
CREATE with a —name directive and label it. 
(this is not the hostname)

mdadm --create /dev/md0 --metadata=1.2 --level=1 
--raid-devices=2 /dev/sda2 /dev/sdb2
## then stop
mdadm —stop /dev/md0
## then reassemble
mdadm --assemble /dev/md0 /dev/sda2 /dev/sdb2 
--update=name --name=boot --homehost="<none>”

(-- if you copy above lines, might be 
messed up wordpress html)
if home host issues come up on first boot, when 
stuck in dracut prompt, you can stop and 
reassemble to reset those names and host settings.

When all is said and done, make sure the final 
mdadm.conf is set with:
(notice /dev/md/0 not md0!  — and the device/homehost settings!)
DEVICE partitions

HOMEHOST <ignore>

AUTO +1.x +imsm -all

ARRAY /dev/md/0 metadata=1.2 name=boot 
ARRAY /dev/md/1 metadata=1.2 name=rootlvm 

#### EDIT 4-24-15 ####
The last clone I just did, DID NOT use /dev/md/0 format,
it used /dev/md0 without error, so try this way too.
However, see notes update below about UUID’s and grub.cfg default command line.
#### END EDIT ####

Create LV’s

Create your PV > VG > LV’s
Format XFS

REstore FSA’s

Do mounts and Chroot env.
— make sure to setup the mdadm.conf correctly in chroot.

— check and fix anything in /etc/fstab
< UUID mounts and maybe /dev/md0 needs set?

— if not already, /etc/dracut.conf.d/
< add md.conf < set the mdconfig and lvmconfig
variables. (review dracut.conf as example) this is
needed before initramfs. (might be set form another before!)

— Do a dracut initramfs build
You’ll need to do
“dracut -f -v /boot/initramfs-.img ”
plus just a “dracut -f -v” for current kern.

— then check any needed in /etc/default/grub
**** IMPORTANT (edit 4-24-15) Change the /etc/default/grub
section for GRUB_CMDLINE_LINUX if you have rd.md.uuid entries!!!!!
See notes below in edit.
— grub2-mkconfig -o /boot/grub2/grub.cfg
— grub2-install –modules=”part_gpt mdraid09 mdraid1x lvm” /dev/sda
(and for other drive to bootable)

— exit chroot and umounts

Should be able to reboot!

Once loaded (fix further if not) then check the mdadm.conf
and lvm.conf and fstab.

If doing any other ZFS, might need to
reset hostid and hostname!!!!!!
Or else might not reimport on reboot.
nano /etc/hostname
< set the current new hostname
nano /etc/hosts
< set that new hostname in the localhost line

“ dd if=/dev/urandom of=/etc/hostid bs=4 count=1 “
<< resets a new hostid

Prob just ned to fix/change any ifcfg scripts.

Should be all downhill from here!

#### EDIT NOTES 4-24-15 ####
Again, I ran into issues cloning. Turns out I left entries in /etc/default/grub for the UUID’s of the old system. See this example (not the full line, and should be single line):

GRUB_CMDLINE_LINUX=" rd.auto rd.auto=1 
rd.md.uuid=bbd483af:95088699:76e2826e:14b6dc4f rd.lvm.lv=vg1/root

DONT FORGET to change those rd.md.uuid entries or it won’t boot!
Get your current UUID’s like so:
mdadm –detail /dev/md0 (and /dev/md1 too)
The UUID listed in those details is what you need on each rd.md.uuid entry.

Maybe it works without those in there, but grub wouldn’t find the md devices and dracut/initramfs bootup would not assemble my arrays until I changed them. The partitions and arrays were there though, and I was dropped to a dracut prompt. From there I could manually assemble and boot, which allowed me to change the line above and then re-run grub2-mkconfig.

Just quick note while on dracut prompt. Manually assemble:

mdadm --assemble /dev/md0
mdadm --assemble /dev/md1
lvm vgchange -a y vg1

That booted my system. After fixing /etc/default/grub and re-running grub2-mkconfig all was good!