Differences
This shows you the differences between two versions of the page.
— | linux:raid [2019/10/31 08:55] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Setup raid on Ubuntu ====== | ||
+ | Find the active arrays in the / | ||
+ | < | ||
+ | cat / | ||
+ | Personalities : [raid0] [linear] [multipath] [raid1] [raid6] [raid5] [raid4] [raid10] | ||
+ | md0 : active raid0 sdc[1] sdd[0] | ||
+ | 209584128 blocks super 1.2 512k chunks | ||
+ | |||
+ | unused devices: < | ||
+ | </ | ||
+ | Unmount the array, stop it and remove it | ||
+ | < | ||
+ | sudo umount /dev/md0 | ||
+ | sudo mdadm --stop /dev/md0 | ||
+ | sudo mdadm --remove /dev/md0 | ||
+ | </ | ||
+ | Find the devices that were used to build the array with the following command: | ||
+ | < | ||
+ | lsblk -o NAME, | ||
+ | |||
+ | NAME SIZE FSTYPE | ||
+ | sda 100G | ||
+ | sdb 100G | ||
+ | sdc 100G linux_raid_member disk | ||
+ | sdd 100G linux_raid_member disk | ||
+ | vda | ||
+ | ├─vda1 | ||
+ | └─vda15 | ||
+ | </ | ||
+ | Reset the disks back to normal | ||
+ | < | ||
+ | sudo mdadm --zero-superblock /dev/sdc | ||
+ | sudo mdadm --zero-superblock /dev/sdd | ||
+ | </ | ||
+ | or | ||
+ | < | ||
+ | sudo wipefs -a -f /dev/sdc | ||
+ | sudo wipefs -a -f /dev/sdd | ||
+ | </ | ||
+ | Remove any of the persistent references to the array. Edit the /etc/fstab file and comment out or remove the reference to your array. Also, comment out or remove the array definition from the / | ||
+ | < | ||
+ | . . . | ||
+ | # ARRAY /dev/md0 metadata=1.2 name=mdadmwrite: | ||
+ | . . . | ||
+ | </ | ||
+ | Finally, update the initramfs again | ||
+ | < | ||
+ | sudo update-initramfs -u | ||
+ | </ | ||
+ | |||
+ | To get started, find the identifiers for the raw disks that you will be using | ||
+ | < | ||
+ | lsblk -o NAME, | ||
+ | |||
+ | NAME SIZE FSTYPE | ||
+ | sda 100G | ||
+ | sdb 100G | ||
+ | sdc 100G | ||
+ | sdd 100G | ||
+ | vda | ||
+ | ├─vda1 | ||
+ | └─vda15 | ||
+ | </ | ||
+ | |||
+ | Create RAID1 and create the filesystem | ||
+ | < | ||
+ | sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdc /dev/sdd | ||
+ | mkfs.ext4 -F /dev/md0 | ||
+ | </ | ||
+ | You can ensure that the RAID was successfully created by checking the / | ||
+ | < | ||
+ | cat / | ||
+ | |||
+ | Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] | ||
+ | md0 : active raid0 sdd[1] sdc[0] | ||
+ | 209584128 blocks super 1.2 512k chunks | ||
+ | |||
+ | unused devices: < | ||
+ | </ | ||
+ | Add the reference to fstab (/data is the existing mount point on my system) | ||
+ | < | ||
+ | echo '/ | ||
+ | </ | ||
+ | |||
+ | To make sure that the array is reassembled automatically at boot, we will have to adjust the / | ||
+ | < | ||
+ | sudo mdadm --detail --scan | sudo tee -a / | ||
+ | #sudo mdadm --examine --scan --config=mdadm.conf >> / | ||
+ | </ | ||
+ | Afterwards, you can update the initramfs, or initial RAM file system, so that the array will be available during the early boot process: | ||
+ | < | ||
+ | sudo update-initramfs -u | ||
+ | </ | ||
+ | |||
+ | Check if new space is avaliable | ||
+ | < | ||
+ | df -h | ||
+ | </ | ||
+ | |||
+ | **Note** For some reason, ubuntu ignores the name md0 on the next boot, and renames the array to md127. You can check with **mdadm --query --detail /dev/md* ** | ||