Skip to main content

Primary links

  • Home
  • AI
  • Kubernetes
  • Incus
  • Ansible
  • Terraform
  • OpenStack
  • Virtualization
  • Linux
  • SmartHome
  • HowTo

Misc

  • Linux
    • Ubuntu
    • LTSP
    • HowTo
      • Add proposed repository
      • Anonymous rsync
      • Automatically move photos from memory card to hard drive with udev
      • Change SSH port
      • Compile XBMC
      • Compile lshw
      • Create Gnome menu entry
      • Create SSH netinstall ISO
      • Create squashfs
      • Downgrade Libreoffice to 3.3.4
      • Enable routing
      • Extract RPM
      • Fedora
      • Fix grub on btrfs partition
      • ImageMagic
      • Intel AMT (vPro) under Linux
      • Kernel options
      • Mirror page with wget (e.g. cacti)
      • Mount FTP
      • MultiBootUSB
      • Read SNMP
      • Remotely unlock encrypted root disk using SSH
      • Resize filesystem on LVM
      • SSH VPN server
      • Samba
      • Send HTML mail
      • Skipfish
      • Software RAID
      • Start app on second desktop
      • Sync Time
      • Test network bandwidth
      • Ubuntu DVD-RAM
      • Ubuntu Notify OSD
      • UmountMemoryCard.sh
      • VNC remote help
      • Ventoy
      • VirtualBox host interface
      • access RAID LVM harddisk
      • dd
      • dnsmasq
      • gnome-shell
      • grep, linux
      • hardware, linux
      • lmbench
      • maildroprc
      • meego
      • netcat
      • network bridge
      • nmap
      • processOrder.sh
      • ramdisk
      • rsnapshot
      • rsync
      • rsync
      • sshuttle
      • streamToInternet.sh
      • swapToFile.sh
      • tmux
      • udev
      • upstart
    • BASH
    • Backtrack
    • CUPS
    • CentOS
    • Debian
    • FreeNX
    • GRML
    • Gnome
    • Grub
    • IpFire
    • Kernel
    • Linux Lite
    • SSH
    • UEFI
    • dban
    • logrotate
    • parted
    • proxy
    • systemd
  • Hardware
  • Programming
  • Databases
  • Multimedia
  • Windows

Cloud

  • OpenStack
  • cloud-config
  • nextcloud

Virtualization

  • Virtualization
  • Incus
  • Docker
  • KVM
  • Kubernetes
  • LXC
  • LXD
  • QEMU
  • VMware
  • VirtualBox
  • multipass
  • podman
  • vagrant
  • XEN

Network

  • DNS
  • Firewall
  • Linux
  • OpenvSwitch
  • SSL
  • VLAN
  • VPN
  • iPXE
  • namespaces
  • nmcli
  • tcpdump

Storage

  • CEPH
  • DRBD
  • LVM
  • S3
  • ZFS
  • btrfs

Automation / CI/CD

  • Install
  • Ansible
  • GitLab
  • LLM
  • Preseed
  • Puppet
  • Terraform
  • Ubuntu autoinstall

Monitoring / Visualisation

  • Grafana
  • Icinga
  • Prometheus
  • Monitoring
  • ELK
  • mermaid

create software raid

apt-get install -y mdadm parted --no-install-recommends

# view discs
lshw -short -c disc
sudo mdadm --examine /dev/sd*

# old 
for DEV in sda sdb; do
   umount /dev/${DEV}1
   parted /dev/${DEV} -s rm 1
   #parted /dev/${DEV} -s rm 2
   #dd if=/dev/zero of=/dev/${DEV} bs=1M count=1
   parted /dev/${DEV} -s mklabel msdos
   parted /dev/${DEV} -s mkpart primary 1 256G
   #parted /dev/sda -s mkpart primary 256G 128G
done

# new
for DEV in /dev/sd{x..z}; do
    parted ${DEV} -s rm 1
    parted ${DEV} -s mklabel gpt
    parted ${DEV} -s mkpart primary 2048s 100%
    parted ${DEV} -s set 1 raid on
done


# --assume-clean 
mdadm --create /dev/md0 --name=backup --auto=yes --level=1 --raid-devices=2 /dev/sd{a..b}1

mkfs.ext4 -L backup /dev/disk/by-label/backup

CLI

# view partitions
lsblk

# scan for existing RAIDs
mdadm --examine --scan

# activate existing RAIDs
mdadm --assemble --scan

# stop all software RAIDs
mdadm --stop --scan

# create data partition
mdadm --create --verbose /dev/md0 --auto=yes --metadata=0.90 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1

# raid10 - quick init
mdadm --create --assume-clean --verbose /dev/md10 --auto=yes --level=10 --raid-devices=8 /dev/sd{a..h}1

# SSD + HDD RAID
mdadm --create /dev/md1 --level=1 --raid-devices=2 --bitmap=internal --write-behind=1024 /dev/sda1 --write-mostly /dev/sdb2
# echo writemostly > /sys/block/md1/md/dev-sdd2/state

mdadm --readwrite /dev/md0
mkfs.ext3 /dev/md0
mount /dev/md0 /mnt

# create swap partition
mdadm --create --verbose /dev/md1 --auto=yes --metadata=0.90 --level=1 --raid-devices=2 /dev/sda2 /dev/sdb2 
mkswap /dev/md1
swapon /dev/md1

# wait
echo "Wait util soft raid is build"
while [ $(cat /proc/mdstat | grep resync | wc -l) -gt 0 ]; do
    sleep 1
    echo -n .
done
echo "DONE"

# configure verifiy speed
echo 2048 > /proc/sys/dev/raid/speed_limit_min
echo 1048576 > /proc/sys/dev/raid/speed_limit_max

# stop raid
mdadm --stop /dev/md2
mdadm --zero-superblock /dev/sd{a..b}1
mdadm --zero-superblock /dev/nvme1n1p1 /dev/nvme0n1p1

# check
#cd /sys/block/md0/md
#echo check >sync_action
#watch -n1 cat /proc/mdstat

# default cronjob: /etc/cron.d/mdadm
/usr/share/mdadm/checkarray --cron --all --idle --quiet

# change  rebuilding speed limit
cat /proc/sys/dev/raid/speed_limit_max
sysctl -w dev.raid.speed_limit_min=value

# start software RAID with LVM
mdadm --examine --scan
# mdadm --examine --scan | grep "md/1" >> /etc/mdadm/mdadm.conf 

mdadm --detail /dev/md1
mdadm -A /dev/md1
vgchange -a y vg2


# Create Linux software RAID
mdadm --create /dev/md2 --level=raid5 --raid-devices=4 --spare-devices=0 /dev/sdb4
/dev/sdc4 /dev/sdd4

# replace device
mdadm --remove /dev/md0 /dev/sdb1
mdadm --zero-superblock /dev/sdb1
mdadm --manage /dev/md0 --add /dev/sdb1

# start raid
mdadm --assemble --scan -v

Mount inactive / broken RAID

mdadm --manage /dev/md1  --run
mount /dev/md1 /mnt/

Umount to RW
mdadm --readwrite /dev/md127

Links
http://panticz.de/Rebuild-Linux-software-RAID
http://www.cyberciti.biz/tips/linux-raid-increase-resync-rebuild-speed.html
http://sysadmin.compxtreme.ro/mdadm-cheat-sheet/

Profiles GitHub StackOverflow LinkedIn Xing
Contact Imprint
© panticz 2026

Cookie-Einstellungen

Diese Website nutzt eingebettete Inhalte von Drittanbietern (z.B. YouTube, SoundCloud). Beim Laden dieser Inhalte werden Daten an die jeweiligen Anbieter übermittelt. Datenverarbeitungserklärung