Skip to content

Instantly share code, notes, and snippets.

@nvpnathan
Last active March 20, 2024 10:17
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nvpnathan/827aac9e972f22233ca63d17e2fbea04 to your computer and use it in GitHub Desktop.
Save nvpnathan/827aac9e972f22233ca63d17e2fbea04 to your computer and use it in GitHub Desktop.

Run mdadm - this command is used to manage and monitor software RAID devices in linux.

mdadm --detail /dev/md0 or md<N>

mount -t ext4 /dev/md0 /share/MD0_DATA

Check disks

mdadm --examine /dev/sdd3

cat /proc/mdstat

Add disk back to raid that is "removed"

mdadm --manage /dev/md0 --add /dev/sdd3

After this you should see your raid start to rebuild again.

If that doesn't work check to see if the RAID is online

md_checker

1 – Download the file to NAS:

wget http://download.qnap.com/Storage/tsd/utility/md_checker

2 – Apply execute permission:

chmod +x md_checker

3 – Run the script: ./md_checker

II – Fixing RAID With Usign AFR Command (Safe Way)

If your RAID structure seems “Not Active” and cannt access your files, you can fix this by this way;

Warning; if you’re not sure, don’t do it yourself, contact qnap support!

so we type this command line to fix our RAID;

mdadm -AfR /dev/md0 /dev/sda3 /dev/sdb3 /dev/sdc3 /dev/sdd3

What if we got “missing” or “Rebuildin” HDD? you must fallow right order & dont add “Missing” HDD’s to this command line

1 – Type This command to get RAID back online again;

mdadm -AfR /dev/md0 /dev/sdg3 /dev/sdh3 /dev/sda3 /dev/sdf3 /dev/sdc3 /dev/sdd3 /dev/sdb3

2 – And Now RAID Becomes Active Again!

md_checker

3 – To mount RAID back again;

/etc/init.d/init_lvm.sh

4 – Now RAID Comes back, and rebuilding start!

@nvpnathan
Copy link
Author

When I run “ /etc/init.d/init_lvm.sh”. I get “no such directory exists”. Any ideas?

It most have been removed in an update. My QNAP does not have this shell script anymore either.

@Wetzel402
Copy link

I found this very useful along with a great answer on superuser.com and the excellent support I received from QNAP. I wanted to share my steps to recovering my raid for others.

  1. Power down NAS
  2. Pull drives out about an inch or so. We want the NAS to boot as a new uninitialized device. We also don't want to mix up the drive order.
  3. Power on the NAS.
  4. Using Qfinder Pro, right click on the NAS and select connect via SSH, login with the default admin account. The password will be the MAC address of the device excluding colons.
  5. Open a terminal and SSH into the NAS using the default admin account.
  6. Run md_checker to see the raid(s)
  7. Bring up the raid(s) using mdadm (mdadm -AfR /dev/md0 /dev/sdg3 /dev/sdh3 /dev/sda3 /dev/sdf3)
  8. Assuming you are using thin or thick volumes run vgscan to find you volume group name(s)
  9. Activate the volume (vgchange -ay vg1)
  10. Run lvs to list logical volume(s)
  11. Create a mount point (mkdir /dev/mapper/cachedev1)
  12. Finally mount the raid (mount -t ext4 /dev/vg1/lv1 /dev/mapper/cachedev1)

*** repeat as necessary for other raids

In my case I had a bad superblock so I attempted to use a backup super block. None of them worked but the raid did mount using the noload option and I was still able to recover my data.

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