HowTo: Transfer old software RAID1 to new disks - stefan -  2008-10-13
 
 
 
Hi, 
 
my goal is to substitute two mirrored IDE disks, 160GB each, for 2x 500GB SATA drives - keeping the /dev/md0 layout for rootfs (Suse 10.1) and the Data partition /dev/md1 will just have more space. 
 
  
 
I'm failing in making the new drives bootable. 
 
(see below, end of the post: 
 
mdadm: no devices found for /dev/md0.) 
 
  
 
Here's what I did: 
 
  
 
  
 
Connect the new disks additionally (sda und sdb) 
 
  
 
## 1st is to backup the drive partition tables: 
 
  
 
 
 
Code: mkdir /raidinfo 
sfdisk -d /dev/hda > /raidinfo/partitions.hda 
sfdisk -d /dev/hdb > /raidinfo/partitions.hdb 
 
# fdisk -l /dev/hda 
 
Disk /dev/hda: 160.0 GB, 160041885696 bytes 
255 heads, 63 sectors/track, 19457 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
 
  Device Boot      Start         End      Blocks   Id  System 
/dev/hda1               1         131     1052226   82  Linux swap / Solaris 
/dev/hda2   *         132        4048    31463302+  fd  Linux raid autodetect 
/dev/hda3            4049       19456   123764760   fd  Linux raid autodetect 
 
#(hdb is identical to hda)
  
 
 
 
  
 
## With "fdisk": 
 
- create sda1 and sdb1 (swap) 
 
- create sda2 and sdb2 (for / type: fd) 
 
- create sda3 and sdb3 (/fileshares type: fd) 
 
- set active partitions sda2 und sdb2. 
 
  
 
 
 
Code: ## fdisk -l /dev/sda 
Disk /dev/sda: 500.1 GB, 500107862016 bytes 
255 heads, 63 sectors/track, 60801 cylinders 
Units = cylinders of 16065 * 512 = 8225280 bytes 
 
  Device Boot      Start         End      Blocks   Id  System 
/dev/sda1               1         131     1052226   82  Linux swap / Solaris 
/dev/sda2   *         132        4048    31463302+  fd  Linux raid autodetect 
/dev/sda3            4049       60801   455868472+  fd  Linux raid autodetect 
 
#(sdb is identical to sda)
  
 
 
 
  
 
## Create both new RAID: 
 
 
 
Code: mdadm --create /dev/md2 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2 
mdadm --create /dev/md3 --level=1 --raid-devices=2 /dev/sda3 /dev/sdb3 
 
watch cat /proc/mdstat  ## Just to check progress. 
 
mkfs.reiserfs /dev/md2  ## Format can be started  
mkfs.reiserfs /dev/md3  ##  during creation of array. 
 
mkdir /mnt/md2 
mkdir /mnt/md3
  
 
 
 
  
 
mcedit /etc/fstab (add md2 + md3 lines) 
 
 
 
Code: /dev/md0    /           reiserfs   acl,user_xattr  1 1 
  /dev/md1    /fileshares reiserfs   acl,user_xattr  1 1 
  /dev/md2    /mnt/md2    reiserfs   acl,user_xattr  1 1 
  /dev/md3    /mnt/md3    reiserfs   acl,user_xattr  1 1 
  /dev/hda1   swap        swap       defaults        0 0 
  /dev/hdb1   swap        swap       defaults        0 0
  
 
 
 
  
 
## Mount new Arrays: 
 
 
 
Code: mount /dev/md2  /mnt/md2   -o acl  -o user_xattr 
mount /dev/md3  /mnt/md3   -o acl  -o user_xattr
  
 
 
 
  
 
## rsync copies also ACLs: 
 
 
 
Code: rsync -v --recursive --times --perms --links --exclude "/mnt/" --exclude \ 
"/proc/"  --exclude "/fileshares/" --exclude "/sys/" -a  /*  /mnt/md2/ 
 
cd /mnt/md2/ %% mkdir mnt %% mkdir proc %% mkdir fileshares %% mkdir sys
  
 
 
 
  
 
# Copy Data partition: 
 
 
 
Code: rsync -v --recursive --times --perms --links  -a /fileshares/* /mnt/md3/
  
 
 
 
  
 
## Set new UUIDs in new mdadm.conf: 
 
 
 
Code: mdadm --detail --scan >> /mnt/md2/etc/mdadm.conf
  
 
 
 
  
 
## Install GRUB onto both new disks: 
 
 
 
Code: chroot /mnt/md2 
grub 
 device (hd0) /dev/sda 
 root (hd0,1)           ## 0,0 = swap, 0,1 = / incl /boot 
 setup (hd0) 
 device (hd1) /dev/sdb 
 root (hd1,1)           ## 1,0 = swap, 1,1 = / incl /boot 
 setup (hd1) 
 quit
  
 
 
 
  
 
mcedit /mnt/md2/etc/fstab 
 
 
 
Code: /dev/md0    /           reiserfs   acl,user_xattr  1 1 
  /dev/md1    /fileshares reiserfs   acl,user_xattr  1 1   
  /dev/sda1   swap        swap       defaults        0 0 
  /dev/sdb1   swap        swap       defaults        0 0
  
 
 
 
  
 
mcedit /mnt/md2/boot/grub/device.map 
 
 
 
Code: (hd0)   /dev/sda 
(hd1)   /dev/sdb
  
 
 
 
  
 
mcedit /mnt/md2/boot/grub/menu.lst 
 
 
 
Code: ###Don't change this comment - YaST2 identifier: Original name: linux### 
title SUSE Linux 10.1 
root (hd0,1) 
kernel /boot/vmlinuz root=/dev/md0 vga=0x31a    resume=/dev/sda1  splash=silent showopts 
initrd /boot/initrd
  
 
 
 
  
 
  
 
poweroff 
 
  
 
Remove hda and hdb. 
 
  
 
Boot from new hard disks: 
 
 
 
Code: ... 
Loading raid1 
md: personality registered for level 1 
Loading reiserfs 
md: md0 stopped. 
mdadm: no devices found for /dev/md0. 
resume /dev/sda1 not founf (ignoring) 
md: md0 stopped. 
mdadm: no devices found for /dev/md0. 
md: md1 stopped. 
mdadm: no devices found for /dev/md1. 
Waiting for device /dev/md0 to appear: ok. 
rootfs: major=9 minor=0 devn=2304 
/dev/md0: unknown volume type 
invalid root filesystem -- exiting to /bin/sh 
$_
  
 
 
 
  
 
Any suggestions will be appreciated! 
 
  
 
One thing that might be the problem is that I swapped the SATA cables from sda and sdb by mistake: 
 
 
 
Code: # mdadm --detail /dev/md2 
/dev/md2: 
    Version : 00.90.03 
 Creation Time : Sat Oct  4 02:38:41 2008 
 Raid Level : raid1 
 Array Size : 31463232 (30.01 GiB 32.22 GB) 
Device Size : 31463232 (30.01 GiB 32.22 GB) 
  Raid Devices : 2 
 Total Devices : 2 
Preferred Minor : 2 
Persistence : Superblock is persistent 
 
Update Time : Sun Oct 12 21:24:25 2008 
      State : clean 
Active Devices : 2 
Working Devices : 2 
Failed Devices : 0 
 Spare Devices : 0 
 
       UUID : ba1944d9:4539b5bb:0fa8b8d3:3798154c 
     Events : 0.1722 
 
Number   Major   Minor   RaidDevice State 
   0       8       18        0      active sync   /dev/sdb2 
   1       8        2        1      active sync   /dev/sda2
  
 
 
 
  
 
If that's the whole problem, how can I fix it now that the users are already writing stuff on /dev/md3 (mounted on: /fileshares)? 
 
 
 
 
 |