1

Cloning is very convenient if multiple identical systems need to be created. But I have the following concern. As far as I know during formatting of file system and even during it's use a bad disk sector can be marked as "bad" by the file system. Cloning tools (like dd and similar) do not check for sector quality and copy all sectors identically as on source medium. Please, correct me if I am wrong in any of these assumptions.

So my questions are:

  1. Is there a risk that on target medium there are bad sectors that during cloning will not be marked as "bad" and will result in corrupted or unstable system?

  2. If such risk exists, how big is it for HDD, SDD, SD Card ?

  3. Finally, considering everything when cloning can be considered a good practice?

If the answers are well known, please direct me to the right sources of information because I am not able to find satisfactory answer on Serverfault or Google. Thanks.

Linas
  • 19
  • 2
  • 1
    The only things I still clone are virtual guests and even for those a template and/or orchestration system is preferred to an exact copy which then needs to be "fixed" (e.g. to set a correct hostname, license key, a new MAC address etc.) – HBruijn Aug 06 '14 at 07:28
  • Let others work on the answer and then get away is a bad thing, so you got a downvote here. – peterh Aug 08 '14 at 13:02

2 Answers2

0

In most cases, production drives doesn't contain bad blocks, because they are thrown out on the first such event. It has a logical reason: compare the mean cost of a hard drive to the mean wage of a professional system administrator. And you didn't even calculated the worth of the data which this disk contains.

But if we see the hyphotetic situation, that drives with bad blocks can remain in their professional business server environment, there are also possibilities to handle these cases.

Normally, there is only a few bad block on a hard disk compared to the number of the blocks without any problems.

There are tools which are capable to clone disk images handling the read errors caused by bad sectors. A very good example is the tool ddrescue on the unix world.

The risk of a bad block event while a clone exists. In my professional carrier it happened 2 times in 15 years. The risk exists, but it is low. You need to have always backup from everything!

Cloning is normally a good thing, although I clone mostly not through a block-level copy, but simply a reformatting and file-level copy. (mke2fs, and then cp -vfa or tar -cvf - mountpoint/|nc targetserver). This handles bad blocks, and moves only the used blocks. There is no need for the empty blocks to be also copied, for ssd systems it is even a very bad behavior, because it could cause the empty-signed ssd blocks to be overwritten with zeros.

peterh
  • 4,953
  • 13
  • 30
  • 44
0

Modern disks have remapping of bad sectors build into the logic on the drive itself. This means that the feature in file systems to mark bad sectors is a relic from the past which no longer serves a purpose.

This doesn't mean you'll never see read errors due to bad blocks. Trying to read from a bad block, which has not been remapped yet will give a read error. Remapping cannot be done until the data has been successfully read or has been overwritten. Thus bad sectors on the target drive should become good again (remapped) once you write the image to the drive.

And the number of blocks marked bad on the source drive will usually be zero or at least too small to worry about.

For those reasons I do not consider bad blocks to be a concern you need to consider when cloning disks.

Other more important concerns are the following: - Is the target disk large enough? Even media which according to official specs are the same size may internally be different revisions and due to that have slightly different sizes. - Could any piece of software get confused from the fact that two different file systems have the same ID?

You can avoid size related problems by leaving a bit of space unallocated at the end of the media. And the identical file system IDs only become a problem if you are later going to be using two clones in the same machine.

kasperd
  • 30,455
  • 17
  • 76
  • 124