• I have a one disk, no RAID, no LVM system based on Debian Squeeze (my old system).
  • I created a RAID array (RAID 5, 4 HDDs) with mdadm (my new system).
  • I installed LVM2 on the new system and created several LVs.
  • I migrated the folders (/,/boot,/home,/var/,/tmp,/usr) of the old system in the respective LVs (lv_root,lv_boot,lv_home,lv_var,lv_tmp,lv_usr) by using rsync.
  • Note that my boot is in LVM, not outside.

How do I proceed for the following tasks (I didn't find any good tutorials for my level of knowledge):

  • Once the RAID array is created, how can I build a mdadm.conf file on the new system?
  • How can I create a fstab file on the new system
  • How can I install Grub2 in /boot and configure the four disks in order to boot from any?

After these tasks, I should be able to shutdown my machine, remove the HDD with the old system, restart the machine and the new system should boot.

  • So the new system is a installation from scratch (Debian Wheezy?)? What folders did you migrate from the old system - just /home and stuff like that, or also parts of the system itself (/usr, ...)? If it's an installation from scratch, the Debian installer should have taken care of the tasks that you list. Jan 28, 2014 at 17:31
  • see my new text according to your question. It's not a scratch.
    – Bertaud
    Jan 28, 2014 at 17:45

1 Answer 1


So you're inside a rescue system now? You need mount all these LVs somewhere, for example to /mnt/target:

  • lv_root -> /mnt/target/
  • lv_boot -> /mnt/target/boot
  • lv_home -> /mnt/target/home
  • ...

Then you need to bind-mount the kernel filesystems:

for i in proc sys run dev; do mount --bind /$i /mnt/target/$i; done

Now you can change into this "dead" system with chroot:

chroot /mnt/target

You are now inside the system, as if you had booted into it; that is, / is now no longer the old / from your rescue system, but the root LV.

Create the mdadm.conf:

/usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf

Check it manually with an editor to see if everythings OK.

Create the device.map for grub:


Check that manually too. Install grub to all disks (put in the correct disk names here):

grub-install /dev/sda
grub-install /dev/sdb

Manually adapt you /etc/fstab so that all LVs are mounted to their correct mount points.

Regenerate the grub config and the initramfs:

update-initramfs -u
  • Very good info for me. I am inside the old system, not a rescue system. I didn't migrate the content of the /sys et /proc folders. Shall I do it ? Chroot was missing in my knowledge ! How can I terminate this function ? Before the device.map creation, I suppose that I must install or verify that Grub2 is in the boot folder, correct ?
    – Bertaud
    Jan 28, 2014 at 23:06
  • @Bertaud It's usually wise to do migrations like these from some kind of rescue system, because a) you're guaranteed that the old system won't change during or after you've copied the files to the new system (for example, if you have a mail server running, it might accept an incoming mail after you've already copied the mail spool. This mail is lost when you switch to the new system) and b) you can access the whole filesystem without having to worried about overmounted folders like /dev. Jan 29, 2014 at 0:00
  • "I didn't migrate the content of the /sys et /proc folders. Shall I do it?" - no, do not try to copy the contents of /proc and /sys, because these are virtual filesystems. You really don't want to try to copy files like /proc/kcore ;). Instead, create them as empty folders in the target filesystem, and then mount-bind them so you can successfully chroot into it. Jan 29, 2014 at 0:03
  • Ok. I will try tomorow because it's 01:00 am ;-) I appreciated your explanation. Gute Nacht.
    – Bertaud
    Jan 29, 2014 at 0:08
  • my mdadm.conf seems to be strange: ARRAY /dev/md/0 metadata=1.2 UUID=... name=... I expected /dev/md0
    – Bertaud
    Jan 29, 2014 at 13:39

You must log in to answer this question.

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