Skip to content

mdadm

how to create raid 1 with one missing disk and add second disk later

Festplatte formatieren, Partitionstabelle erstellen, Partition erstelleun und Filesystem erstellen

https://wiki.archlinux.org/title/Parted

parted /dev/sdc mklabel gpt mkpart primary ext4 0% 100% ((parted) mkpart part-type-or-part-label fs-type start end) OR mkpart primary ext4 <1MiB or 100MiB> 100% ((parted) mkpart part-type-or-part-label fs-type start end) > Not tested yet if necessary to be able to match more disks of different manufactures print

mdadm erstellen mit einer missing disk um im anschluss daten rüberzuschieben https://arstechnica.com/civis/threads/mdadm-raid-1-with-existing-data.1136487/ https://wiki.archlinux.org/title/RAID

apt install mdadm

PREPARE DISK

create the array [the missing drive is the one containing data. sdc1 = new empty drive] mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdc1 missing (sdc1 is the new drive which is empty)

check the details, showing an array with 2 devices, 1 in use. mdadm --detail /dev/md0

create the filesystem on raid array OR with parted mkfs.ext4 /dev/md0 or parted /dev/md0 mkpart primary ext4 0% 100%

mount the raid array mount /dev/md0 /mnt/raid

mount the drive containing all of the data mount /dev/sdb /mnt/extdisk

copy data to empty portion of the Raid1 using whatever arguments for rsync you prefer rsync -av /media/tb1/ /media/raid1

unmount the drive containing the data (which is not part of the raid set) sudo umount /media/tb1

FIRST CREATE PARITIONTABLE AND FS ON THE OLD ONE

add said drive to the array sudo mdadm --add /dev/sda1

Obviously, substitute your drive naming scheme for the one's I've used, paying close attention to detail.

Wait for sync.....and mount on startup via fstab.

cat /proc/mdstat Personalities : [raid1] md0 : active raid1 sda1[2] sdd1[0] 976759936 blocks [2/1] [U_] [==>..................] recovery = 10.3% (101263680/976759936) finish=134.6min speed=108370K/sec

Change sync speed limits

Syncing can take a while. If the machine is not needed for other tasks the speed limit can be increased.

cat /proc/mdstat

Personalities : [raid10] md127 : active raid10 sdd1[3] sdc1[2] sdb1[1] sda1[0] 31251490816 blocks super 1.2 512K chunks 2 far-copies [4/4] [UUUU] [=>...................] resync = 5.2% (1629533760/31251490816) finish=2071.7min speed=238293K/sec bitmap: 221/233 pages [884KB], 65536KB chunk In the above example, it would seem the max speed is limited to approximately 238 M/sec.

Check the current speed limit:

sysctl dev.raid.speed_limit_min

dev.raid.speed_limit_min = 1000

sysctl dev.raid.speed_limit_max

dev.raid.speed_limit_max = 200000 Set a new maximum speed of raid resyncing operations using sysctl:

sysctl -w dev.raid.speed_limit_min=600000

sysctl -w dev.raid.speed_limit_max=600000

Then check out the syncing speed and estimated finish time.

cat /proc/mdstat

Personalities : [raid10] md127 : active raid10 sdd1[3] sdc1[2] sdb1[1] sda1[0] 31251490816 blocks super 1.2 512K chunks 2 far-copies [4/4] [UUUU] [=>...................] resync = 5.3% (1657016448/31251490816) finish=1234.9min speed=399407K/sec bitmap: 221/233 pages [884KB], 65536KB chunk