# --- # - Speedup rebuilding and re-syncing linux software raid # --- ## - http://www.cyberciti.biz/tips/linux-raid-increase-resync-rebuild-speed.html ## - echo 200000 > /proc/sys/dev/raid/speed_limit_max echo 200000 > /proc/sys/dev/raid/speed_limit_min ## - swap device /dev/md0 (auto.read-only) ## - swapoff -a mkswap /dev/md0 swapon -a # --- # - (Re)activate inactiv array /dev/md0 # --- mdadm --manage /dev/md0 --run # --- # - Completely removing a mdadm raid array # --- ## - # cat /proc/mdstat ## - Personalities : [raid1] [raid6] [raid5] [raid4] [linear] [multipath] [raid0] [raid10] ## - md1 : active raid1 sda3[0] sdb3[1] ## - 80533504 blocks super 1.2 [2/2] [UU] ## - ... ## - # - See details # - mdadm --detail /dev/md1 # - Unmount raid array if mounted # - umount /dev/md1 # - Completly remove /dev/md2 # - mdadm --stop /dev/md1 mdadm --remove /dev/md1 # - zero the superblock FOR EACH drive # - mdadm --zero-superblock /dev/sda3 mdadm --zero-superblock /dev/sda6 # - Make the changes known to initramfs # - update-initramfs -u -k all # --- # - Create an array with ONLY 1 DEVICE # --- ## - This can be useful, if having a harddisk previosly configured/used ## - in a raid 1 array. ## - ## - Create raid 1 array with onlx device /dev/sda1 ## - mdadm --create /dev/md0 -l 1 -n 2 /dev/sda1 missing ## - Complte the raid array: ## - ## - Adding device /dev/sb1 into array /dev/md0 ## - mdadm -a /dev/md0 /dev/sdb1 # --- # - Create an new raid1 array on /dev/sdb1 /dev/sdc1 # --- mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sd[bc]1 # - write out confile - so the mdadm daemon can read it at startup and # - mount the devices # - cd /tmp echo 'DEVICE /dev/sdb1 /dev/sdc1' > mdadm.conf mdadm --examine --scan --config=mdadm.conf >> mdadm.conf echo 'MAILADDR ckubu@so36.net' >> mdadm.conf cp mdadm.conf /etc/mdadm/mdadm.conf rm /tmp/mdadm.conf # - Make the changes known to initramfs # - update-initramfs -u -k all ## - !! IMPORTANT !! ## - make sure do format the md device NOT the devices included ## - in the array ## - ## - Notice - Lazy Initialization: ## - ## - For creation of an ext4-filesystem, cleaning up (initializing) inode tables ## - and also initializing journal file are needed. Eanabling lazy ## - initialization speeds up the creation, and do that after mounting first ## - time. This is enabled by default. ## - ## - to disable lazy initialation use: ## - ## - mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0 ## - ## - Die "-m" Option reserviert soviel Prozent (hier: 0 Prozent) des Speichers ## - für den Superuser. Vergisst man die Option anzugeben, werden standardmäßig 5% ## - des Speicherplatzers für den Superuser reserviert. ## - mkfs.ext4 -m0 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0 mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0 mkfs.ext4 /dev/md0 # --- # - Verschiedene 'mdadm' Operationen.. # --- ## - stop md device /dev/md0 ## - mdadm --stop /dev/md0 ## - start md device /dev/md0 ## - ## - -A = --assemble ## - -s = --scan ## - mdadm -As /dev/md0 ## - als defekt markieren. Damit stoppt die Verwendung: ## - mdadm -f ## - remove device fom raid-array ## - mdadm -r ## - (re)add device to raid-array ## - mdadm -a ## - Raid Array ist im auto-read-only status ## - ## - Ändern durch: ## - mdadm --readwrite /dev/md ## - send a testmessage ## - mdadm --monitor --test -1 --scan ## - or just for one md-array ## - mdadm --monitor --test -1 ## - Print detail ## - mdadm -D # ===== # - MBR-Partitionstabelle sichern und wiederherstellen # ===== ## - Save partitiontable ## - sfdisk -d /dev/sdb > partitions.sdb.txt ## - Restore partitiontable ## - cat partitions.sdb.txt | sfdisk /dev/sdb ## - oder ## - sfdisk /dev/sdb < partitions.sdb.txt # ===== # - Restore (replicate) partition table on /dev/sdb (defet device) from /dev/sda (undemaged device) # ===== ## - Replicate GPT partition scheme from /dev/sda to /dev/sdd (useful for RAID array rebuild) ## - ## - !! Faulty device: /dev/sdb !! ## - sfdisk -d /dev/sda | sfdisk /dev/sdb ## - oder (force) ## - sfdisk -d /dev/sda | sfdisk -f /dev/sdb ^^^^^^^^ faulty device # ===== # - GPT Partitionstabelle sichern und wiederherstellen # ===== ## - Save partitiontable ## - ## - sgdisk --backup={/path/to/file} {/dev/device/here} ## - sgdisk --backup=/root/partitions.sdg.txt /dev/sdg ## - Restore partitiontable ## - ## - sgdisk --load-backup={/path/to/file} {/dev/device/here} ## - sgdisk --load-backup=/root/partitions.sdg.txt /dev/sdg # ===== # - Restore (replicate) partition table on /dev/sdg (defet device) from /dev/sdd (undemaged device) # ===== ## - Replicate GPT partition scheme from /dev/sda to /dev/sdd (useful for RAID array rebuild) ## - ## - !! Faulty device: /dev/sdg !! ## - sgdisk -R /dev/sdg /dev/sdd ^^ faulty device ## - Anschließend neue zufällig GUID vergeben ## - sgdisk -G /dev/sdd