Skip to content

mdadm

Verschoben Linux
  • Info

    raid_pool0 = sda1 = /dev/mapper/raid_pool0
    raid_pool1 = sdb1 = /dev/mapper/raid_pool1
    

    Verschlüsseln

    sudo cryptsetup --key-size 512 --hash sha256 --iter-time 5000 --use-random luksFormat /dev/sda1
    sudo cryptsetup --key-size 512 --hash sha256 --iter-time 5000 --use-random luksFormat /dev/sdb1
    

    Platten entschlüsseln

    sudo cryptsetup open /dev/sda1 raid_pool0
    sudo cryptsetup open /dev/sdb1 raid_pool1
    

    RAID1 anlegen

    sudo mdadm --create /dev/md0 --auto md --level=1 --raid-devices=2 /dev/mapper/raid_pool0 /dev/mapper/raid_pool1 
    
    sudo mkfs.ext4 /dev/md0
    

    Script zum Entschlüsseln und Mounten

    #!/bin/bash
    ###############################################################################$
    #       Autor: Frank Mankel
    #       Verschlüsseltes Raid1 einbinden!
    #
    #       Hardware:
    #       ROCKPro64v2.1
    #       PCIe SATA Karte
    #       2St. 2,5 Zoll HDD Platten a 2TB
    #
    #       Software:
    #       bionic-minimal 0.7.9
    #
    ###############################################################################$
    
    #Passwort abfragen
    echo "Passwort eingeben!"
    read -s password
    echo "Bitte warten......"
    
    #Passwörter abfragen
    echo -n $password | cryptsetup open /dev/sda1 raid_pool0 -d -
    echo -n $password | cryptsetup open /dev/sdb1 raid_pool1 -d -
          
    #Raid1 mounten
    mount /dev/md0 /mnt/raid
    
    echo "Laufwerke erfolgreich gemountet!"
    
  • Wir möchten dieses vorhandene Raid1 auf einem neuen Betriebssystem wieder aktivieren!

    Erstmal was installieren

    sudo apt install cryptsetup
    sudo apt install mdadm
    

    Danach ließ sich das Device /dev/md0 nicht mounten.

    frank@rockpro64:~$ sudo mount /dev/md0 /mnt/raid
    mount: special device /dev/md0 does not exist
    

    Irgendwie logisch. Das haben wir beim letzten Mal ja auch angelegt, ist jetzt aber natürlich nicht angelegt. Ok, wie bekommen wir das jetzt wieder an den Start?

    sudo mdadm --assemble --scan
    

    Danach ist das Device wieder vorhanden und das Script funktioniert wieder wie gewohnt.

  • Mein RAID1 war mal wieder nicht komplett 😞

    Da beide Platten verschlüsselt sind, werden diese erst mal entsperrt.

    cryptsetup open /dev/sda1 raid_pool0
    cryptsetup open /dev/sdb1 raid_pool1
    

    Danach geht es weiter...

    Nach fdisk -l

    Disk /dev/mapper/raid_pool0: 1,8 TiB, 2000395771392 bytes, 3907022991 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/md0: 1,8 TiB, 2000260497408 bytes, 3906758784 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    
    
    Disk /dev/mapper/raid_pool1: 1,8 TiB, 2000395771392 bytes, 3907022991 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 4096 bytes
    I/O size (minimum/optimal): 4096 bytes / 4096 bytes
    

    Mir fehlt das Device /dev/md1 Warum??? Keine Ahnung!!!

    Schauen wir mal nach, was noch lebt.

    root@rockpro64v_2_1:~# mdadm --examine --scan
    ARRAY /dev/md/0  metadata=1.2 UUID=33ac7964:473fe590:3682dd85:a979b336 name=rockpro64v_2_1:0
    

    So, Device md0 lebt 🙂

    Wir mounten das noch lebende Laufwerk.

    mount /dev/md0 /mnt/raid
    

    Danach geschaut, ob mit NFS die Daten erreichbar sind. Alles OK.

    Kurz checken

    root@rockpro64v_2_1:~# cat /proc/mdstat
    Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
    md0 : active raid1 dm-0[2]
          1953379392 blocks super 1.2 [2/1] [U_]
          bitmap: 7/15 pages [28KB], 65536KB chunk
    
    unused devices: <none>
    

    Da sieht man das ein Laufwerk fehlt. Dann wollen wir mal adden 😉

    root@rockpro64v_2_1:~# mdadm /dev/md0 --manage --add /dev/mapper/raid_pool1
    mdadm: re-added /dev/mapper/raid_pool1
    

    Jetzt läuft das Recovery

    root@rockpro64v_2_1:~# cat /proc/mdstat
    Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
    md0 : active raid1 dm-1[1] dm-0[2]
          1953379392 blocks super 1.2 [2/1] [U_]
          [>....................]  recovery =  1.2% (25185728/1953379392) finish=604.2min speed=53184K/sec
          bitmap: 7/15 pages [28KB], 65536KB chunk
    
    unused devices: <none>
    

    Und Fertig 🙂

    root@rockpro64v_2_1:~# cat /proc/mdstat
    Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10] 
    md0 : active raid1 dm-1[1] dm-0[2]
          1953379392 blocks super 1.2 [2/2] [UU]
          bitmap: 0/15 pages [0KB], 65536KB chunk
    
    unused devices: <none>
    

    Daten kontrolliert, noch alles da. Puuuuuh! Aber, warum das Ganze???? Ich bin übrigens jetzt wieder auf Kamils Image und dabei ist mir aufgefallen, das das Recovery wesentlich schneller ging als bei meinem letzten Versuch. Hmm???????

    Zum Schluß noch was aus dem dmesg

    [    8.612039] ata1: SATA max UDMA/133 abar m512@0xfa010000 port 0xfa010100 irq 231
    [    8.612047] ata2: SATA max UDMA/133 abar m512@0xfa010000 port 0xfa010180 irq 231
    [    9.085894] ata1: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
    [    9.123159] ata1.00: ATA-10: ST2000LM015-2E8174, SDM1, max UDMA/133
    [    9.123169] ata1.00: 3907029168 sectors, multi 16: LBA48 NCQ (depth 32), AA
    [    9.172776] ata1.00: configured for UDMA/133
    [    9.173235] scsi 0:0:0:0: Direct-Access     ATA      ST2000LM015-2E81 SDM1 PQ: 0 ANSI: 5
    [    9.173782] sd 0:0:0:0: [sda] 3907029168 512-byte logical blocks: (2.00 TB/1.82 TiB)
    [    9.173792] sd 0:0:0:0: [sda] 4096-byte physical blocks
    [    9.173889] sd 0:0:0:0: [sda] Write Protect is off
    [    9.173896] sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
    [    9.173933] sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
    [    9.239218]  sda: sda1
    [    9.240144] sd 0:0:0:0: [sda] Attached SCSI disk
    [    9.649853] ata2: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
    [    9.687095] ata2.00: ATA-10: ST2000LM015-2E8174, SDM1, max UDMA/133
    [    9.687104] ata2.00: 3907029168 sectors, multi 16: LBA48 NCQ (depth 32), AA
    [    9.696476] NFSD: starting 45-second grace period (net f00000a1)
    [    9.736698] ata2.00: configured for UDMA/133
    [    9.737137] scsi 1:0:0:0: Direct-Access     ATA      ST2000LM015-2E81 SDM1 PQ: 0 ANSI: 5
    [    9.739557] sd 1:0:0:0: [sdb] 3907029168 512-byte logical blocks: (2.00 TB/1.82 TiB)
    [    9.739568] sd 1:0:0:0: [sdb] 4096-byte physical blocks
    [    9.739592] sd 1:0:0:0: [sdb] Write Protect is off
    [    9.739597] sd 1:0:0:0: [sdb] Mode Sense: 00 3a 00 00
    [    9.739631] sd 1:0:0:0: [sdb] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
    [    9.803472]  sdb: sdb1
    [    9.804397] sd 1:0:0:0: [sdb] Attached SCSI disk
    [   22.550770] rk_gmac-dwmac fe300000.ethernet eth0: Link is Up - 100Mbps/Full - flow control off
    [   22.550820] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
    [   42.132977] device-mapper: uevent: version 1.0.3
    [   42.133199] device-mapper: ioctl: 4.39.0-ioctl (2018-04-03) initialised: dm-devel@redhat.com
    [  141.047476] md/raid1:md0: active with 1 out of 2 mirrors
    [  141.061140] md0: detected capacity change from 0 to 2000260497408
    [  522.183161] EXT4-fs (md0): mounted filesystem with ordered data mode. Opts: (null)
    [  559.062705] nfsd: last server has exited, flushing export cache
    [  559.084203] NFSD: starting 45-second grace period (net f00000a1)
    [  840.473519] md: recovery of RAID array md0
    [ 1141.650170] md: md0: recovery done.
    
  • Ok, öfter was Neues 🙂

    Mein Device md0 war weg, das hieß nun /dev/md127 !?!?!

    Gut, etwas gelesen, dann neugestartet.

    Die Datei /etc/mdadm/mdadm.conf geändert

    # mdadm.conf
    #
    # !NB! Run update-initramfs -u after updating this file.
    # !NB! This will ensure that initramfs has an uptodate copy.
    #
    # Please refer to mdadm.conf(5) for information about this file.
    #
    
    # by default (built-in), scan all partitions (/proc/partitions) and all
    # containers for MD superblocks. alternatively, specify devices to scan, using
    # wildcards if desired.
    #DEVICE partitions containers
    
    # automatically tag new arrays as belonging to the local system
    HOMEHOST <system>
    
    # instruct the monitoring daemon where to send mail alerts
    MAILADDR root
    
    # definitions of existing MD arrays
    
    # This configuration was auto-generated on Sat, 20 Oct 2018 09:01:46 +0200 by mkconf
    ARRAY /dev/md0 level=raid1 num-devices=2 metadata=1.20 UUID=33ac7964:473fe590:3682dd85:a979b336
    

    An die Daten, was man da eintragen muss kommt man mit

    rock64@rp64v_2_1_NAS:~$ sudo mdadm --detail /dev/md0
    mdadm: metadata format 1.20 unknown, ignored.
    /dev/md0:
               Version : 1.2
         Creation Time : Sat Oct 20 09:05:51 2018
            Raid Level : raid1
            Array Size : 1953379392 (1862.89 GiB 2000.26 GB)
         Used Dev Size : 1953379392 (1862.89 GiB 2000.26 GB)
          Raid Devices : 2
         Total Devices : 2
           Persistence : Superblock is persistent
    
         Intent Bitmap : Internal
    
           Update Time : Thu Feb  7 20:10:12 2019
                 State : clean 
        Active Devices : 2
       Working Devices : 2
        Failed Devices : 0
         Spare Devices : 0
    
    Consistency Policy : bitmap
    
                  Name : rockpro64v_2_1:0
                  UUID : 33ac7964:473fe590:3682dd85:a979b336
                Events : 66932
    
        Number   Major   Minor   RaidDevice State
           2     252        1        0      active sync   /dev/dm-1
           1     252        0        1      active sync   /dev/dm-0
    

    Nach dem Eintragen der Änderungen den Befehl hier nicht vergessen 😉

    update-initramfs -u
    

    Mal schauen ob das jetzt mal was länger klappt 🙂

  • Nachdem ich die SATA-Karte gewechselt habe, sind meine Probleme verschwunden. Mein NAS läuft seit Monaten einwandfrei.

    rock64@rp64v_2_1_NAS:~$ uptime
     21:57:50 up 73 days,  4:44,  1 user,  load average: 0,00, 0,00, 0,00
    

    https://forum.frank-mankel.org/topic/299/sata-karte-marvell-88se9230-chipsatz/16

  • Plasma 6

    Linux
    1
    0 Stimmen
    1 Beiträge
    65 Aufrufe
    Niemand hat geantwortet
  • Links zu Vaultwarden

    Vaultwarden
    1
    0 Stimmen
    1 Beiträge
    95 Aufrufe
    Niemand hat geantwortet
  • Restic v0.16.0 released

    Restic
    1
    0 Stimmen
    1 Beiträge
    89 Aufrufe
    Niemand hat geantwortet
  • Star64 - Bootvorgang

    Hardware
    1
    0 Stimmen
    1 Beiträge
    64 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    1 Beiträge
    313 Aufrufe
    Niemand hat geantwortet
  • Debian Buster 10.7 released

    Linux
    1
    0 Stimmen
    1 Beiträge
    201 Aufrufe
    Niemand hat geantwortet
  • Restic - forget --keep-last 3 --prune

    Restic
    2
    0 Stimmen
    2 Beiträge
    576 Aufrufe
    FrankMF

    Ich habe mich damit noch ein wenig beschäftigt, die letzten drei zu behalten, ist nicht so optimal. Da es viele Optionen bei dem Befehl gibt, hier ein Ausschnitt

    Flags: -l, --keep-last n keep the last n snapshots -H, --keep-hourly n keep the last n hourly snapshots -d, --keep-daily n keep the last n daily snapshots -w, --keep-weekly n keep the last n weekly snapshots -m, --keep-monthly n keep the last n monthly snapshots -y, --keep-yearly n keep the last n yearly snapshots

    habe ich das ein wenig so angepasst, das ich denke es passt für mich.

    restic --password-file /root/passwd -r /media/NAS_neu/Restic/Home/ forget --keep-last 3 --keep-monthly 3 --prune

    Damit behalte ich auch die jeweils eines pro Monat. Und die letzten drei. Das sieht dann so aus.

    root@debian:~# ./backup2.sh repository 2f3f6147 opened successfully, password is correct Files: 38 new, 100 changed, 13268 unmodified Dirs: 0 new, 1 changed, 0 unmodified Added to the repo: 10.166 GiB processed 13406 files, 50.324 GiB in 3:24 snapshot 849f614c saved repository 2f3f6147 opened successfully, password is correct Applying Policy: keep the last 3 snapshots, 3 monthly snapshots snapshots for (host [debian], paths [/home/frank]): keep 5 snapshots: ID Time Host Tags Reasons Paths ------------------------------------------------------------------------------------ a7251cfd 2019-11-28 17:00:01 debian monthly snapshot /home/frank 283d4027 2019-12-31 17:00:01 debian monthly snapshot /home/frank ae2b96ec 2020-01-01 21:47:46 debian last snapshot /home/frank 079e00a6 2020-01-02 17:00:01 debian last snapshot /home/frank 849f614c 2020-01-03 21:08:45 debian last snapshot /home/frank monthly snapshot ------------------------------------------------------------------------------------ 5 snapshots remove 26 snapshots: ID Time Host Tags Paths ------------------------------------------------------------------ 896f16c2 2019-11-07 22:23:40 debian /home/frank b21bcf6d 2019-11-11 17:00:01 debian /home/frank f89248fb 2019-11-12 17:00:01 debian /home/frank 123ab546 2019-11-13 17:00:01 debian /home/frank b82d87d0 2019-11-18 17:00:01 debian /home/frank 040b0ab7 2019-11-19 17:00:01 debian /home/frank 7221d8ef 2019-11-20 17:00:01 debian /home/frank 84132a25 2019-11-21 17:00:01 debian /home/frank b558a52c 2019-11-25 17:00:01 debian /home/frank e5cc0c3e 2019-12-02 17:00:01 debian /home/frank 22423fa5 2019-12-03 17:00:01 debian /home/frank 39df1ab9 2019-12-04 17:00:01 debian /home/frank 98843457 2019-12-05 17:00:01 debian /home/frank b0cdd4b6 2019-12-09 17:00:01 debian /home/frank 828414f9 2019-12-10 17:00:01 debian /home/frank e34a27c3 2019-12-11 17:00:01 debian /home/frank 6e488c3b 2019-12-12 17:00:01 debian /home/frank 17898403 2019-12-16 17:00:01 debian /home/frank 1973305a 2019-12-17 17:00:01 debian /home/frank 9553bedd 2019-12-18 17:00:01 debian /home/frank fedf749d 2019-12-19 17:00:01 debian /home/frank 8e7cb876 2019-12-23 17:00:01 debian /home/frank 0bd0d102 2019-12-25 17:00:01 debian /home/frank 13d348b0 2019-12-26 17:00:01 debian /home/frank c7d960aa 2019-12-30 17:00:01 debian /home/frank f6ea9118 2020-01-01 17:00:01 debian /home/frank ------------------------------------------------------------------ 26 snapshots 26 snapshots have been removed, running prune counting files in repo building new index for repo [0:35] 100.00% 7806 / 7806 packs repository contains 7806 packs (46537 blobs) with 41.110 GiB processed 46537 blobs: 0 duplicate blobs, 0 B duplicate load all snapshots find data that is still in use for 5 snapshots [0:01] 100.00% 5 / 5 snapshots found 32654 of 46537 data blobs still in use, removing 13883 blobs will remove 0 invalid files will delete 715 packs and rewrite 752 packs, this frees 5.027 GiB [2:28] 100.00% 752 / 752 packs rewritten counting files in repo [0:01] 100.00% 6571 / 6571 packs finding old index files saved new indexes as [d137b425 f7caee99 a6e9711a] remove 35 old index files [1:13] 100.00% 1467 / 1467 packs deleted done using temporary cache in /tmp/restic-check-cache-916655151 repository 2f3f6147 opened successfully, password is correct created new cache in /tmp/restic-check-cache-916655151 create exclusive lock for repository load indexes check all packs check snapshots, trees and blobs read all data [7:47] 100.00% 6571 / 6571 items duration: 7:47 no errors were found root@debian:~#

    Am Ende seht ihr noch, wie Restic alle Files testet. Mein Script sieht jetzt so aus.

    #!/bin/bash # Script um mit Restic Daten automatisiert zu sichern! # Dient zum Sichern der Homepartition auf dem ROCKPro64 NAS! # Was soll gesichert werden? backup_pfad=/home/frank # Programm Start restic --password-file /root/passwd -r /media/NAS_neu/Restic/Home/ backup $backup_pfad --exclude-file=excludes.txt restic --password-file /root/passwd -r /media/NAS_neu/Restic/Home/ forget --keep-last 3 --keep-monthly 3 --prune # Testen restic --password-file /root/passwd -r /media/NAS_neu/Restic/Home/ check --read-data

    Das dann schön mit einem Cronjob laufen lassen und die Datensicherung ist erledigt 😉

  • NVMe Firmware - Daten werden benötigt

    Linux
    1
    0 Stimmen
    1 Beiträge
    702 Aufrufe
    Niemand hat geantwortet