I am on Linux Mint 18.1 with 4.8 kernel.

Question is: How to check (mdadm) software RAID array, if the e.g. the swap file is on it?

I need the correct procedure before and after calling the checkarray script to define proper alias.

  • You just do. No need to swapoff or umount. Not sure what gives you that idea. – frostschutz Mar 24 '17 at 11:07

In this example the array is called md0 and it's mounted in /raid1.

Check array alias:

  1. Supposing a swap file is located on the array, we need to turn it off first. If that is the only swap area on the system, we can do:

    sudo swapoff --all
  2. The array needs to be unmounted in order for it to be checked properly:

    sudo umount /raid1
  3. After this preparation took place, we may call the checkarray script, I chose fast priority, but you may choose any priority option:

    sudo /usr/share/mdadm/checkarray --fast /dev/md0
  4. If you wish to watch the progress of the array check every second:

    watch -n 1 cat /proc/mdstat

So the complete bash check array alias located e.g. in your personal .bash_aliases file would look something like:

alias checkarray='sudo swapoff --all && \
                  sudo umount /raid1 && \
                  sudo /usr/share/mdadm/checkarray --fast /dev/md0 && \
                  watch -n 1 cat /proc/mdstat'

Make sure you close all open files on the array before calling it.

After-Check array alias:

I think no further comments needed:

alias checkarray-after='sudo mount /dev/md0 /raid1 && \
                        sudo swapon --all'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.