Saturday, April 26, 2014

Zyxel NSA-210 successfully running 4TB Seagate 4000DM000

This walkthrough will tell You how to make Your >2TB work in Zyxel NSA-210 with newest firmware when disk initialization fails. It does not contain images currently, maybe later. Maybe hard to understand and not enough detailed. I wrote it after I succedded and it was hard to remember all correct steps after 2 days of continous work on this issue. Also I consider that You have a bit of Linux knowledge that's why I skipped details here and there. Feel free to ask questions in comments.

Make Zyxel NSA-210 support Your 4TB HDD.

What will You need:
- Linux x64 (required, I used CentOS, can be in VirtualBox),
- USB->SATA bridge or desktop computer (required)
- Additional tools listed in this walkthrough if You don't have full installation of Linux (required)
- Patience (optional :)
- Clonezilla or other able to read EXT3 and XFS (optional)
- >2TB HD (optional, that is if You have one)
- <2TB HD (required, can be old HD that You kept in NAS)

First You may like to boot up Your NAS with old disk and check if everything works. If You didn't boot it up ever, then You need to do it with HD that is less than 2TB, even old 40GB SATA will do, we just need to initialize it with tools that were shipped with the NAS (or newer ones available on Zyxel site to download. WARNING! MUST BE FOR NSA-210, even if program is the same, newest versions for other models will just not work correctly, even if it appears so).

So init the old HD in NAS with newest firmware so it boots up, You can start setting it up but it's recommended not to make any shares and users yet, let it have admin only (root for shares). You should use as little space HD as possible because clonning it (if You decide to do so) will take a while. If You didn't put 4.41 version of firmware during disk inition (in disk init wizard) then download it now from Zyxel site and update the firmware with web interface. It's important to have newest one due to 4TB disk support, even though You may have trouble making it work at all.

Turn off NAS and take out old HD, use USB->SATA bridge or 2.5 inch USB case (in case You used this size to init Your Zyxel - yes it's possible to put in 2.5 inch HD, it just needs SATA sockets), or connect it inside Your desktop if You have one.

Now the things can get tricky. But You will need linux anyway, clonezilla itself will MOST LIKELY NOT help You, even though it may appear that Your NAS read it.

Easiest way to move firmware data is to just clone old HD onto new HD either using device->device setup with clonezilla or device->image then image->device setup. It's recommended to copy whole harddrive. WARNING! MAKE SURE TO UNCHECK PARTITION RESIZING!!! If You fail in any of steps after this You need to start over doing this.

Alternative way is to make Linux read Your partitions and copy the data on old HD to Your home directory. WARNING! BOTH PARTITIONS MUST BE COPPIED IN SEPARATE DIRECTORIES AND ALL HIDDEN FILES, AND FILE PERMISSIONS MUST BE PRESERVED (all, even when groups/users IDs don't exists on Your linux box/virtualbox).

Access Your old HD and new HD with Linux x64 box or virtual guest machine. In case of using USB->SATA adapters and VirtualBox make sure You don't use USB 3.0 connection, it will fail to read the drive even when 1.1 mode is set in VB - just use 2.0 cable or connect to USB 2.0/ USB 2.0 hub. You need to run terminal as root then type: fdisk -l and using Your sharp eyes and brain to distinguish between disk names like /dev/sda, /dev/sdb, /dev/sdc etc. Now if You already know which one is Your old HD then note down starting and ending point of first partition and starting point of 2nd partition. If You used clonezilla You most likely have same structure on Your new HD. You may already know what I want You to do but STOP, DON'T CREATE ANY PARTITIONS ON NEW HD (or alter them when cloned).

We now need gdisk or parted, because we need to make MBR into GPT partition table on new HD - Yes new firmware reads it all right. Both solutions are valid but I prefer parted myself more, even though it's most likely harder to use but at the same time I know what I'm doing because all things are done manually. Doesn't matter if You cloned Your HD or are starting on fresh HD, Your data will be intact if You DON'T do any mistake here because basically what we are editing is main partition table and XFS file system can be resized pretty nicely.

So now run parted on Your new HD. For example parted /dev/sdc (if sdc is Your new HD THAT IS!). Type in print and confirm that You have cloned partitions or empty table. Now type in mklable gpt. If You had cloned HDs it will give warning information, answer Yes. Now we need to switch to sectors as the measuring unit, type in unit s. Now check Your noted start and end sectors from original disk back when You used fdisk. For me they were: partition 1 - Start: 63, End: 1028159, partition 2 - Start: 1028160, End: not important. Now I would type mkpart primary ext3 63 1028159. Ignore the warning. Now type print and confirm that start and end sector matches Your previously noted range. Also take a look at reported number of sectors by the disk. This is kind of importand because You can't go over that range when creating second partition for data, in fact, You must stay away a bit from the end due to one sector being used for GPT partition table backup and it doesn't exactly means it's the last. Let's make 2nd partition, I typed mkpart primary xfs 1028160 7814033472, and again ignore the warning. I got away by like 2000 or 20000 sectors away, don't remember, but it's not that important if it's that away from the end of HD. You can also name both partiton, first should be named firmware, second is second. Not sure if it's necessary, but I did that just incase.
quit parted.

If You cloned image then You can skip this place. If You didn't then You now need to make ext3 file system on first partition and xfs on 2nd partition. You can search the internet on how to do that. No special settings need to be used here, just make sure they are the same size as place alligned for partition. After making file systems You need to copy all previously backed up data from old HD to new HD or directly copy if You have both HDs connected. WARNING! ALL HIDDEN FILES, AND FILE PERMISSIONS MUST BE PRESERVED. WARNING2! Be sure that Your XFS partition has disabled lazy-count, mount the XFS partition and run xfs_info on the mountpoint. If it has enabled lazy-count then You must umount it and run command that looked like this in my example: xfs_admin -c 0 /dev/md127. I have suspision that if You don't disable it You may run into the same problem as me, disk full messages after writing ~100GB to the HD.

This step is for people that used clonezilla previously. Now You need to mount XFS file system. You need to add -t xfs in the line since system may not detect it automatically. Now let's resize it by typing: xfs_growfs mount_point. It may take a while in case of big HD so go make Yourself a cup of tea or coffee. :)
After this confirm that all files are still visible on both partitions and umount them.

Now You basically should be ready to put Your new HD into Zyxel? Go on and try it... You will be susrpised that all this work is NOT YET ENOUGH! Why? Well You may have noticed something when running fdisk -l on old HD. There is some additional information under old disk. Yes, that's right. A RAID-Linear volume. Why the hell would the use RAID in one HD Zyxel? No idea, but I think it's to avoid errors when booting with USB drive connected, or to show more volumes if there are any (most likely it's possible), because Zyxel doesn't look for sdXY when booting, it searches for MD0 only for data storage.

How the heck then we make RAID stuff. Especially that we just made partitions and checked that data is intact. Well, it won't hurt Your already existing partitions if You do everything RAID, I mean right. :)

First we would like to read all RAID stuff on old HD, by typing mdadm --detail /dev/mdX where X is the thing that fdisk -l reported for old HD. For example my output looked like this:

[root@localhost media]# mdadm --detail /dev/md127
/dev/md127:
        Version : 0.90
  Creation Time : Tue Apr 22 18:36:51 2014
     Raid Level : linear
     Array Size : 155774208 (148.56 GiB 159.51 GB)
   Raid Devices : 1
  Total Devices : 1
Preferred Minor : 127
    Persistence : Superblock is persistent

    Update Time : Thu Apr 24 11:50:17 2014
          State : clean 
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

       Rounding : 64K

           UUID : 8296b7ff:c19f6ddc:7c88728c:d0f54ce9
         Events : 0.29

    Number   Major   Minor   RaidDevice State
       0       8       18        0      active sync   /dev/sdb2

So we now need to create similar thing for new HD, having in mind that most of the info must match and we need to use MDx that is not yet used. For this I ran this command: 
mdadm --create --verbose /dev/md0 --level=linear --raid-devices=1 --rounding=64K /dev/sdc2 --metadata=0.9 --force

It may be important to use 0.9 version metadata otherwise Zyxel may fail to see the volume. After running this command You are basically ready to put Your new HD into Zyxel. What is left is to loosly compare permissions being the same as the old HD ones by looking at few files/directories on both drives. ls -la will as well tell You if new HD consist of hidden directories/files and symlinks.

After this You may try to put Your HD into Zyxel NSA-210 and You should see volume of 3.64TB or similar size in case of 4TB drive. That is Your new data storage. If for some reason Zyxel appears unstable, like adding shares doesn't work or it can't shutdown, then reconnect it to Your linux box and run xfs_check or xfs_repair. Also I noticed that I needed to reboot NAS after adding a share, even though it already existed when I rechecked with my Linux box. So bigger HD may still have some problems with this old device, but it's yet up to test... Finally my 4TB Seagate 4000DM000 has nesting place to rest in. :)

So basically what we done was:
1. Created GPT on new HD (instead of MBR table as on old one),
2. Restored parition structure on new HD,
3. Resized data partition to cover whole free disk area,
4. Coppied all data from old HD to new HD including hidden files and permissions (or cloned it with clonezilla),
5. Recreated valid RAID-linear array for second partition,
6. Confirmed everything is ready to boot and run on Zyxel NSA-210.

I hope I helped. :)
~~~~
Mr_KrzYch00 ( http://www.4my.eu )

4 comments:

Unknown said...

Hello, I have 4TB Western Digital WD40EURX. It have Advanced Format (i.e. 4kB sector instead of 512B), so I used parted -a optimal /dev/sdb to have best aligment. I did all other steps like mkpart, mkfs, copy data from old HD with all hiden files, attributes and permissions, make RAID array (only diff from old HD is, that old HD has rounding 0K, but --create not alow that). After all this work I connect it to NSA210 and boot-up. System boot-up properly and when I look to administration page all looks to be OK, but in disk management array icon is red with status "down". May be problem advanced format or different size of rounding?
With Best Regards
Radim Protivansk√Ĺ

Mr_KrzYch00 said...

Well I can't really help You with that if You have other kind of 4TB HDD. You would need to redo all things to confirm that it still doesn't work after trying it step by step (clonezilla method and standard method). If it doesn't then You would need to try&error and discover something new maybe...

I can say that I have some issues with that 4TB HDD. It's not something big but sometimes it reports that I have disk full when I copy files to it and I can't even shut it down properly then - unplugging it from power is required. After next boot, however, it works properly again, and so on.

Unknown said...

Hello,
As you cab see, comment is from 2014/08, so problem is solved since 2014/09. Problem is bad order of steps You posted. You post steps in order Create (in my case) sdb1 for sysdisk, create sdb2, mkfs.xfs sdb2, mdadm create md1 from sdb2, transfer data to new disk, assembly NSA..., but in my case it must be create sdb1, sdb2, mdadm create md1 from sdb2, mkfs.xfs md0, transfer data to new disk, assembly NSA. That works perfectly.
And another tip, sysdisk (sdb1) could be aligned other than original sysdisk partition (LBA 63 to 1028159). In my case, it is LBA 128 to 1028159. GPT have limitation of start of first partition to LBA 48 (I thing). Proper alignement on AF disk could have, depending on HDD vendor, a major impact on write speed performance. Hope this will help to anyone.

Mr_KrzYch00 said...

You are right... Filesystem should be created on RAID volume (MD0). It's hard to remember if I actually missed that step or somehow got it to work other way around (like through zyxel control panel)...

About HDD speed. For me it has not much point. I'm using it on 100mbps ethernet connection. Even when I was using 1gbps there was not much speed increase due, to what I noticed, slow CPU.