RAID configuration

Is it possible to do RAID configuration with “mdadm” to take advantage of the 2 sata ports?

with stock kernel available in 18.04 image - no (RAID support not compiled as built-in nor module).

I have cross-compiled kernel from sources available in bsp on github with RAID enabled (rest of kernel configuration - default as in bsp) and board boots fine. I had no time to play with raid on it yet so i cannot confirm for sure, but I see no reason why it would not work.

Thanks for your answer. I have never compiled kernel. Can you explain how to do it for w2 or share a tutorial?

readme is on github (i did it 1st time here as well so it works ;])

  • either download git repo as zip and unzip on your machine or git clone to your linux box.
  • cd your repo directory
  • run this script: ./build.sh
  • opt 4 for kernel config (GUI like menu to enable / disable modules, look for RAID and mark it with * - built-in or M - module to be loaded / unloaded)
  • opt 1 to build
  • about 90 minutes later (on my laptop - might be different on your machine) there is new directory “SD” inside repo dir
  • in there you have 100MB, BPI-BOOT and BPI-ROOT
  • copy over files from those directories to appropriate partitions on your SD card:
  1. BPI-BOOT is partition 1 (contain uImage, dtb, bluecore)
  2. BPI-ROOT is partition 2, (contain kernel modules compiled in the process)
  3. I have ignored 100MB folder as I have not changed anything in bootloader (it is included in basic image downloaded from here in the first place)

that is all - new kernel is built.

1 Like

Thanks Kamil. I will try

After recompiling the kernel I have been using RAID1 on 2 2.5’’ hard disks for a long time, although I use BTRFS with RAID support instead of mdadm to manage the disks.

mdadm raid1 works with 2x 1TB hdd (not SSD).

mdadm.conf has array details,

fstab has mount details

array is not assembled after reboot:

md scan for arrays is done faster than sataa and satab are initialised:

Oct  6 01:15:59 bpi-w2 kernel: [    6.476868] md: Waiting for all devices to be available before autodetect
Oct  6 01:15:59 bpi-w2 kernel: [    6.483837] md: If you don't use raid, use raid=noautodetect
Oct  6 01:15:59 bpi-w2 kernel: [    6.490253] md: Autodetecting RAID arrays.
Oct  6 01:15:59 bpi-w2 kernel: [    6.494462] md: Scanned 0 and added 0 devices.
Oct  6 01:15:59 bpi-w2 kernel: [    6.499025] md: autorun ...
Oct  6 01:15:59 bpi-w2 kernel: [    6.501886] md: ... autorun DONE.

...

Oct  6 01:15:59 bpi-w2 kernel: [   19.658300] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Oct  6 01:15:59 bpi-w2 kernel: [   19.734755] ata2.00: ATA-10: ST1000LM035-1RK172, SDM2, max UDMA/133
Oct  6 01:15:59 bpi-w2 kernel: [   19.741216] ata2.00: 1953525168 sectors, multi 16: LBA48 NCQ (depth 31/32)
Oct  6 01:15:59 bpi-w2 kernel: [   19.846491] ata2.00: configured for UDMA/133
Oct  6 01:15:59 bpi-w2 kernel: [   21.106300] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
Oct  6 01:15:59 bpi-w2 kernel: [   21.192902] ata1.00: ATA-10: ST1000LM035-1RK172, SDM2, max UDMA/133
Oct  6 01:15:59 bpi-w2 kernel: [   21.199334] ata1.00: 1953525168 sectors, multi 16: LBA48 NCQ (depth 31/32)
Oct  6 01:15:59 bpi-w2 kernel: [   21.304613] ata1.00: configured for UDMA/133
Oct  6 01:15:59 bpi-w2 kernel: [   21.309425] scsi 0:0:0:0: Direct-Access     ATA      ST1000LM035-1RK1 SDM2 PQ: 0 ANSI: 5
Oct  6 01:15:59 bpi-w2 kernel: [   21.346715] sd 0:0:0:0: [sataa] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
Oct  6 01:15:59 bpi-w2 kernel: [   21.354798] sd 0:0:0:0: [sataa] 4096-byte physical blocks
Oct  6 01:15:59 bpi-w2 kernel: [   21.358530] scsi 1:0:0:0: Direct-Access     ATA      ST1000LM035-1RK1 SDM2 PQ: 0 ANSI: 5
Oct  6 01:15:59 bpi-w2 kernel: [   21.368745] sd 0:0:0:0: [sataa] Write Protect is off
Oct  6 01:15:59 bpi-w2 kernel: [   21.373845] sd 0:0:0:0: [sataa] Mode Sense: 00 3a 00 00
Oct  6 01:15:59 bpi-w2 kernel: [   21.379258] sd 0:0:0:0: [sataa] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Oct  6 01:15:59 bpi-w2 kernel: [   21.397839] sd 0:0:0:0: [sataa] Attached SCSI disk
Oct  6 01:15:59 bpi-w2 kernel: [   21.406663] sd 1:0:0:0: [satab] 1953525168 512-byte logical blocks: (1.00 TB/932 GiB)
Oct  6 01:15:59 bpi-w2 kernel: [   21.414697] sd 1:0:0:0: [satab] 4096-byte physical blocks
Oct  6 01:15:59 bpi-w2 kernel: [   21.420343] sd 1:0:0:0: [satab] Write Protect is off
Oct  6 01:15:59 bpi-w2 kernel: [   21.425439] sd 1:0:0:0: [satab] Mode Sense: 00 3a 00 00
Oct  6 01:15:59 bpi-w2 kernel: [   21.430848] sd 1:0:0:0: [satab] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
Oct  6 01:15:59 bpi-w2 kernel: [   21.537636] sd 1:0:0:0: [satab] Attached SCSI disk

manual trigger after boot assembles without errors and mounts it right away.

is there any way to delay mdscan on boot or actually wait for all devices to be available before giving up?

I could do dirty pseudo manual scan after boot via rc.local but maybe there is cleaner way

My array is not automatically assembled either when using mdadm. I recommend using BTRFS to manage multiple disks. Just put /dev/sataa /mnt btrfs device=/dev/sataa,device=/dev/satab 0 0 in fstab and the BTRFS driver will wait for all devices to be available before mounting the filesystem.

https://btrfs.wiki.kernel.org/index.php/Using_Btrfs_with_Multiple_Devices

after another kernel re-compile (forgot to enable btrfs in kernel when compiling for raid first time) I have tried it.

tried mounting via UUID as in guide found on google, but then it failed to boot (stuck on start job for device… (x of 1m30s).

after those 90s it asked for root pass for recovery. works perfectly fine when used your entry in fstab.

now lets get kodi rolling on this box and I have pretty little NAS / media center connected to TV in living room ;] time to retire raspberry pi 2 running xbian in same role (no NAS option there)

I have compiled my kernel from git://github.com/BPI-SINOVOIP/BPI-W2-bsp selecting RAID options in the following: ‘General setup -> Device Drivers -> Multiple device driver support (RAID and LVM) -> RAID support’. Except ‘Autodetect RAID arrays during kernel boot’, because this feature sometimes works sometimes doesn’t. Also it requires the outdated metadata v0.90. On the other hand, ‘update-initramfs -u’ does not work as well. So, I put the ‘mdadm --assemble’ and ‘mount’ commands into /etc/rc.local. I hope '‘update-initramfs’ will be fixed in next image releases. But for the time being, my RAID1 works properly for samba, nfs, web and ftp servers.