Skip to content

4. RAID System

The following manual explains how to create a RAID disk system on Windows and Ubuntu operating systems.

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

Windows 10/11

Steps

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

diskpart # To enter the tool

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

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

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

# Attach the disks

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

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

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

DISKPART> exit # To leave DISKPART
  1. Check that the actions have run correctly.
# Check that the disks exist

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

---
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
---

The storage space is created:

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

  1. Create a new pool and storage spaces.

  1. Select the disks to use -> Create pool.

  1. Set the following parameters:
    • Resilience type = Two-way mirror
    • Size = 9 GB

  1. Create the storage spaces.

  1. Check that the drive just created appears in the file system.

To automate processes

Scripts (.bat) can be created so that the disks are mounted every time the desktop starts.

  • The first script will do the mounting, with the commands used earlier to mount them manually. To do this, 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 Check 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\Disco1.vhd"
echo attach vdisk
echo select vdisk file="C:\RAIDDisks\Disco2.vhd"
echo attach vdisk
echo select vdisk file="C:\RAIDDisks\Disco3.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 Check 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 mount script

set "SCRIPT_MOUNT=%~dp02_mount_raid_disks.bat"

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

REM Create a scheduled task at Windows startup

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

if %errorLevel% equ 0 (
    echo.
    echo ========================================
    echo   CONFIGURATION COMPLETE
    echo ========================================
    echo.
    echo The virtual disks will be mounted automatically
    echo every time Windows starts.
    echo.
    echo To verify: run "taskschd.msc" and look for "MountRAIDDisks"
) else (
    echo ERROR: The scheduled task could not be created
)

echo.
pause

At this point, you can restart the desktop and see the disks mounted correctly from the start.

  • Explanation:

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

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

Once checked, it calls the 1st script to perform the mounting and assigns it the name "SCRIPT_MOUNT". 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

  1. Open the terminal.
  2. Run the following command:
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
#                                     /
---
  1. Check that there is an unallocated disk partition. It can be seen in the system's disk manager.

sudo fdisk /dev/vda # This can be replaced by doing it directly in GParted; you only need to make two 1G partitions (1024 MiB)
---
#    n (new partition Disk1)
#    Enter
#    Enter
#    +1G
#    n (Disk2)
#    Enter
#    Enter
#    +1G
#    w
---
  1. The GParted (Ubuntu) exercise explains with an example how to create these partitions with GParted.
sudo lsblk # Check that the action completed 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

Verification tests for proper operation

# per provar

sudo apt install -y  # Eina que s'utilitza per administrar sistemes d'arxius
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
---
#    S. ficheros     Tipo  Medida En uso Libre  %Uso Montado en
#    /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
---

# fi prova