User Tools

Site Tools


computing:storage:linux_software_raid

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
computing:storage:linux_software_raid [2011/11/27 10:28]
gcooper created
computing:storage:linux_software_raid [2019/10/25 10:42] (current)
gcooper
Line 2: Line 2:
  
 http://wiki.centos.org/HowTos/SoftwareRAIDonCentOS5 http://wiki.centos.org/HowTos/SoftwareRAIDonCentOS5
 +
 http://wiki.xtronics.com/index.php/Raid http://wiki.xtronics.com/index.php/Raid
 +
 http://robbat2.livejournal.com/231207.html http://robbat2.livejournal.com/231207.html
 +
 https://raid.wiki.kernel.org/index.php/Linux_Raid https://raid.wiki.kernel.org/index.php/Linux_Raid
 +
 http://archive.networknewz.com/2003/0113.html http://archive.networknewz.com/2003/0113.html
  
 Works on block devices, usually partitions.  This is not like strictly-drive-oriented hardware RAID controllers. Works on block devices, usually partitions.  This is not like strictly-drive-oriented hardware RAID controllers.
  
-**Show Existing RAID**+===== Show Existing RAID =====
  
-mdadm --detail --scan+<file> 
 +mdadm --detail --scan --verbose 
 +</file>
  
-**Partitioning**+===== Partitioning =====
  
-''fdisk /dev/sda'''' +<file> 
-'' +fdisk -l /dev/sda 
-Using fdisk, create matching partitions on various drives (block devices) of type "fd  Linux raid autodetect" that will be assembled into arrays. +</file>
-'' +
-sfdisk -l /dev/sda''''+
  
-Disk /dev/sda'''': 8942 cylinders, 255 heads, 63 sectors/track+or 
 + 
 +<file> 
 +sgdisk -p /dev/sda 
 +</file> 
 + 
 +**Copy Patition Scheme**: https://askubuntu.com/questions/57908/how-can-i-quickly-copy-a-gpt-partition-scheme-from-one-hard-drive-to-another/333923 
 + 
 +:!: Verify ''sfdisk'' recognizes your source partitions.  If not, try ''sgdisk''
 + 
 +Using fdisk, create matching partitions on various drives (block devices) of type **fd  Linux raid autodetect** that will be assembled into arrays. 
 + 
 +<file> 
 +sfdisk -l /dev/sda 
 + 
 +Disk /dev/sda: 8942 cylinders, 255 heads, 63 sectors/track
 Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0 Units = cylinders of 8225280 bytes, blocks of 1024 bytes, counting from 0
  
-   Device Boot Start     End   #cyls    #blocks   Id  System +Device      Boot  Start     End    #cyls    #blocks  Id  System 
-/dev/sda1''''   *      0+    242     243-   1951866   fd  Linux raid autodetect +/dev/sda1           0+    242     243-   1951866   fd  Linux raid autodetect 
-/dev/sda2''''        243     485     243    1951897+  fd  Linux raid autodetect +/dev/sda2           243     485     243    1951897+  fd  Linux raid autodetect 
-/dev/sda3''''        486     607     122     979965   82  Linux swap+/dev/sda3           486     607     122     979965   82  Linux swap 
 +</file>
  
-''Once you partition the first drive, use sfdisk to duplicate partitions from that first drive to other drives: +:!: Be careful not to write to the **wrong disk** or you will have a **very bad day**!
-'' +
-sfdisk -d /dev/sda'''' | sfdisk /dev/sd[b''cd]+
  
-**Create Arrays**+Once you partition the first drive, use ''sfdisk'' or ''sgdisk'' to replicate partitions from that first drive to other drives: 
 + 
 +<file> 
 +sfdisk -d /dev/sda | sfdisk /dev/sdb 
 +</file> 
 + 
 +or 
 + 
 +<file> 
 +sgdisk /dev/sda -R /dev/sdb 
 +sgdisk -G /dev/sdb 
 +</file> 
 + 
 +===== Create Arrays =====
  
 http://robbat2.livejournal.com/231207.html http://robbat2.livejournal.com/231207.html
 +
 http://en.wikipedia.org/wiki/Mdadm http://en.wikipedia.org/wiki/Mdadm
  
 +<file>
 mdadm --create <[[array]]_device> -c <chunk_size> -l <raid_level> -n <active_disks> -x <spare_disks> <block_devices> mdadm --create <[[array]]_device> -c <chunk_size> -l <raid_level> -n <active_disks> -x <spare_disks> <block_devices>
 +</file>
  
-Here is a four-drive RAID5 example where one drive is a hot spare.  Hot spare drives can serve multiple arrays (spare-group).+Here is a four-drive (partition) RAID5 example where one drive (partition) is a hot spare.  Hot spare drives can serve multiple arrays (spare-group).
  
 +<file>
 mdadm --create /dev/md0 --level=5 --raid-devices=3 --spare-devices=1 --spare-group=groupname /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 mdadm --create /dev/md0 --level=5 --raid-devices=3 --spare-devices=1 --spare-group=groupname /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1
 +</file>
  
-http://www.kernelhardware.org/linux-add-share-hot-spare-device-software-raid/+===== Add a Drive =====
  
-**Add a Drive**+http://www.kernelhardware.org/linux-add-share-hot-spare-device-software-raid/
  
-mdadm --detail --scan+<file> 
 +mdadm --detail --scan --verbose
  
 mdadm --add /dev/md0 /dev/sdb1 mdadm --add /dev/md0 /dev/sdb1
 mdadm --add /dev/md1 /dev/sdb2 mdadm --add /dev/md1 /dev/sdb2
 mdadm --add /dev/md2 /dev/sdb3 mdadm --add /dev/md2 /dev/sdb3
 +</file>
  
-**Create Conf FIle**+===== Create Configuration File =====
  
 +Not sure how beneficial or necessary this step is...
 +
 +<file>
 mdadm --detail --scan > /etc/mdadm/mdadm.conf mdadm --detail --scan > /etc/mdadm/mdadm.conf
 +</file>
  
-or  (Centos)+or for Centos:
  
 +<file>
 mdadm --detail --scan --verbose > /etc/mdadm.conf mdadm --detail --scan --verbose > /etc/mdadm.conf
 +</file>
 +
 +===== MBR and GRUB =====
 +
 +==== MBR ====
 +
 +http://www.cyberciti.biz/faq/howto-copy-mbr/
 +
 +Assuming you have identical disks with identical partitioning, use this command to copy the entire master boot record (boot code plus partition table) like this, adjusting for your needs:
 +
 +<file>
 +dd if=/dev/sda of=/dev/sdb bs=512 count=1
 +</file>
 +
 +==== GRUB ====
 +
 +http://wiki.centos.org/HowTos/GrubInstallation
 +
 +<file>
 +grub
 +</file>
 +
 +If you have a separate /boot partition:
 +
 +<file>
 +grub> find /grub/stage1
 +</file>
 +
 +If you don't:
 +
 +<file>
 +grub> find /boot/grub/stage1
 +</file>
 +
 +Then, based on the output of the find command:
 +
 +<file>
 +grub> root (hd0,0)
 +grub> setup (hd2)
 +</file>
  
-Last changed (in Tomboy): 2011-05-02 
-Note created (in Tomboy): 2010-12-18 
  
computing/storage/linux_software_raid.1322414884.txt.gz · Last modified: 2011/11/27 10:28 by gcooper