How to prepare a Hard Disk whilst installed in a Synology NAS

From SynologyWiki
Revision as of 15:50, 31 August 2012 by HarryPotter (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Note: As of firmware 0942 you are given the option to do a full surface scan when you format a drive/volume. Hence for fw 0942 and above you wont need this wiki to prepare a hard disk, but you may want to use it to erase/scrub an existing disk.

This page aims to give step by step instructions on how to prepare a hard disk (new or otherwise) for use in your Synology NAS. It is recomended that if you are able to use the How to prepare your hard disks procedures given under General Contents you should. This procedure is only for those who have no other way of preparing their SATA disk, i.e. do not have a PC with a SATA interface (e.g. laptop users) and do not have a USB external enclosure with a SATA interface.

Contents

What is Hard Disk preperation

Please see the How to prepare your hard disks page for this information.

Limitations if your NAS only has one disk installed

If you only have one Hard disk in your NAS and that disk is the one you want to prepare you will not be able to use the exact procedure described below. However you will be able to prepare most of the disk, partition by partition.

The operating system resides on partition1 (/dev/sda1 for multibay NASs and /dev/hda1 for single bay NASs) of disk1 (/dev/sda or /dev/hda). As the procedure below wipes the whole disk (hence all partitions on the disk) the precedure will fail after wiping the file (/dev/zero) on partion1 (/dev/sda1 or /dev/hda1).

Therefore instead of preparing the whole disk at once (/dev/sda or /dev/hda) you should turn off memory swapping using the command "swapoff -a" and then prepare partition3 (/dev/sda3 or /dev/hda3) then partition2 (/dev/sda2 or /dev/hda2) and then partition1 (/dev/sda1 or /dev/hda1). This procedure will prepare 100% of partition3 and partition2 but it will not do all of partition1 as it will fail after wiping the file /dev/zero. The NAS will freeze part way through partition1, you need to turn off and (30secs latter) turn on the power supply to reboot the NAS, and then use Synology Assistant to reload the firmware.

Are you aware of the consequences if this routine is not executed correctly?

This routine will wipe all and any information on the target disk. The main command used to do it is the dd command. This command also has the nick name of "data destroyer" because simple mistakes can lead to large consequences. For instance if you have more than one drive in your NAS it only requires one letter difference (e.g. a "b" instead of "a") and you could irreversibly wipe a drive you didn't want to. Hence be very carefull.

How long will it take to prepare the Disk

To start the process (which requires your time) takes about 15 minutes. However once the process is started the NAS is out of action untill it finishes the process, and that can be a long time. How long depends on the hardware (NAS and disk size). Below is a table showing how long it took those who have used this procedure (add yours if you do it).

NAS Model Firmware Disk Size Disk Make Disk Model How long it took Reported By YYYY.MM
CS-407 590 500Gb WD WD5000AAKS 2.5 hours RobinGB 2008.04
CS-407 590 1TB Samsung HD103UJ 3.5 hours RobinGB 2008.04
CS-407 2.2-0942 2TB WD WD20EADS 9.5 hours Ihse 2009.09
DS-207+ 590 500Gb WD WD5000AAKS 2.5 hours RobinGB 2008.04

Don't wait forever

Once the disk preparation has started the HD light on your NAS will flash continuosly untill the process finishes or is prematurely terminated. If the HD light has stopped flashing for more than 5 seconds but dd has not reported "No space left on device" then the procedure did not complete fully. You will need to restart the process. If your network connection to your NAS is not stable, you should load GNU screen on to your NAS and then run the process from within screen.

Pre Installation

The following is assumed;

  • You have a Synology NAS
  • You have the latest version of synology assistant installed
  • You know how to login to the Management page of your NAS as "admin"
  • You have 15 minutes spare to start the disk preperation process
  • You are happy for your NAS to be busy preparing the disk for up to 10 hours depending on your NAS model and the Hard Disk size.
  • You are able to leave the Command Line Interface session open till the end of the process, i.e. your PC will need to be on till the end, unless you have GNU coreutils > nohup or GNU screen installed on the NAS.
  • If you have GNU coreutils installed consider using the shred command as discussed on this articles discussion page as it gives a progress indication

Which procedure is for you

The set-ups this Wiki covers are;

  • Proc1 - A multibay NAS which is already working with atleast disk1 in it. In this instance you are going to add another disk to the NAS and prepare the added disk.
  • Proc2 - Preparing Disk1 which is in "Basic" or "RAID 0" mode of a working multidisk NAS (i.e. you have atleast disk2 installed and working)
  • Proc3 - Preparing A Disk (Disk1, Disk2, Disk3, Disk4) of a working RAID1 or RAID5 volume

Proc1 - Preparing a Disk in a working multibay NAS

Overview: In this procedure we are going to install a disk (other than Disk1) in a working multibay NAS, enter the Command Line Interface, check the added drive is recognised, and then write zeros all over it. After this you can then use your NAS's Management page to add the Disk to your NAS as normal.

  1. Shutdown the NAS, open the case, install the drive(s), turn on the NAS
  2. When the NAS has finished booting up Login into the Command Line Interface as "root", password is the same as the admin password.
  3. Now we are going to prepare the disk by writing 0 all over it ***This will irreversibly erase everything on the disk***. Which disk do you want to prepare?. In the next stage we will enter a command something like (DONT ENTER IT YET) "dd if=/dev/zero of=/dev/sdb bs=1M conv=noerror" where the "b" in "of=/dev/sdb" means the action is on Disk2, Disk3 is "c", Disk4 is "d" etc. Hence if you wanted to carry out this command on Disk3 you would use the command "dd if=/dev/zero of=/dev/sdc bs=1M conv=noerror". Now enter the correct command for the disk you want to prepare (dont get it wrong). This command can take a very long time to complete. Unfortuneately the dd command gives no progress indication. You must leave the Command Line Interface session open till the end else you will terminate the process. When the process is finished dd will report "No space left on device".
  4. When it has finished, if you have more disks to prepare enter the next relevant dd comand as described above.
  5. When you have finished preparing all your disks close the Command Line Interface
  6. Log in to the NAS's Management Page and add the disk(s) to your NAS's volume using the Synology tool found under Storage>Volume.

See the section below on recomended post-preparation action

Proc2 - Preparing Disk1 which is in "Basic" or "RAID 0" mode of a working multidisk NAS

Overview: This is intended for those who did not prepare Disk1 before using it in a Basic or RAID 0 volume but subsequently want to do so. For this procedure to work you must have installed and commissioned a second disk in the NAS, it doesn't matter what mode the second disk is in, but you must have added it to the NAS through the Web Management GUI, else this procedure will fail and you will need to reinstall the firmware.

In this procedure you are going to backup the NAS's configuration, backup your data, unmount volume1 and prepare Disk1. Note: ***This procedure will erase all data on Disk1 and therefore you will need to have a backup of your data.

  1. Login to the NAS's Management web GUI and Backup the NAS's configuration file to a safe place on your PC.
  2. Goto the shared folders tab in the Management web GUI and make a note of all the shared folders in volume1. You will need to recreate all of the shared folders after this process, including the system folders such as music, video, web, NetBackup etc.
  3. Backup any of your data in the shared folders of volume1 that you will want to restore after this process.
  4. Login into the Command Line Interface as "root", password is the same as the admin password.
  5. Stop all services running on the NAS and then unmount the raid volume by entering the following commands, "/usr/syno/etc/rc.d/S25download.sh stop", "/usr/syno/etc/rc.d/S20pgsql.sh stop", "/usr/syno/etc/rc.d/S80Samba.sh stop" and "umount /volume1"
  6. Now we are going to prepare Disk1 by writing 0 all over it ***This will erase everything on the disk, you will need a backup of your data! The preparation of Disk1 is a two stage process, unlike the process for other Disks. This is because by default the synology NAS uses partition1 of disk1 (/dev/sda1) for its OS files. The synology NAS's always mirrors partition1 of disk1 to partiton1 of all disks in the NAS, even if the disk(s) is set to Basic or RAID 0. When you delete partition1 of disk 1 the NAS will hang/freeze. You will need to reboot it (at which point the NAS will go to using the OS files in partition1 of the next good disk. Hence, to prepare Disk1 enter the command "dd if=/dev/zero of=/dev/sda bs=1M conv=noerror". After about 1-2 hours the NAS will hang/freeze (see the section Don't Wait Forever).
  7. Reboot the NAS by turning off the power supply, waiting 30seconds and then reconecting power.
  8. Log in to the web management GUI and turn off the beeps (under the "Storage>Volume" tab) and then restart the process above, i.e. stop services, enter dd command for Disk1 again. This time it will complete. The dd command can take a very long time to complete. Unfortuneately the dd command gives no progress indication. You must leave the Command Line Interface session open till the end else you will terminate the process. When the process is finished dd will report "No space left on device".
  9. When it has finished you need to get the NAS to recognise the blanked disk so it can be reformatted. To do so reboot the NAS, i.e. enter the command "reboot".
  10. When the NAS has finished booting up it will start beeping again indicating it has detected a loss of data on disk1. Log into the Management web GUI page of the NAS and goto Storage>Volume and recommission disk1.
  11. When the repair process has finished you will need to recreate all shared folders in volume1 using the Web Management GUI (do not use the command line interface).
  12. Restore the backed up configuration file. This will restore users and groups access rights to the shared folders
  13. Restore your backed up data to the shared folders

See the section below on recomended post-preparation action

Proc3 - Preparing A Disk which is already part of a RAID 1 or RAID 5 volume

Overview: This is intended for those who did not prepare their disks before using them in a RAID 1 or 5 volume but subsequently want to do so. In this procedure you are going to unmount the raid volume, prepare one of the disks (NOTE this effectively degrades the RAID volume as though that disk had failed!), remount the volume, repair the volume and then repeat the process for the other disks in the RAID volume (if required).

  1. Login into the Command Line Interface as "root", password is the same as the admin password.
  2. Stop all services running on the NAS and then unmount the raid volume by entering the following commands, "/usr/syno/etc/rc.d/S25download.sh stop", "/usr/syno/etc/rc.d/S20pgsql.sh stop", "/usr/syno/etc/rc.d/S80Samba.sh stop" and "umount /volume1"
  3. Now we are going to prepare the first disk of the raid volume (Disk1) by writing 0 all over it ***This will irreversibly erase everything on the disk and leave your RAID volume in a de-graded status i.e. a further disk/data loss would result in loss of your data! However as you have stopped all other processes accessing the raid volume it is very unlikely. The preparation of Disk1 is a two stage process, unlike the process for other disks. This is because by default the synology NAS uses partition1 of disk1 (/dev/sda1) for its OS files, and although these are mirrored to partition 1 of the other disks, when you delete partition1 of disk 1 the NAS will hang/freeze. You will need to reboot it (at which point the NAS will go to using the OS files in partition1 of the next good disk. Hence, to prepare disk1 enter the command "dd if=/dev/zero of=/dev/sda bs=1M conv=noerror". After about 15minutes the NAS will hang/freeze (see the section Don't Wait Forever). Reboot the NAS, log in to the web management GUI and turn off the beeps (under the "Diskmanagement>volume" tab) and then restart the process above (stop services, enter dd command) for disk1 again. This time it will complete. The dd command can take a very long time to complete. Unfortuneately the dd command gives no progress indication. You must leave the Command Line Interface session open till the end else you will terminate the process. When the process is finished dd will report "No space left on device".
  4. When it has finished you need to get the NAS to recognise the degraded RAID volume so it can be repaired before you do another disk (else you will loose your data) by rebooting the NAS, enter the command "reboot".
  5. when the NAS has finished booting up it will start beeping indicating it has detected a loss of data on the disk you have just prepared. Log into the Management web page of the NAS goto Storage>Volume and repair the volume.
  6. When the repair process has finished repeat the steps above, i.e. stop the process, unmount volume1, use the dd comand on the next disk to be prepared e.g. for Disk2 enter "dd if=/dev/zero of=/dev/sdb bs=1M conv=noerror". Note the "b" in "of=/ev/sdb" means the action is on Disk2, "c" would be Disk3, "d" would be Disk4 etc. DO NOT get carried away, remember to repair the volume after preparing each disk ELSE YOU WILL LOOSE YOUR DATA.
  7. When you have finished preparing all your disks and rebooted and repaired the volume for the last time, you should have a more stable volume1.

See the section below on recomended post-preparation action

Recomended post-preparation action

If the drive you were preparing supports S.M.A.R.T. (most modern drives do) install and run smartmontools to find out how many bad sectors are on the drive. See smartmontools in A short list of the more useful 900+ ipkg packages

Personal tools
Community Resources