Debian 11 Bullseye
Sponsored Link

Configure RAID 12021/09/29

 
Configure RAID 1 to add 2 new Disks on a computer.
[1] This example is based on the environment like follows.
It shows to install new Disks [sdb] and [sdc] on this computer and configure RAID 1.
root@dlp:~#
df -h

Filesystem                   Size  Used Avail Use% Mounted on
udev                         3.9G     0  3.9G   0% /dev
tmpfs                        796M  544K  796M   1% /run
/dev/mapper/debian--vg-root   77G 1020M   72G   2% /
tmpfs                        3.9G     0  3.9G   0% /dev/shm
tmpfs                        5.0M     0  5.0M   0% /run/lock
/dev/sda1                    470M   48M  398M  11% /boot
tmpfs                        796M     0  796M   0% /run/user/0
[2] Create a partition on new Disks and set RAID flag.
root@dlp:~#
apt -y install parted
root@dlp:~#
parted --script /dev/sdb "mklabel gpt"

root@dlp:~#
parted --script /dev/sdc "mklabel gpt"

root@dlp:~#
parted --script /dev/sdb "mkpart primary 0% 100%"

root@dlp:~#
parted --script /dev/sdc "mkpart primary 0% 100%"

root@dlp:~#
parted --script /dev/sdb "set 1 raid on"

root@dlp:~#
parted --script /dev/sdc "set 1 raid on"
[3] Configure RAID 1.
# install required tools

root@dlp:~#
apt -y install mdadm
root@dlp:~#
mdadm --create /dev/md0 --level=raid1 --raid-devices=2 /dev/sdb1 /dev/sdc1

mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
Continue creating array? y
mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

# show status

root@dlp:~#
cat /proc/mdstat

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      83817472 blocks super 1.2 [2/2] [UU]
      [====>................]  resync = 24.9% (20902592/83817472) finish=7.4min speed=140632K/sec

unused devices: <none>

# status turns like follows if syncing finished

# that's OK to configure RAID 1

root@dlp:~#
cat /proc/mdstat

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      83817472 blocks super 1.2 [2/2] [UU]

unused devices: <none>
[4] If a member Disk in RAID array would be failure, re-configure RAID 1 like follows after swapping new Disk.
# the status is like follows in failure

root@dlp:~#
cat /proc/mdstat

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      83817472 blocks super 1.2 [2/1] [U_]

unused devices: <none>

# after swapping new disk, re-configure like follows

root@dlp:~#
mdadm --manage /dev/md0 --add /dev/sdc1

mdadm: added /dev/sdc1
root@dlp:~#
cat /proc/mdstat

Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      83817472 blocks super 1.2 [2/2] [UU]
      [====>................]  resync = 24.9% (20902592/83817472) finish=7.4min speed=140632K/sec

unused devices: <none>
Matched Content