Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== Using mdadm to create a Software RAID in Linux ====== Part of [[engineering:computer_science:linux:linux|Linux]] ===== Installation ===== In Debian: <code> sudo apt get install mdadm </code> ===== ===== ===== Partition Disks for mdadm usage ===== You can use: <code> sudo mdadm -E /dev/sd[b-c] </code> to check if the devices are part of a RAID / super-block is found. ==== Drive Partitioning for RAID: ==== <code> sudo fdisk /dev/sdX </code> To create the partition, input the following values in order. Each Input should be followed by a confirmation (ENTER) ^Value^Description| |n|New primary Partition| |P|Define as Primary Partition| |1|Partition Number| |(ENTER)|Confirm Default Starting Block| |(ENTER)|Confirm Default End Block| |t|Choose partitions type| |fd|Partition type: Linux Raid auto| |w|Write Changes| === Useful Options for fdisk === ^Value^Description| |d|Delete selected partition| |p|Print partitions information| |L|List available types of partitions| Don't forget to repeat the steps for all disks you using on the RAID. ===== Creating a RAID 1 ===== <code> sudo mdadm --create /dev/md0 --level=mirror --raid-devices=2 /dev/sd[b-c]1 </code> ^Value^Description| |–create|Create a new RAID| |/dev/md0|Using /dev/md0| |–level=mirror|Raid as Mirror| |–raid-devices=2|Use 2 devices| |/dev/sd[b-c]1|The devices sdb1 and sdc1| ===== Creating File System on a RAID Device ===== Use mkfs to create a ext4 File System with: <code> sudo mkfs.ext4 /dev/md0 </code> ===== Automount RAID on boot ===== Edit your fstab to auto-mount your RAID on boot: <code> sudo nano /etc/fstab </code> Eg: <code> /dev/md0 /mnt/md0 ext4 defaults,nofail 0 0 </code> To make sure that the array is reassembled automatically at boot, adjust your /etc/mdadm/mdadm.conf: <code> sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf </code> Uncomment - if necessary - your array on /etc/mdadm/mdadm.conf by removing the Starting "#": <code> sudo nano /etc/mdadm/mdadm.conf </code> Update the initramfs again so that the early boot process does not try to bring an unavailable array online: <code> sudo update-initramfs -u </code> ===== Check Raid Status ===== You can use the following commands to check the status of your RAID: <code> sudo mdadm -E /dev/sd[b-c]1 </code> <code> sudo mdadm --detail /dev/md0 </code> CKG Edit engineering/computer_science/linux/linux_mdadm_software_raid.txt Last modified: 2024/08/16 13:56by carlossousa