Cloning OS - Kernel Won't Boot

Latest response

Hi,

I have a few stand alone servers (RHEL 6.2) which I'm trying to configure OS backup procedure for.
My intention is to use a second internal device in the server with the same size to clone the boot device to it.

I created two partitions similar to the boot device - one for /boot (/dev/sda1) and another for LVM.
I added the second partition as a PV to the root Volume Group and converted each LV to be mirrored across both PVs.
I then reduced each Mirrored LV to one copy on the original PV and split the other PV to be a separated VG.
I've used dd and grub-install to use /dev/sdb1 as the boot partition.
I also edited fstab on the cloned root LV to reflect changes in the root VG name.

I then used dracut to create a new initramfs image and edited grub.conf on the cloned boot partition.

However, when I reboot the server and choose the second device as the boot device in BIOS, the grub menu appears but the Kernel does not start to load.
I get a blank screen with a "_" and nothing else, as if grub is unable to load the kernel according to what I've configured in grub.conf.

I'm certain I've missed a basic step somewhere in this procedure.
If anyone can help it would be much appreciated.
Thanks,
Yair

Responses

Grub doesn't load, otherwise you would get some kind of grub error.
Did you do a grub-install to that specific disk?

Hi Martijn,

I did run grub-install on the alternate boot partition, it finished successfully with no errors and device.map file was updated with the new device - hd1
In addition, I do see the GRUB menu load and shows that it will load the initramfs and the kernel of the alternate boot device but after that nothing happens.
This is why I don't think it's a GRUB issue (unless I missed something in grub.conf).

Thanks,
Yair

Hi Martijn,

I did run grub-install on the alternate boot partition, it finished successfully with no errors and device.map file was updated with the new device - hd1
In addition, I do see the GRUB menu load and shows that it will load the initramfs and the kernel of the alternate boot device but after that nothing happens.
This is why I don't think it's a GRUB issue (unless I missed something in grub.conf).

Thanks,
Yair

I don't have any absolute answers to this question (and now I want to try this as well).

Have you tried booting the host from Rescue Media and run a [pv|vg|lv]scan to make sure all your devices and volumes are sound? Also - have you tried using BLKID (and UUID) rather than Volume Names to configure.

Also - did you run your dracut after the Volume split? I believe the dracut grubs lvm.conf , but it should scan regardless and find the PVs and see the metadata to create the VG from that. One thing I wonder about is disk-alignment also. I.e. if you installed on sda and laid down the boot-blocks and then sda1/2 followed... as opposed to a new device (sdb1) and then you create sdb1 which might start at an earlier block on the disk.

[root@apoc backup]# egrep 'pe_[sc]|extent' centos 
    extent_size = 8192      # 4 Megabytes
            pe_start = 2048
            pe_count = 4994 # 19.5078 Gigabytes
                start_extent = 0
                extent_count = 512  # 2 Gigabytes
                start_extent = 0
                extent_count = 4482 # 17.5078 Gigabytes

Have you considered using MDadm instead? (sorry if I missed a requirement that makes software RAID not an option).

While Grub is working; you could check it's contents as it may point to the wrong disk.
Could you post the grub.conf file you had and the new one?

Are you certain the new initramfs is being used?

Hi Martijn and James,

First thank you very much for your desire to help with this issue.
I have tried my procedure on another server and it worked better this time.
I imagine that all the testing I've done on the original server probably caused the issue I faced and left the alternate boot device not-bootable.

I will provide the outline of the procedure I used in case anyone would like to use it in the future.
My root VG is called vg_root and it is installed on /dev/sda and contains two LVs - LogVol00 and LogVol01.
My backup boot device is /dev/sdb.
I run the following commands:

[root@host1~]# vgchange -an vg_bck
[root@host1~]# vgreduce --remove-missing vg_bck
[root@host1~]# vgremove -f vg_bck #clear old remains in case of need
[root@host1~]# /sbin/sfdisk -d /dev/sda | /sbin/sfdisk --force /dev/sdb
[root@host1~]# mkfs.ext4 /dev/sdb1
[root@host1~]# mkdir /mnt/boot
[root@host1~]# mount /dev/sdb1 /mnt/boot
[root@host1~]# rsync -v --update -r --perms --owner --group --times -x -l --temp-dir=/tmp -R /boot /mnt/
[root@host1~]# pvcreate -f /dev/sdb2
[root@host1~]# vgextend vg_root /dev/sdb2
[root@host1~]# lvconvert -m 1 --mirrorlog core /dev/vg_root/LogVol00 /dev/sdb2
[root@host1~]# lvconvert -m 1 --mirrorlog core /dev/vg_root/LogVol01 /dev/sdb2
[root@host1~]# lvconvert --splitmirrors 1 --name BLogVol00 /dev/vg_root/LogVol00
[root@host1~]# lvconvert --splitmirrors 1 --name BLogVol01 /dev/vg_root/LogVol01
[root@host1~]#lvchange -a n /dev/vg_root/BLogVol00
[root@host1~]# lvchange -a n /dev/vg_root/BLogVol01
[root@host1~]# vgsplit vg_root vg_bck /dev/sdb2
[root@host1~]# lvchange -a y /dev/vg_bck/BLogVol00
[root@host1~]# mkdir /mnt/root
[root@host1~]# mount /dev/vg_bck/BLogVol00 /mnt/root
[root@host1~]# blkid /dev/sdb1 #to capture /dev/sdb1 Block ID for fstab
[root@host1~]# vi /mnt/root/etc/fstab #see blow
[root@host1~]# /sbin/grub-install --recheck --root-directory=/mnt /dev/sdb
[root@host1~]# dracut -f /mnt/boot/initramfs-2.6.32-220.el6.x86_64.img `uname -r`
[root@host1~]# edit /mnt/boot/grub/grub.conf #see below
[root@host1~]# lvchange -a y /dev/vg_bck/BLogVol01
[root@host1~]# mkswap /dev/vg_bck/BLogVol01
[root@host1~]# lvchange -a n /dev/vg_bck/BLogVol01
[root@host1~]# umount /mnt/boot
[root@host1~]# umount /mnt/root
[root@host1~]# lvchange -a n /dev/vg_bck/BLogVol00

This is my current /etc/grub.conf:

[root@host1~]# cat /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_root-LogVol00
#          initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
password --md5 $1$wYaHt1$EpstxgQ/hqsSr5oSLeW5Z0
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
    root (hd0,0)
    kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_root-LogVol00 rd_NO_LUKS rd_LVM_LV=vg_root/LogVol02 LANG=en_US.UTF-8 rd_LVM_LV=vg_root/LogVol00 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
    initrd /initramfs-2.6.32-220.el6.x86_64.img
[root@host1~]#

And this is the grub.conf on the alternate boot partition:

[root@host1~]# cat /mnt/boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/mapper/vg_root-LogVol00
#          initrd /initrd-[generic-]version.img
#boot=/dev/sdb
default=0
timeout=5
password --md5 $1$wYaHt1$EpstxgQ/hqsSr5oSLeW5Z0
splashimage=(hd1,0)/grub/splash.xpm.gz
hiddenmenu
title BACKUP Red Hat Enterprise Linux (2.6.32-220.el6.x86_64)
        root (hd1,0)
        kernel /vmlinuz-2.6.32-220.el6.x86_64 ro root=/dev/mapper/vg_bck-BLogVol00 rd_NO_LUKS rd_LVM_LV=vg_bck/BLogVol01 LANG=en_US.UTF-8 rd_LVM_LV=vg_bck/BLogVol00 rd_NO_MD quiet SYSFONT=latarcyrheb-sun16 rhgb crashkernel=128M  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-2.6.32-220.el6.x86_64.img
[root@host1~]#

This is my current /etc/fstab file:

[root@host1 ~]# cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Sep  3 14:36:23 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_root-LogVol00 /                       ext4    defaults        1 1
UUID=389eff18-92bd-4737-b1e5-e1ac0dc09f8f /boot                   ext4    defaults        1 2
/dev/mapper/vg_root-LogVol01 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
[root@host1 ~]#

And this is the fstab file on the alternate root LV:

[root@host11 ~]# cat /mnt/root/etc/fstab

#
# /etc/fstab
# Created by anaconda on Wed Sep  3 14:36:23 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/vg_bck-BLogVol00 /                       ext4    defaults        1 1
UUID=c34c101b-6e8f-439d-9f04-91022a93161c /boot                   ext4    defaults        1 2
/dev/mapper/vg_bck-BLogVol01 swap                    swap    defaults        0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
[root@host1 ~]#

A few things to note:
1. This procedure is not intended for a case where the original boot device is missing or in some way unrecognized by the boot process (I use physical mirroring for that scenario). It is intended to address a software issue preventing the OS from booting. If the original boot device is unrecognized by the boot process, the addressing for the hd device in grub.conf (which is to hd1) should be changed to hd0 otherwise you will not be able to get pass the grub menu.
2. The Backup VG must not be exported, or you will get a kernel panic when you try to boot from the backup disk. I tried to import it through a rescue CD, however it encountered a fatal LVM error when searching for OS installation on the devices since the VG is exported. I'm sure there's a solution for that, I just don't have the time currently to search for it so I just leave the VG imported on the system after the backup procedure.

I hope this helps anyone in the future and again, I thank you both for assisting me.
Regards,
Yair

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.