Sunday, June 28, 2009

After Near Miss, New RAID is Bliss


As I stated in my previous post, I recently purchased five 1TB drives to expand my home NAS system (a Thecus N5200). I had two ways to set this up:

1. Replace each of my old drives separately, one at a time, with a new drive. Rebuild the RAID with each drive replacement. When all new drives were in and all old ones out, I would click "EXPAND" in the NAS's admin screen and it would use all drive space.

2. Remove all old drives, and replace with all new drives. Build a new empty RAID5 on the new drives. Then copy over all my data from an external backup.

#1 has the advantage of keeping all my data and NAS settings intact during the process, but would take infinitely longer since I would have had to rebuild the entire RAID at least three times, most likely 5.

#2 would be way faster, but would require copying all the data from backup, and the files would not be accessible until the upgrade was complete.

So I chose #2. I didn't want to rebuild the RAID tons of times, when each time could take many hours, if not days.

Now here's the kicker...my backup included everything from the NAS, including NAS system files. I figured copying those back could keep my settings and modules intact.

Long story short...I replaced all drives at once, started copying the files back, and all seemed fine. Until I rebooted the NAS.

After a reboot, I noticed that all the data was there, but it was read-only. I couldn't write any files onto the NAS at all. Plus, all the modules I had installed (like SSH support, FTP server, etc) were showing as installed, but would not work. I couldn't even uninstall and reinstall modules. When I tried, nothing would happen.

I quickly realized that copying the modules back from my backup probably overwrote the proper permissions/ownerships on all those files, causing the NAS not to be able to read them correctly. If I had SSH access into the box, I could fix that, but SSH access was only available as a module. Crap.

Plus, why was it all read-only? Uggg!

Anyway, after resetting to factory defaults, updating the firmware, and other non-successful rescue attempts, I did some research. Luckily, I found a script someone wrote that I could install on the NAS (through the firmware upgrade screen) that would simply rename the old modules database, causing the NAS to create a new empty one. Perfect. This would allow me to reinstall all my modules and get SSH working. (Script is named Renmod and can be found here)

That worked beautifully. Now I was able to SSH in and start changing permissions and such. Well, I changed all the permissions and owners of the data, but the filesystem was still read-only.

So last thing I did was edit each share through the NAS admin. I had to disable the public flag, edit the ACL to add all my users to the share, then re-enable the public flag. That did the trick!

Now I have all my data, tons of space, and a scripted nightly backup to an external 1TB drive connected through the NAS's esata port. Sweet! I'll have to create a How-To at some point to explain how I got the nightly RSYNC to work. It's an interesting bunch of scripts :-)

No comments: