Page 1 of 3

single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/02 10:34:49
by mclien
I hav to change a running single HDD LVM to a (software) RAID1:

I started following this howto: (which isn't exactly what I want, because it ends up in a RAID with LVM):

I successfully did the following so far:

on the additional HDD I created a raid array with the first drive missing:
[code]cat /proc/mdstat
Personalities : [raid1]
md1 : active raid1 sdb3[1]
157291319 blocks super 1.2 [2/1] [_U]
md0 : active raid1 sdb1[1]
530101 blocks super 1.2 [2/1] [_U]
unused devices: <none>[/code]

I transfered the content of /boot to /dev/md0 and the content of / to /dev/md1 using rsync (because the lvm commands obviously won't work here).
I created the initrd image and edited /boot/grub/menu.lst to boot from the rai partitions and do a failback to the running system:
[quote]
default=0
fallback=1
timeout=5
#splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
title CentOS RAID (2.6.32-220.4.2.el6.i686)
root (hd1,0)
kernel /vmlinuz-2.6.32-220.4.2.el6.i686 ro root=/dev/md1 rd_NO_LUKS LANG=en_US.UTF-8 KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys crashkernel=auto quiet
initrd /initramfs-2.6.32-220.4.2.el6.i686.img-raid
title CentOS (2.6.32-220.4.2.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.4.2.el6.i686 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=VolGroup/lv_root rd_NO_DM
initrd /initramfs-2.6.32-220.4.2.el6.i686.img
[/quote]
But grub complains it can't mount the selected file system.

My guess is the transfer via rsync is not the best way and the filesystem is deprected.
Can anyone hint me how to get the filesystem trasnferd corrctly or who to repair the filesystem on the raid partition?

Thanks

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/02 11:33:15
by TrevorH
Make sure you have the latest version of dracut installed and, if you built your initrd with the older one, rebuild it. There's a bug in the 6.2 version of dracut that affects booting from RAID 1 with a missing device.

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/02 13:20:47
by mclien
So I build the initrd with dracut instead of mkinitrd?
and this:
Release : 256.el6_2.1
is the corrct version of dracut. (at least the last I get via yum)

EDIT:
here is the missing "e"

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/04 02:43:04
by pschaff
Yes and yes.
[code]
# rpm -q dracut
dracut-004-256.el6_2.1.noarch
# cat /etc/redhat-release
CentOS release 6.2 (Final)[/code]

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/04 02:47:52
by TrevorH
There's still an /sbin/mkinitrd executable but it's a wrapper and calls dracut to do the work.

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/05 10:08:20
by mclien
There must be still a mistake in my way to do it...
-I have setup my RAID as stated above
-I boot the existing LVm system from the first HDD
-mount the RAID system:
[code][root@localhost ~]# mount /dev/md1 /mnt
[root@localhost ~]# mount /dev/md0 /mnt/boot[/code]
-update dracut
-use rsync to copy the content of the LVm to the raid partitions:
[code]rsync -vax / /mnt
rsync -vax /boot/ /mnt/boot[/code]
-chroot to the raidsystem:
[code]chroot /mnt[/code]
-use dracut to generate the initrd:
[code]dracut --mdadmconf --force /boot/initramfs-2.6.32-220.4.2.el6.i686.img-raid 2.6.32-220.4.2.el6.i686[/code]
-leave chroot
-edit /mnt/etc/fstab to this:
[code][root@localhost ~]# cat /mnt/etc/fstab

#
# /etc/fstab
# Created by anaconda on Thu Feb 16 14:29:40 2012
#
# 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/md1 / ext4 defaults 1 1
/dev/md0 /boot ext4 defaults 1 2
/dev/sdb2 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
[/code]
reboot

Still "Grub error 17: cannot mount selected partition"

So where is my mistake?
Thanks

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/05 19:04:55
by pschaff
What's in /boot/grub/grub.conf on /dev/md0?

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/06 08:49:11
by mclien
you mean this: ?
[code][root@localhost ~]# mount /dev/md1 /mnt
[root@localhost ~]# mount /dev/md0 /mnt/boot
[root@localhost ~]# cat /mnt/boot/grub/grub.conf
.....
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-220.4.2.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.4.2.el6.i686 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 \
KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD rd_LVM_LV=VolGroup/lv_swap
SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=VolGroup/lv_root rd_NO_DM
initrd /initramfs-2.6.32-220.4.2.el6.i686.img[/code]

OK, thats not correct. But isn't that irrelevant, because I boot from the existing grub entry of the first HDD, which contains this:?
[code]default=0
fallback=1
timeout=5
#splashimage=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu

title CentOS RAID (2.6.32-220.4.2.el6.i686)
root (hd1,0)
kernel /vmlinuz-2.6.32-220.4.2.el6.i686 ro root=/dev/md1 LANG=en_US.UTF-8 KEYBOARDTYPE=pc \
KEYTABLE=de-latin1-nodeadkeys crashkernel=auto quiet
initrd /initramfs-2.6.32-220.4.2.el6.i686.img-raid

title CentOS (2.6.32-220.4.2.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-220.4.2.el6.i686 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 \
KEYBOARDTYPE=pc KEYTABLE=de-latin1-nodeadkeys rd_NO_MD rd_LVM_LV=VolGroup/lv_swap \
SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet rd_LVM_LV=VolGroup/lv_root rd_NO_DM
initrd /initramfs-2.6.32-220.4.2.el6.i686.img-raid[/code][Moderator edit: Wrap [b]long[/b] lines.]

Or didn't I get the mechanism of grub right?

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/06 11:37:48
by mclien
or could it be that grub doesn't supports ext4 on md devices, while it supports ext4 on /dev/sda ?

Re: single HDD LVM convert to RAID1 without LVM Problems

Posted: 2012/03/06 13:47:42
by pschaff
GRUB will boot from ext4 on software RAID1. I can't spot the problem but you will need to boot from the RAID to accomplish your goal. I'd fix the GRUB entry of /dev/md0, make it the first disk, and if still having problems, then read:
http://wiki.centos.org/TipsAndTricks/TroubleshootGRUB
http://wiki.centos.org/TipsAndTricks/ReinstallGRUB