SHARE
TWEET

Raspberry Pi RAID

apfelcast Oct 27th, 2019 1,112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #### Raspberry Pi RAID Konfiguration ####
  2.  
  3. ## Update Sources ##
  4. sudo apt-get update
  5.  
  6. ## Install RAID Software mdadm ##
  7. sudo apt-get install mdadm
  8.  
  9. ## Reboot Pi ##
  10. sudo reboot
  11.  
  12. ## Check disks ##
  13. lsblk
  14.  
  15. ## Remove all data & partitions from disks ##
  16. sudo parted /dev/sda "rm 1"
  17. sudo parted /dev/sdb "rm 1"
  18.  
  19. ## Check if no partitions are on disks ##
  20. lsblk
  21.  
  22. ## Create MSDOS Table if disk is < 2TB ##
  23. sudo parted /dev/sda "mklabel msdos"
  24. sudo parted /dev/sdb "mklabel msdos"
  25.  
  26. ## Create GPT Table if disk is > 2TB ##
  27. sudo parted /dev/sda "mklabel gpt"
  28. sudo parted /dev/sdb "mklabel gpt"
  29.  
  30. ## Create partition on each disk ##
  31. sudo parted /dev/sda "mkpart primary ext4 1M -1"
  32. sudo parted /dev/sdb "mkpart primary ext4 1M -1"
  33.  
  34. ## Activate RAID for each partition ##
  35. sudo parted /dev/sda "set 1 raid on"
  36. sudo parted /dev/sdb "set 1 raid on"
  37.  
  38.  
  39. ## Check status ##
  40. sudo parted -s /dev/sda print
  41. sudo parted -s /dev/sdb print
  42.  
  43. ## Create RAID Level 0 ##
  44. sudo mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sda1 /dev/sdb1
  45.  
  46. ## Create RAID Level 1 ##
  47. sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/sda1 /dev/sdb1
  48.  
  49. ## Check staus ##
  50. lsblk
  51.  
  52. ## Create Datasystem on RAID-System to be able to put files on it ##
  53. sudo mkfs -t ext4 /dev/md0
  54.  
  55. ## Check prograss ##
  56. cat /proc/mdstat
  57. sudo mdadm --detail /dev/md0
  58.  
  59.  
  60. ## Create Mount Directory ##
  61. sudo mkdir /media/raid
  62.  
  63. ## Mount RAID ##
  64. sudo mount /dev/md0 /media/raid
  65.  
  66. ## Configure autostrat & mount at boot ##
  67. sudo nano /etc/fstab/
  68. add: /dev/md0 /media/raid ext4 4,nofail 0 0
  69.  
  70. sudo crontab -e
  71. add: @reboot sleep 5; sudo mount /dev/md0 /media/raid
  72.  
  73. ### Use RAID as Nextcloud data directory ###
  74.  
  75. sudo su
  76.  
  77. mkdir /media/raid/nextcloud/
  78. chown -R www-data:www-data /media/raid/nextcloud/
  79.  
  80. ## open current data directory ##
  81. cd PATH/TO/DATA/
  82. mv data /media/raid/nextcloud
  83.  
  84. ## Configure Nextcloud data directory ##
  85. nano /var/www/nextcloud/config/config.php
  86.  
  87. edit this line: 'datadirectory' => '/media/raid/nextcloud/data/',
  88.  
  89. ## restart webserver ##
  90. service apache2 restart
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top