Eureka Moment Wiki

One eureka moment at the time

User Tools

Site Tools


linux:raid

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
linux:raid [2017/02/13 10:26]
tplecko
linux:raid [2017/08/10 12:59] (current)
Line 1: Line 1:
 +====== Setup raid on Ubuntu ======
 +Find the active arrays in the /​proc/​mdstat:​
 +<​code>​
 +cat /​proc/​mdstat
 +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: <​none>​
 +</​code>​
 +Unmount the array, stop it and remove it
 +<​code>​
 +sudo umount /dev/md0
 +sudo mdadm --stop /dev/md0
 +sudo mdadm --remove /dev/md0
 +</​code>​
 +Find the devices that were used to build the array with the following command:
 +<​code>​
 +lsblk -o NAME,​SIZE,​FSTYPE,​TYPE,​MOUNTPOINT
 +
 +NAME     SIZE FSTYPE ​           TYPE MOUNTPOINT
 +sda      100G                   ​disk ​
 +sdb      100G                   ​disk ​
 +sdc      100G linux_raid_member disk 
 +sdd      100G linux_raid_member disk 
 +vda       ​20G ​                  ​disk ​
 +├─vda1 ​   20G ext4              part /
 +└─vda15 ​   1M                   ​part ​
 +</​code>​
 +Reset the disks back to normal
 +<​code>​
 +sudo mdadm --zero-superblock /dev/sdc
 +sudo mdadm --zero-superblock /dev/sdd
 +</​code>​
 +or 
 +<​code>​
 +sudo wipefs -a -f /dev/sdc
 +sudo wipefs -a -f /dev/sdd
 +</​code>​
 +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 /​etc/​mdadm/​mdadm.conf file.
 +<​code>​
 +. . .
 +# ARRAY /dev/md0 metadata=1.2 name=mdadmwrite:​0 UUID=7261fb9c:​976d0d97:​30bc63ce:​85e76e91
 +. . .
 +</​code>​
 +Finally, update the initramfs again
 +<​code>​
 +sudo update-initramfs -u
 +</​code>​
 +
 +To get started, find the identifiers for the raw disks that you will be using
 +<​code>​
 +lsblk -o NAME,​SIZE,​FSTYPE,​TYPE,​MOUNTPOINT
 +
 +NAME     SIZE FSTYPE ​           TYPE MOUNTPOINT
 +sda      100G                   ​disk ​
 +sdb      100G                   ​disk ​
 +sdc      100G                   ​disk ​
 +sdd      100G                   ​disk ​
 +vda       ​20G ​                  ​disk ​
 +├─vda1 ​   20G ext4              part /
 +└─vda15 ​   1M                   ​part ​
 +</​code>​
 +
 +Create RAID1 and create the filesystem
 +<​code>​
 +sudo mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sdc /dev/sdd
 +mkfs.ext4 -F /dev/md0
 +</​code>​
 +You can ensure that the RAID was successfully created by checking the /​proc/​mdstat file:
 +<​code>​
 +cat /​proc/​mdstat
 +
 +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: <​none>​
 +</​code>​
 +Add the reference to fstab (/data is the existing mount point on my system)
 +<​code>​
 +echo '/​dev/​md0 /data ext4 defaults,​nofail,​discard 0 0'>>/​etc/​fstab
 +</​code>​
 +
 +To make sure that the array is reassembled automatically at boot, we will have to adjust the /​etc/​mdadm/​mdadm.conf file. You can automatically scan the active array and append the file
 +<​code>​
 +sudo mdadm --detail --scan | sudo tee -a /​etc/​mdadm/​mdadm.conf
 +#sudo mdadm --examine --scan --config=mdadm.conf >> /​etc/​mdadm/​mdadm.conf
 +</​code>​
 +Afterwards, you can update the initramfs, or initial RAM file system, so that the array will be available during the early boot process:
 +<​code>​
 +sudo update-initramfs -u
 +</​code>​
 +
 +Check if new space is avaliable
 +<​code>​
 +df -h
 +</​code>​
 +
 +**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* **
  
linux/raid.txt · Last modified: 2017/08/10 12:59 (external edit)