Emidio Planamente 's Homepage

Home GNU/Linux Programming Technology Sport Others Contact

Search

  Google linux


Debian

  Apt-get
  Debian Anatomy
  Debian Backports
  Debian Help
  Debian Planet
  Debian Swiss
  History of Debian
  Getdeb
  Kernel
  Kernel 2.6
  Packages
  Refcard for newbie
  Reference book
  SATA raid
  Weekly News


Official Docs

  Distrowatch
  Firewire
  Gimp
  Gimp Photo Archive
  Linuxdoc
  Linuxdoc Reference
  Linux Focus
  Linux From Scratch
  Linux Hacks
  Linux Hardware
  Linux Printing
  MySQL
  O'Reilly
  Rute
  Source Forge
  USB guide


Installation

  Instalinux
  Preseed


Laptop

  Linux on Laptops
  Linux Toshiba
  Tux Mobil


Live-CDs

  Create it Your self
  Knoppix
  Kororaa XGL 3


Pictures

  Bay13
  Gnomelook
  Kuznetsov


Security

  GNU/Linux
  PortsDB


Linux based product

  Dreambox


Free web service

  S5 presents


Against Micro$oft

  Combatti Micro$oft
  Microsuck


HTML validator CSS validator

 

Software RAID micro howto


1. Software RAID with mdadm

2. Software RAID with raidtools2


1. Software RAID with mdadm


1.1. Installation


Just install mdadm package


  apt-get install mdadm


1.2. Documentation


Take a look in your directory


  /usr/share/doc/mdadm/


1.3. Creating partitions


I prefere to use RAID with partitions instead of disks. Therefore, before proceding, the partitions shall be created.

Use your prefered tools (e.g.: cfdisk) and set the partition type to "FD").


1.4. Autodetecting array


In order to autodetect your array at boot time, the following things are necessary:


- autodetection support in the kernel

- persistent superblocks shall be used (during creating)

- partition types set to FD


The autodetenction is the only way to boot the system from RAID.


1.5. Creating an array


To create a mirror with 2 harddisks (/dev/hda1 and /dev/hdc1):


  mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/hda1 /dev/hdc1


Note: Using "--create" will create superblocks. With "--build" the superblocks are not created.


1.6. Creating an array without all disks


This can be very helpfull when system or data shall be migrated from not RAID to RAID harddisk and you don't have a temporary place to store all.


  mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/hdc1


In this case, the system or data can be in /dev/hda1. Once the raid is working, the system or data can be copied to /dev/md0.

After that, /dev/hda1 can be added to the array with


  mdadm --add /dev/md0 /dev/hda1


1.7. Viewing array status


Very easily, the array status can be monitored with


  mdadm --detail /dev/md0


or if you prefere


  cat /pro/mdstat


1.8. Setting device to faulty


In order to test your array, you can simulate a break setting one device to faulty:


  mdadm --manage --set-faulty /dev/md0 /dev/hda1


1.9. Removing a device


When a device is broken, before removing it physically, it shall be removed from the array:


  mdadm /dev/md0 -r /dev/hda1


1.10. Adding a device


When a broken device has been replaced, it shall be added to the array:


  mdadm /dev/md0 -a /dev/sda1


1.11. Monitoring array


To monitor the array with a daemon:


  dpkg-reconfigure mdadm


dirty way:


  mdadm --monitor --mail=root@localhost --delay=1800 /dev/md0&


This will send a mail to root when something happen.


1.12. Assembling array


To assemble (syncronize) the array:


  mdadm --assemble


Alternatively:


  mdadm --assemble --force


1.13. Configuration file


The configuration file is


  /etc/mdadm.conf


but if you use autodetection, it is not necessary.


1.14. Stopping array


This stops the array, releasing all resources:


  mdadm -S /dev/md0


1.15. Destroying array


The array can't be really destroyed, because there is not a command providing such a feature.


Alternativelly, it is possible to make it not anymore visible to the system. This can be done with the following step.


Removing superblocks


  mdadm --zero-superblock /dev/xxx


where xxx is the device (e.g.: hda1, sda1, ...).

Now, the array will not be anymore automatically detected.


Note: This is enough to make the array invisible to the system, but the data are anyway there! If you want to safe erase them, give a look here: http://www.planamente.ch/emidio/pages/linux_tools_description.php (Secure data deletion).


2. Software RAID with raidtools2


2.1. Introduction


This tool is depracated. Use mdadm instead.



Emidio Planamente

Last modified on 2024-08-02