Aleksandar Milivojevic
2006-Apr-12 14:55 UTC
[CentOS] Building software RAID mdmad adding a second disk
Quoting israel.garcia at cimex.com.cu:> How can I build a RAID 1 of all my particions of sda using mdadm?1. Boot into rescue mode. 2. Shrink each file system a bit. Generally you'll use resize2fs utility. MD uses some space at the end of partition for its metadata, and you don't want this to overwrite the end of your filesystem. Most HOWTOs on the net list this as one of the last steps (after mirrors are created). However if you do this as last step, in rare cases it may lead to data loss. You probably want to be on the safe side and shrink file systems first (this will insure your data is secure). I'm not sure by how much you need to shrink, should be somewhere in documentation how many sectors at end of partition MD uses for metadata... 3. Create mirror(s) using mdadm. Create using only one real partition and use "missing" instead of second partition (wish Anaconda installer would allow for something like this). Then use mdadm to add second partition to the mirror. Something like: # mdadm --create /dev/md0 --run --level=1 --raid-devices=2 /dev/sda1 missing # mdadm /dev/md0 -a /dev/sdb1 4. Edit /etc/fstab file. 5. You'll need to rebuild initrd image(s) for installed kernel(s). Just mount your filesystems somewhere, chroot into it and run mkinitrd. Mkinitrd should be smart enough to figure it'll need md device drivers by looking into fstab file. Use -v option to mkinitrd to make sure it included needed drivers into new initrd image. 6. Configure boot loader (LILO or Grub, whicever you use) to reflect changes. Make sure you install boot loader into MBR of both drives. -- See Ya' later, alligator! http://www.8-P.ca/
israel.garcia at cimex.com.cu
2006-Apr-12 15:17 UTC
[CentOS] Building software RAID mdmad adding a second disk
I'am running CentOS 4.3 on an (Intel) with one SATA disk (/dev/sda). The output of fdisk -l: Disk /dev/sda: 81.9 GB, 81964302336 bytes 255 heads, 63 sectors/track, 9964 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 19 152586 83 Linux /dev/sda2 20 2569 20482875 83 Linux /dev/sda3 2570 2700 1052257+ 82 Linux swap /dev/sda4 2701 9964 58348080 5 Extended /dev/sda5 2701 9964 58348048+ 83 Linux So, I have an identical second disk (sdb) connected... My question is: How can I build a RAID 1 of all my particions of sda using mdadm? Something like this: /dev/md0 --> /dev/sda1 and /dev/sdb1 /dev/md1 --> /dev/sda2 and /dev/sdb2 /dev/md2 --> /dev/sda5 and /dev/sdb5 Regards Israel
israel.garcia at cimex.com.cu
2006-Apr-13 13:29 UTC
[CentOS] Re: Building software RAID mdmad adding a second disk
Thanks Alexandar for your soon answer, BUT, is there another easier way to do this? Regards, Israel>>Quoting israel.garcia at cimex.com.cu:> >>How can I build a RAID 1 of all my particions of sda using mdadm?>>1. Boot into rescue mode.>>2. Shrink each file system a bit. Generally you'll use resize2fs >>utility. MD uses some space at the end of partition for its metadata,>>and you don't want this to overwrite the end of your filesystem. Most>>HOWTOs on the net list this as one of the last steps (after mirrorsare>>created). However if you do this as last step, in rare cases it may >>lead to data loss. You probably want to be on the safe side andshrink>>file systems first (this will insure your data is secure). I'm not >>sure by how much you need to shrink, should be somewhere in >>documentation how many sectors at end of partition MD uses for >>metadata...>>3. Create mirror(s) using mdadm. Create using only one real partition>>and use "missing" instead of second partition (wish Anaconda installer>>would allow for something like this). Then use mdadm to add second >>partition to the mirror. Something like:>># mdadm --create /dev/md0 --run --level=1 --raid-devices=2 /dev/sda1 >>missing >># mdadm /dev/md0 -a /dev/sdb1>>4. Edit /etc/fstab file.>>5. You'll need to rebuild initrd image(s) for installed kernel(s). >>Just mount your filesystems somewhere, chroot into it and runmkinitrd.>> Mkinitrd should be smart enough to figure it'll need md device >>drivers by looking into fstab file. Use -v option to mkinitrd to make>>sure it included needed drivers into new initrd image.>>6. Configure boot loader (LILO or Grub, whicever you use) to reflect >>changes. Make sure you install boot loader into MBR of both drives.>>-- >>See Ya' later, alligator! >>http://www.8-P.ca/