Saturday 19 January 2013

Migrating QNAP NAS from Raid 1 to Raid 5


What a mess!!

BACKUP FIRST!! Somehow I didn't even need it in the end :-)

Well, I think I have eventually managed to work out how to get my raid migrated from Raid 1 to Raid 5 after adding a new drive (surprisingly without loosing any data), and let me tell you something I would feel sorry for the average guy who doesn't know too much about Linux or computers to be able to do this on the command line. I feel that the UI isn't up to coping with a situation that something doesn't go correctly too well. This was not a straight forward thing to do and probably the first thing I would do is to never use the UI provided to do this, its next to useless! No really! the best thing to do is to learn how to do it manually from the command line, I had a lot more confidence working with Linux directly over this UI. 

It has taken me a couple of weeks and I have my NAS back up and running at Raid level 5 with the new drive and over 50 emails back and fore to support which was very helpful and responsive and gave many clues but in the end I worked out the bulk of it myself, which gave me a great sense of achievement and knowledge. 
I think I rebuilt Raid 1, 3 - 4 times, Raid 5 twice, while removing and trying to re-add my new drive, also scanning drives for bad blocks and as they are all 2 TB drives this doesn't give results back that quickly. So now I am going to try and document what i did to get this to work with the help of a few links one of which I was guided to by the QNAP Support.

So the useful links I had were the following:
Thread 1: viewtopic.php?t=12109

This was the most useful one for clues on the process of what I needed to do, I got so far with this one and failed to unmount the drive as there were services still being used so I needed to run "/etc/init.d/services.sh stop" this stopped all the services I could then unmount the drive. Further down this thread from "abmagfab" he gives more information if you need to grow the raid also.
Thread 2:http://www.davelachapelle.ca/2008/07/25 ... to-raid-5/

This one gave more more information on how to convert the Raid 1 to Raid 5 on 2 disks and then add the new drive. Also very useful. I think I would just use this thread next time.

The trouble with doing all this from the command line is that the UI will start to look incorrect as the files that the UI relies on does not get updated when running these commands on command line. The files were /etc/storage.conf and /etc/config/raidtab. I wasn't sure what I needed to update on these files so I kind of guessed, when I had 3 drives at Raid level 5 I set them accordingly. I tried to find more information about these files and what the different parameters meant but I couldn't, so please if anyone knows where I can find information on this please post here, I would love to understand how they are used and what the possible values to the possible parameters are. thanks  

So I would just follow thread 2 but I would also unmount the /dev/md0 also so would need to run the "services.sh stop" command.

It wasn't as straight forward as the thread as I had already started playing with mdadm and I got things in a bit of a state but I managed to get it all back to a nice state and learned a lot on the way (surprisingly without loosing data too!)

I had a situation once where all was complete, but my /dev/md0 would not automount I had forgotten to turn the journaling back on with the /dev/md0 (quite easily done when you have rebuild times over night and day, I kind of forget what I did! ha ha) once I did that and rebooted, voila! auto mounted!

dmesg is your friend, it can give quite a few clues, I will explain how I found the journaling off problem...When I ran dmesg straight after boot and after I manually mounted /dev/md0 (mount /dev/md0 /share/MD0_DATA -t ext4) it gave me the following on the last line of dmesg:
EXT4-fs (md0): mounted filesystem without journal
I saw the "without journal" and that triggered my memory about whether i turned it off or not and a quick search online of what happens when mounting without journal, gave me some more clues so I just turned it back on using command in Link1 and all seemed to be fine again 

Don't ask me how I didn't loose any data, but I didn't (well not that I have noticed yet!). mdadm is very robust and usable just make sure to read the man pages for all the options that you are about to use from any links that you follow and you can learn a lot just like me 

I am sure it will help me in the future when I forget all this in a few months (well few minutes really)

I hope this helps someone else.

1 comment:

  1. Somewhere the content of the blog surrounded by little arguments. Yes it is healthy for readers. They can include this kind of language in their writing skill as well as while group discussion in college.QNAP TS X51 Series

    ReplyDelete