Tested into a Debian 8 distro with raid5 and raid1.
Migrate any existing system ext3 (multiple or single partitions) with a stand alone hdd on a Software replicated raid.
Install mdadm before the system is replicated on the new array or chrooting will be neccesary for booting the future system on the raid.
apt-get install mdadm
#with ubuntu like
sudo apt-get remove dmraid
Retrive disks infos
fdisk -l
Create partitions on the new drives before building the array.
Grub partition need at lest of 1MB but it can be more in the future.
parted /dev/sda unit kb p free #if needed with fresh drives : mklabel gpt mkpart primary ext3 0 10M mkpart primary ext3 10M 100% #(very important) set 1 bios_grub on p free q partprobe /dev/sda partprobe /dev/sdb
And do th same for each drives of the future array, grub will be installed on each disks.
Other way for flag grub_on
parted /dev/sda1 set 1 bios_grub on parted /dev/sdb1 set 1 bios_grub on
Create the filesystem for raid on all disks
mkfs -t ext3 /dev/sda2 mkfs -t ext3 /dev/sdb2
Create the array (here raid1)
mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2
View live progression very long for 2TB drives
watch -n 1 cat /proc/mdstat
Create filesystem on the raid.
-m 2 for 2% of inodes
-m 2 pour 2% d'inodes
mkfs.ext3 /dev/md0 -m 2
Put a new line in the fstab
blkid nano /etc/fstab
UUID=87b54395-1737-435b-b2a8-b4120ee4060d / ext3 relatime 0 0
Update mdadm.
cat /etc/mdadm/mdadm.conf mdadm --detail --scan --verbose >> /etc/mdadm/mdadm.conf cat /etc/mdadm/mdadm.conf
Mount it.
mkdir /media/raid1/ && mount /dev/md0 /media/raid1/ && df -h && cd /media/raid1/
At this time, synchronize the actual system on the raid.
rsync -aAXv --stats --progress /* /media/raid1/ --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/net*,/lost+found}
Chroot in the future live system.
cd /media/raid1/ mount -t proc proc proc/ mount --rbind /sys sys/ mount --rbind /dev dev/ chroot /media/raid1 /bin/bash
Update the fstab with goods uuid.
blkid cp /etc/fstab /etc/fstab.bkp nano /etc/fstab
Install grub on all drives of the array.
grub-install /dev/sda grub-install /dev/sdb update-grub #or update-grub2
Update the initial ram disk for automount the array during boot
update-initramfs -u
Exit from chroot and reboot, in my case, I unplug the old harddrive
All should run like a charm included grub.
fdisk -l
Attention : identifiant de table de partitions GPT (GUID) détecté sur « /dev/sdb » ! L'utilitaire sfdisk ne prend pas GPT en charge. Utilisez GNU Parted.
Disque /dev/sdb : 2000.4 Go, 2000398934016 octets
255 têtes, 63 secteurs/piste, 243201 cylindres, total 3907029168 secteurs
Unités = secteurs de 1 * 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 4096 octets
taille d'E/S (minimale / optimale) : 4096 octets / 4096 octets
Identifiant de disque : 0x00000000
Périphérique Amorce Début Fin Blocs Id Système
/dev/sdb1 1 3907029167 1953514583+ ee GPT
La partition 1 ne commence pas sur une frontière de cylindre physique.
Attention : identifiant de table de partitions GPT (GUID) détecté sur « /dev/sda » ! L'utilitaire sfdisk ne prend pas GPT en charge. Utilisez GNU Parted.
Disque /dev/sda : 2000.4 Go, 2000398934016 octets
255 têtes, 63 secteurs/piste, 243201 cylindres, total 3907029168 secteurs
Unités = secteurs de 1 * 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 512 octets
taille d'E/S (minimale / optimale) : 512 octets / 512 octets
Identifiant de disque : 0x00000000
Périphérique Amorce Début Fin Blocs Id Système
/dev/sda1 1 3907029167 1953514583+ ee GPT
Disque /dev/md0 : 2000.3 Go, 2000262529024 octets
2 têtes, 4 secteurs/piste, 488345344 cylindres, total 3906762752 secteurs
Unités = secteurs de 1 * 512 = 512 octets
Taille de secteur (logique / physique) : 512 octets / 4096 octets
taille d'E/S (minimale / optimale) : 4096 octets / 4096 octets
Identifiant de disque : 0x00000000
Le disque /dev/md0 ne contient pas une table de partitions valable
Links helped me:
http://velenux.wordpress.com/2012/07/12/grub-failing-to-install-on-debianubuntu-with-gpt-partitions/
http://forums.linuxmint.com/viewtopic.php?f=90&t=95928
http://forums.debian.net/viewtopic.php?f=5&t=92810
http://unix.stackexchange.com/questions/28443/does-grub2-support-putting-boot-on-a-raid5-partition
http://askubuntu.com/questions/252795/convert-running-system-to-raid-5
https://wiki.archlinux.org/index.php/Full_System_Backup_with_rsync
https://wiki.archlinux.org/index.php/Change_Root
https://wiki.archlinux.org/index.php/Convert_a_single_drive_system_to_RAID