3

I have a remote server (no physical access to it) that I need to clone locally. So, I attached a secondary HD to a local linux server, created the partitions boot, swap and root and rsync'd all the data from the remote server. The copy went smoothly but when I try to activate grub so the new drive is bootable this is what happens (the remote server has LVM partitions while on the local drive I just created boot, swap and root normally):

I mount the copied image this way:

mount /dev/sdb3 /mount && mount /dev/sdb1 /mount/boot/

mount --bind /dev /mount/dev && mount --bind /dev/pts /mount/dev/pts && mount --bind /proc /mount/proc && mount --bind /sys /mount/sys
chroot /mount

Then I attempt to install grub:

grub-install /dev/sdb

Could not find device for /dev/mapper/VolGroup-lv_root

The file /boot/grub/stage1 not read correctly.

(and I tried to boot into this drive but I get a "grub rescue" prompt)

/dev/mapper/VolGroup-lv_root is the root partition of the remote server. I don't know what I need to do here. I tried removing the /boot/grub/ folder attempting a fresh grub install but the same happens. How can I tell grub that now the root partition is /dev/sda3 or how would you go about fixing this?

grub.conf file:

default=0

timeout=5

splashimage=(hd0,0)/grub/splash.xpm.gz

hiddenmenu

title Red Hat Enterprise Linux Server (2.6.32-573.7.1.el6.x86_64)

        root (hd0,0)

        kernel /vmlinuz-2.6.32-573.7.1.el6.x86_64 root=/dev/sda1

        initrd /initramfs-2.6.32-573.7.1.el6.x86_64.img

fdisk -l output on the cloned drive:

   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1   *           1          66      524288   83  Linux

Partition 1 does not end on cylinder boundary.

/dev/sdb2              66        2155    16777216   82  Linux swap / Solaris

Partition 2 does not end on cylinder boundary.

/dev/sdb3            2155       41774   318241792   83  Linux

Partition 3 does not end on cylinder boundary.
2
  • You'll certainly need to update fstab, if you haven't already. That might well be where grub-install gets its device ideas.
    – Tom Hunt
    Commented Nov 30, 2015 at 16:52
  • Thanks Tom. I forgot to mention that but I did update fstab before installing grub, so grub is getting the LVM info elsewhere.
    – user145403
    Commented Nov 30, 2015 at 17:43

1 Answer 1

1

You'll need to update both the /etc/fstab file and also the GRUB configs to reflect the change from LVM to not LVM. If you're using original GRUB (ie the better version of GRUB) you can just make the device changes in /boot/grub/grub.conf. If you're using GRUB2 (ie. the annoying version of GRUB) you'll need to change a bunch of files that are most likely located in /etc/defaults/grub/. It may be worth the time to do a search of the whole /etc directory for something like 'VolGroup' just to see where all the LVM devices are referenced because there may be other services referring to the actual device instead of the mount (specifically, udev?).

grep -r 'VolGroup' /etc

11
  • Thanks, David. I updated fstab before trying to install grub so that's not it. In /etc there's only some files within /dev/lvm with the 'VolGroup' string. In /boot/ only grub/grub.conf comes up with matches, like this: /boot/grub/grub.conf: kernel /vmlinuz-2.6.32-573.7.1.el6.x86_64 ro root=/dev/sda3 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM pcie_aspm=off How can I fix that line? I replaced the old path with /dev/sda3 but I dunno what to do with the rest 'n still won't work.
    – user145403
    Commented Nov 30, 2015 at 17:45
  • Try kernel /vmlinuz-2.6.32-573.7.1.el6.x86_64 ro root=/dev/sda3 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM pcie_aspm=off
    – David King
    Commented Nov 30, 2015 at 18:14
  • There also may be tools to automagically detect your available kernels and rebuild the grub.conf file. If those exist and what they're called would be distro dependent but given the complexity of that kernel line I'm guessing it wasn't written by hand.
    – David King
    Commented Nov 30, 2015 at 18:16
  • The grub file has #Generated by Anaconda. Now after boot I just get a grub> prmpt. If I type "ls" I get: (hd0)(hd0,msdos3)(hd0,msdos2)(hd0,msdos1)(fd0) But the grub.conf file has: title Red Hat Enterprise Linux Server (2.6.32-573.7.1.el6.x86_64) root (hd0,0) kernel /vmlinuz-2.6.32-573.7.1.el6.x86_64 ro root=/dev/sda3 rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 rhgb crashkernel=auto quiet KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM pcie_aspm=off initrd /initramfs-2.6.32-573.7.1.el6.x86_64.img Should I change where it says "root (hd0,0)" to "root(hd0,msdosX)?
    – user145403
    Commented Nov 30, 2015 at 18:43
  • I did some Googling and didn't find much on anaconda. I normally write my grub.conf files by hand but it's been a while since I've used a separate /boot partition so I'm a little rusty on the details. I thin all you need on the kernel line is kernel /vmlinuz-2.6.32-573.7.1.el6.x86_64 root=/dev/sdb1
    – David King
    Commented Nov 30, 2015 at 18:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .