Skip to content

Instantly share code, notes, and snippets.

@l1x
Last active December 8, 2021 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save l1x/88b43b6a5638b4ccbbac1f9fd30a675d to your computer and use it in GitHub Desktop.
Save l1x/88b43b6a5638b4ccbbac1f9fd30a675d to your computer and use it in GitHub Desktop.

Creating a mirror using two disks

This uses the partition UUID to be able to tolarate device name changes.

 doas /sbin/mdadm \
 --verbose --create /dev/md/nas0 \
 --level=mirror --raid-devices=2 \
 /dev/disk/by-partuuid/7b139fcf-e971-4806-b0f9-cbbd8c1d24de \
 /dev/disk/by-partuuid/a11e2aa2-c404-48a1-8e3e-51a8dec0c967

Creating a FS on the new device.

doas /sbin/mkfs.xfs -f -b size=4096 -s size=4096 /dev/md/nas0

Info about the array.

➜  rpi4-3.lan ~ doas /sbin/mdadm --verbose --detail /dev/md/nas0
/dev/md/nas0:
           Version : 1.2
     Creation Time : Wed Dec  8 21:21:56 2021
        Raid Level : raid1
        Array Size : 7813894464 (7451.91 GiB 8001.43 GB)
     Used Dev Size : 7813894464 (7451.91 GiB 8001.43 GB)
      Raid Devices : 2
     Total Devices : 2
       Persistence : Superblock is persistent

     Intent Bitmap : Internal

       Update Time : Wed Dec  8 21:25:34 2021
             State : clean, resyncing
    Active Devices : 2
   Working Devices : 2
    Failed Devices : 0
     Spare Devices : 0

Consistency Policy : bitmap

     Resync Status : 0% complete

              Name : rpi4-3.lan:nas0  (local to host rpi4-3.lan)
              UUID : ff6bf993:818a61e4:83b9ed22:23d9176f
            Events : 46

    Number   Major   Minor   RaidDevice State
       0       8       32        0      active sync   /dev/sdc
       1       8       16        1      active sync   /dev/sdb

XFS info

➜  rpi4-3.lan ~ doas /sbin/xfs_info /dev/md0
meta-data=/dev/md0               isize=512    agcount=8, agsize=268435455 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=0
data     =                       bsize=4096   blocks=1953473360, imaxpct=5
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=521728, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

After mounting

➜  rpi4-3.lan ~ df -h | grep nas
/dev/md0        7.3T   52G  7.3T   1% /nas

Tracking progress

 cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sdc1[1] sdb1[0]
      7813893440 blocks super 1.2 [2/2] [UU]
      [=>...................]  resync =  6.1% (483675520/7813893440) finish=736.3min speed=165908K/sec
      bitmap: 56/59 pages [224KB], 65536KB chunk

Monitoring temperature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment