Skip to content

4. RAID System

The following manual explains how to create a RAID disk system, both on Windows and Ubuntu Operating Systems.

A RAID system combines multiple disks to function as a single unit, increasing security through redundant copies, or performance (faster read/write).

Windows 10/11

Steps

  1. PowerShell as Administrator
# Create the directory for virtual disks (VHD)
mkdir "C:\RAIDDisks"
  1. To create the virtual disks, we need to use the Windows "DISKPART" tool
# Create 3 VHDs

diskpart # To access the tool

DISKPART> create vdisk file="C:\RAIDDisks\Disk1.vhd" maximum=10000 type=expandable # Disk1

DISKPART> create vdisk file="C:\RAIDDisks\Disk2.vhd" maximum=10000 type=expandable # Disk2

DISKPART> create vdisk file="C:\RAIDDisks\Disk3.vhd" maximum=10000 type=expandable # Disk3

# Mount the disks

DISKPART> select vdisk file="C:\RAIDDisks\Disk1.vhd"
DISKPART> attach vdisk

DISKPART> select vdisk file="C:\RAIDDisks\Disk2.vhd"
DISKPART> attach vdisk

DISKPART> select vdisk file="C:\RAIDDisks\Disk3.vhd"
DISKPART> attach vdisk

DISKPART> exit # To exit DISKPART
  1. Verify that the actions have been completed correctly.
# Verify disk existence

Get-Disk | Format-Table Number, FriendlyName, Size, PartitionStyle -AutoSize 
# Three virtual disks similar to the following output should appear:

---
Number FriendlyName              Size          PartitionStyle
------ ------------              ----          --------------
1      Msft Virtual Disk         10485760000   RAW
2      Msft Virtual Disk         10485760000   RAW
3      Msft Virtual Disk         10485760000   RAW
0      Red Hat VirtIO            171798691840  GPT
---

Create the storage space:

  1. Win + S -> Control Panel -> System and Security -> Storage Spaces

  1. Create a new pool and storage space.

  1. Select the disks you want to use -> Create Pool

  1. Resiliency type = Two-way mirror

    Size = 9GB

  1. Create storage space.

  1. Verify that the unit we just created appears in the file system.

To Automate Processes

You can create scripts (.bat) so that every time the desktop starts, the disks are mounted.

  • The first script will have the mounting function, with the commands we used previously to mount them manually. To do this, you can create a blank file and copy the following instructions.

    It will be saved with the name: "2_mount_raid_disks.bat"

@echo off
REM ========================================
REM    MOUNT RAID VIRTUAL DISKS
REM ========================================

REM Verify administrator privileges
net session >nul 2>&1
if %errorLevel% neq 0 (
    exit /b 1
)

REM Wait 5 seconds for the system to be ready
timeout /t 5 /nobreak >nul

REM Mount the three disks
(
echo select vdisk file="C:\RAIDDisks\Disk1.vhd"
echo attach vdisk
echo select vdisk file="C:\RAIDDisks\Disk2.vhd"
echo attach vdisk
echo select vdisk file="C:\RAIDDisks\Disk3.vhd"
echo attach vdisk
) | diskpart >nul 2>&1

exit /b 0
  • The second script will create a task that runs every time Windows starts

    To do this, you can create a blank file and copy the following instructions. Once done, save it with the ".bat" extension and run it in Administrator mode.

@echo off
echo ========================================
echo   CONFIGURE AUTOMATIC MOUNTING
echo ========================================
echo.

REM Verify administrator privileges

net session >nul 2>&1
if %errorLevel% neq 0 (
    echo ERROR: This script requires administrator privileges
    pause
    exit /b 1
)

REM Get the current path of the mounting script

set "SCRIPT_SETUP=%~dp02_mount_raid_disks.bat"

echo Automatic mounting will be configured using:
echo %SCRIPT_SETUP%
echo.

REM Create scheduled task at Windows startup

schtasks /create /tn "MountRAIDDisks" /tr "\"%SCRIPT_SETUP%\"" /sc onstart /ru SYSTEM /rl HIGHEST /f

if %errorLevel% equ 0 (
    echo.
    echo ========================================
    echo   CONFIGURATION COMPLETED
    echo ========================================
    echo.
    echo Virtual disks will be mounted automatically
    echo every time Windows starts.
    echo.
    echo To verify: Run "taskschd.msc" and search for "MountRAIDDisks"
) else (
    echo ERROR: Could not create scheduled task
)

echo.
pause

At this point you can restart the desktop and you will be able to see the disks mounted correctly from startup.

  • Explanation:

The 1st script stores the instructions to mount the disks.

The 2nd script first checks that it has been run in administrator mode.

Once verified, it calls the 1st script to do the mounting and assigns it the name "SCRIPT_SETUP". From here, it creates a task that starts with the desktop startup and calls this script.

The created task can be seen by running "taskschd.msc" and searching for "MountRAIDDisks".

Ubuntu

Steps

Through terminal:

sudo apt update
sudo apt upgrade -y
sudo apt install -y mdadm
sudo lsblk
---
#    vda    252:0    0   100G  0 disk 
#    ├─vda1 252:1    0     1M  0 part 
#    ├─vda2 252:2    0   513M  0 part /boot/efi
#    └─vda3 252:3    0  79,5G  0 part /var/snap/firefox/common/host-hunspell
#                                     /
---
We need to verify that we have an unassigned disk partition.

By entering the system's disk manager we can check it.

sudo fdisk /dev/vda # This can be replaced by doing it directly from GParted, just create 2 partitions of 1G (1024 MiB)
---
#    n (new partition Disk1)
#    Enter
#    Enter
#    +1G
#    n (Disk2)
#    Enter
#    Enter
#    +1G
#    w
---
Here is a link to the manual where we explain how to make these partitions with GParted using an example.
sudo lsblk # Check that the action has been performed correctly
---
#    vda    252:0    0   100G  0 disk 
#    ├─vda1 252:1    0     1M  0 part 
#    ├─vda2 252:2    0   513M  0 part /boot/efi
#    ├─vda3 252:3    0  79,5G  0 part /var/snap/firefox/common/host-hunspell
#    │                                /
#    ├─vda4 252:4    0     1G  0 part 
#    └─vda5 252:5    0     1G  0 part 
---
sudo wipefs -a /dev/vda4 /dev/vda5
sudo mdadm --create /dev/md0 --level=1 --raid-devices=2 /dev/vda4 /dev/vda5
---
#   yes
---
sudo lsblk
---
#    vda     252:0    0   100G  0 disk  
#    ├─vda1  252:1    0     1M  0 part  
#    ├─vda2  252:2    0   513M  0 part  /boot/efi
#    ├─vda3  252:3    0  79,5G  0 part  /var/snap/firefox/common/host-hunspell
#    │                                  /
#    ├─vda4  252:4    0     1G  0 part  
#    │ └─md0   9:0    0  1022M  0 raid1 
#    └─vda5  252:5    0     1G  0 part  
#      └─md0   9:0    0  1022M  0 raid1
---
sudo mdadm --detail /dev/md0
---
#    /dev/md127:
#               Version : 1.2
#         Creation Time : Wed Nov 12 13:51:17 2025
#            Raid Level : raid1
#            Array Size : 1046528 (1022.00 MiB 1071.64 MB)
#         Used Dev Size : 1046528 (1022.00 MiB 1071.64 MB)
#          Raid Devices : 2
#         Total Devices : 2
#           Persistence : Superblock is persistent
#    
#           Update Time : Wed Nov 12 13:51:31 2025
#                 State : clean 
#        Active Devices : 2
#       Working Devices : 2
#        Failed Devices : 0
#         Spare Devices : 0
#
#    Consistency Policy : resync
#
#                  Name : ubuntu:0  (local to host ubuntu)
#                  UUID : 4afe7442:2f7b8bd2:b42d29cd:78ac0321
#                Events : 17
#
#        Number   Major   Minor   RaidDevice State
#           0     252        4        0      active sync   /dev/vda4
#           1     252        5        1      active sync   /dev/vda5
---
echo "DEVICE partitions" | sudo tee /etc/mdadm/mdadm.conf >/dev/null
sudo mdadm --detail --scan | sudo tee -a /etc/mdadm/mdadm.conf >/dev/null
sudo update-initramfs -u

Tests to verify proper operation:

# to test

sudo apt install -y xfsprogs # Tool used to manage file systems
sudo mkfs.xfs -f /dev/md0
---
#    meta-data=/dev/md0               isize=512    agcount=4, agsize=65408 blks
#             =                       sectsz=512   attr=2, projid32bit=1
#             =                       crc=1        finobt=1, sparse=1, rmapbt=0
#             =                       reflink=1    bigtime=0 inobtcount=0
#    data     =                       bsize=4096   blocks=261632, imaxpct=25
#             =                       sunit=0      swidth=0 blks
#    naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
#    log      =internal log           bsize=4096   blocks=1566, version=2
#             =                       sectsz=512   sunit=0 blks, lazy-count=1
#    realtime =none                   extsz=4096   blocks=0, rtextents=0
#    Discarding blocks...Done.
---
sudo mount -t xfs -o defaults,noatime,nodiratime /dev/md0 /mnt
sudo lsblk
---
#    vda       252:0    0   100G  0 disk  
#    ├─vda1    252:1    0     1M  0 part  
#    ├─vda2    252:2    0   513M  0 part  /boot/efi
#    ├─vda3    252:3    0  79,5G  0 part  /var/snap/firefox/common/host-hunspell
#    │                                    /
#    ├─vda4    252:4    0     1G  0 part  
#    │ └─md0     9:127  0  1022M  0 raid1 /mnt
#    └─vda5    252:5    0     1G  0 part  
#      └─md0     9:127  0  1022M  0 raid1 /mnt
---
df -hT /mnt
---
#    Filesystem     Type  Size  Used Avail Use% Mounted on
#    /dev/md0       xfs   1016M  40M  977M   4%  /mnt
---
sudo umount /mnt
sudo lsblk
---
#    vda       252:0    0   100G  0 disk  
#    ├─vda1    252:1    0     1M  0 part  
#    ├─vda2    252:2    0   513M  0 part  /boot/efi
#    ├─vda3    252:3    0  79,5G  0 part  /var/snap/firefox/common/host-hunspell
#    │                                    /
#    ├─vda4    252:4    0     1G  0 part  
#    │ └─md0     9:127  0  1022M  0 raid1 
#    └─vda5    252:5    0     1G  0 part  
#      └─md0     9:127  0  1022M  0 raid1
---

# end test