On Mon, 2005-04-04 at 10:27 +0200, Mimmus wrote: > I have an already existing filesystem (on /dev/sde1) and I'd like to mirror > it on a new fs (on /dev/sdh1) using 'md', saving its content. > I think that command: > mdadm --create /dev/md0 --level=1 --raid-device=2 /dev/sde1 /dev/sdh1 > makes the work but I need confirmation that filesystem on /dev/sde1 will be > not lost. First: always make sure you have a backup when doing stuff like this. Even if you are certain you know what you are doing, it only takes one wrong command to wipe all your data out. It was my understanding that when a raid device was created a raid superblock was written to the very end of the block device. If this is indeed the case, then you would be overwriting whatever it located at the end of your filesystem on that block device. Furthermore, I think that since the system will have no way of know which of the two block devices has the "correct" copy of the data, it might resync the two block devices to match pulling data from both of them resulting in a garbled mess. Here is what has worked for me (assuming two block devices of equal size): 1) Create a degraded array on your new block device: # mdadm --create /dev/md0 --level=1 --raid-device=2 missing /dev/sdh1 The "missing" keyword will create a degraded RAID-1 array with a placeholder for a missing device. To see the state of the array: # cat /proc/mdstat 2) Create the filesystem on your new array device: # mke2fs -j /dev/md0 (or whatever is appropriate) 3) Mount the new array somewhere on your filesystem 4) Copy all the data from the old filesystem on /dev/sde1 to the new filesystem on /dev/md0 5) When you are sure all data has been copied properly, umount the filesystem on /dev/sde1. You can keep /dev/md0 mounted. 6) Add /dev/sde1 into /dev/md0. This will DESTROY ALL THE DATA on /dev/sde1 so be very sure that /dev/md0 has the data copied on it. It will put /dev/sde1 into the array and sync it's contents with what is on /dev/sdh1. # mdadm --manage /dev/md0 --add /dev/sde1 7) Check to see if it is syncing the array: # cat /proc/mdstat You may have to do some extra steps to ensure they get started properly at boot. I set my partition types to type "fd" for auto-detect. Hope that helps... Sean
Attachment:
signature.asc
Description: This is a digitally signed message part