initial commit

This commit is contained in:
Christoph 2024-02-05 16:17:34 +01:00
commit 4fc1a5ab54
4 changed files with 328 additions and 0 deletions

179
README.mdadm Normal file
View File

@ -0,0 +1,179 @@
# ---
# - 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 <md-device> <partition-device>
## - remove device fom raid-array
## -
mdadm -r <md-device> <partition-device>
## - (re)add device to raid-array
## -
mdadm -a <md-device> <partition-device>
## - Raid Array ist im auto-read-only status
## -
## - Ändern durch:
## -
mdadm --readwrite /dev/md<n>
## - send a testmessage
## -
mdadm --monitor --test -1 --scan
## - or just for one md-array
## -
mdadm --monitor --test -1 </dev/md?>
## - Print detail
## -
mdadm -D </dev/md?>
# ---
# - MBR-Partitionstabelle sichern und wiederherstellen
# ---
## - Save partitiontable
## -
sfdisk -d /dev/sdb > partitions.sdb.txt
## - Rrestore partitiontable
## -
cat partitions.sdb.txt | sfdisk /dev/sdb

View File

@ -0,0 +1,55 @@
# --------------------
# RAID 1 of /boot/efi partition on Debian
# --------------------
# see: https://unix.stackexchange.com/questions/644108/raid-1-of-boot-efi-partition-on-debian
The steps are mainly:
1.) Install Debian without setting up the RAID for the ESP partition.
During the partitioning, I've already created two identical partitions
marked as ESP partitions. They were on /dev/sda1 and /dev/sdb1
2.) umount /boot/efi
3.) Copie the contents of /boot/efi somewhere else (/boot/eficopy).
4.) Create an array for use as EFI partion.
NOTE:
use metadata version 1.0
Version 1.0 still has the requirement (for this usecase) of placing the
superblock at the end of the device, but also includes "the modern features of mdadm",
by using common layout format as 1.1 & 1.2.
# mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 --metadata=1.0 /dev/sda1 /dev/sdb1
5.) mkfs.vfat /dev/md3
6.) found the UUID of the partition in /dev/disk/by-uuid:
# ls -al /dev/disk/by-uuid/
7.) Changed the /boot/efi entry in /etc/fstab with the new UUID
for example:
UUID=C354-2922 /boot/efi vfat umask=0077 0 1
8.) mount /boot/efi
9.) Copy the data from the backup into /boot/efi again
10.) Update initramfs:
# update-initramfs -u -k all

14
README.rename-array Normal file
View File

@ -0,0 +1,14 @@
# ---
# - Rename /dev/md126 to /devmd2
# ---
mdadm --stop /dev/md126
mdadm --assemble --update=name --name=<HOSTNAME>:2 /dev/md2 /dev/sdc1 /dev/sdd1 /dev/sde1 /dev/sdf1
# - Take care /etc/mdadm/mdadm.conf is up-to-date
# -
mdadm --examine --scan --config=mdadm.conf
# - Make the changes known to initramfs
# -
update-initramfs -u -k all

View File

@ -0,0 +1,80 @@
# ---
# - Festplattenaustausch im Software-RAID
# ---
1.) alle an raid-arrays beteiligten partitionen der defekten platte aus
den entsprechenden arrays entfernen
## - falls nicht schon vom system suspendiert und als fehlerhaft
## - gekennzeichnet muss das nun passieren.
##
mdadm -f <md-device> <partition-device>
## - remove device fom raid-array
## -
mdadm -r <md-device> <partition-device>
2.) Platte tauschen
## - festplatttenmodell und seriennummer auslesen
##
hdparm -I /dev/sdb | grep Number
3.) Festplatte partitionieren
## - Beide Festplatten im Array müssen die exakt gleiche Partitionierung
## - haben. Die Partitionstabelle einer Festplatte lässt sich mittels dd
## - einfach auf eine andere kopieren.
## -
## - Hierbei wird auch gleich der Bootloader mitkopiert.
## -
MBR-Partitionstabelle
=====================
## - !! Defekte Platte: /dev/sdb !!
## -
dd if=/dev/sda of=/dev/sdb count=1 bs=512 # falls die Platte /dev/sdb
^^ # ausgetauscht wurde
defekte Platte
## - oder alternativ
## -
sfdisk -d /dev/sda | sfdisk /dev/sdb
^^
defekte Platte
## - Partitionstabelle vom Kernel neu eingelesen
## -
sfdisk -R /dev/sdb
GUID-Partitionstabelle (GPT)
============================
## - !! Defekte Platte: /dev/sdb !!
## -
sgdisk -R /dev/sdb /dev/sda
^^
defekte Platte
## - Anschließend neue zufällig UUID vergeben
## -
sgdisk -G /dev/sdb
4.) Partionen dem Raid-Array wieder zufügen
mdadm -a <md-device> <partition-device>
## -
## - Ende: Festplattenaustausch im Software-RAID
## - Request identification info directly from the drive
## -
hdparm -I /dev/<device>