Difference between revisions of "RAID"

From RHS Wiki
Jump to navigation Jump to search
Line 39: Line 39:
 
unused devices: <none>
 
unused devices: <none>
 
</nowiki>
 
</nowiki>
==== Create the filesystem ====
 
sudo mkfs.ext4 -F /dev/md0
 
==== Mount the filesystem ====
 
sudo mount /dev/md0 /mnt/md0
 
  
 
=== Save the array layout ===
 
=== Save the array layout ===
Line 49: Line 45:
 
Enable the array at boot time
 
Enable the array at boot time
 
  sudo update-initramfs -u
 
  sudo update-initramfs -u
 +
 +
=== Using LVM ===
 +
pvcreate /dev/md0
 +
vgcreate lvm_group_name /dev/md0
 +
lvcreate -L30G -nlogical_volume_group_name lvm_group_name
 +
mkfs.ext4 /dev/lvm_group_name/logical_volume_group_name
 +
=== Using EXT4 ===
 +
===== Create the filesystem =====
 +
sudo mkfs.ext4 -F /dev/md0
 +
===== Mount the filesystem =====
 +
sudo mount /dev/md0 /mnt/md0
 +
 
Add mount option to fstab
 
Add mount option to fstab
 
  echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab
 
  echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab

Revision as of 17:57, 20 September 2018

Create RAID 5 Ubuntu

Disk Information

lsblk -o NAME,SIZE,FSTYPE,TYPE,MOUNTPOINT

NAME     SIZE FSTYPE TYPE MOUNTPOINT
sda    931.5G        disk 
└─sda1 931.5G ntfs   part /var/lib/transmission-daemon/downloads/HM_30
sdb    931.5G        disk 
└─sdb1 931.5G ntfs   part 
sdc    931.5G        disk 
└─sdc1 931.5G ntfs   part /var/lib/transmission-daemon/downloads/HM_40
sdd    931.5G        disk 
├─sdd1   100M ntfs   part 
├─sdd2   293G ntfs   part 
├─sdd3    14G ntfs   part 
├─sdd4     1K        part 
├─sdd5    28G ext4   part /
├─sdd6  93.1G ext4   part /home
├─sdd7  11.2G swap   part [SWAP]
└─sdd8   1.9G ext4   part /var/log
sdi      3.7T        disk 
sdj      3.7T        disk 
sdk      3.7T        disk 
sdl      3.7T        disk 
sr0     1024M        rom  

TODO: Disks order

Create RAID 5

sudo mdadm --create --verbose /dev/md0 --level=5 --raid-devices=4 /dev/sdi /dev/sdj /dev/sdk /dev/sdl

Monitor the array progress creation with

cat /proc/mdstat

Output:

Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
md0 : active raid5 sdl[4] sdk[2] sdj[1] sdi[0]
      11720658432 blocks super 1.2 level 5, 512k chunk, algorithm 2 [4/3] [UUU_]
      [>....................]  recovery =  0.0% (2091700/3906886144) finish=7753.1min speed=8393K/sec
      bitmap: 0/30 pages [0KB], 65536KB chunk

unused devices: <none>

Save the array layout

Wait until the array creation is finished and run:

sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf

Enable the array at boot time

sudo update-initramfs -u

Using LVM

pvcreate /dev/md0
vgcreate lvm_group_name /dev/md0
lvcreate -L30G -nlogical_volume_group_name lvm_group_name
mkfs.ext4 /dev/lvm_group_name/logical_volume_group_name

Using EXT4

Create the filesystem
sudo mkfs.ext4 -F /dev/md0
Mount the filesystem
sudo mount /dev/md0 /mnt/md0

Add mount option to fstab

echo '/dev/md0 /mnt/md0 ext4 defaults,nofail,discard 0 0' | sudo tee -a /etc/fstab

LVM and RAID Cheatsheet

https://gist.github.com/plepe/52ecc9f18efb32c68d18

Check RAID status

mdadm -D /dev/md0

References

https://www.digitalocean.com/community/tutorials/how-to-create-raid-arrays-with-mdadm-on-ubuntu-16-04#top
https://unix.stackexchange.com/questions/88654/what-does-mdadms-spare-number-mean
https://wiki.bandaancha.st/RAID_y_LVM_en_Linux

https://zackreed.me/software-raid-5-in-debian-with-mdadm/
https://zackreed.me/adding-an-extra-disk-to-an-mdadm-array/