diskpart clean zeros LBA 0 to LBA 2047

Page 1 of 4 123 ... LastLast

  1. Posts : 7,055
    Windows 7 Home Premium 32 bit
       #1

    diskpart clean zeros LBA 0 to LBA 2047


    During the course of this thread Recover data from a diskpart > clean command it became evident that the first NTFS (also known as Partition Boot Record / Volume Boot Record) in a HDD can be at LBA 63 (Absolute Sector 63) or LBA 2048 (Absolute Sector 2048) depending upon the partitioning utility used. This is actually the starting sector of the first partition.

    Partition Wizard run from a bootable pendrive formatted a 750GB Seagate GoFlex external HDD with the first NTFS at LBA 63.

    diskpart clean zeros LBA 0 to LBA 2047-ntfs63pwbootcd.jpg

    Windows Disk Management formatted the same drive with the first NTFS at LBA 2048.

    diskpart clean zeros LBA 0 to LBA 2047-ntfs2048wdm.jpg

    In both cases it was found that the diskpart clean command zeroed LBA 0 to LBA 2047.

    This should remove the common misconception that the diskpart clean zeros only the MBR at LBA 0.

    Even I believed it to be so thus far till a debate/discussion between me and Anshad Edavana in that thread brought this revelation.
      My Computer


  2. Posts : 562
    Windows 7 Ultimate x64
       #2

    I did one more DISKPART experiment with a XP partitioned disk ( partition start at LBA 63 ). Regardless of the starting position of first partition at LBA 63, DISKPART zeroed the first 1 MB and last 1 MB. It looks like this behavior is hard coded in "Windows 7" version of DISKPART ( Probably in 8 too ). It make sense because DISKPART doesn't have to bother about whether the disk is partitioned in MBR or GPT scheme by wiping out first and last one MB.

    Official Microsoft documentation ( DiskPart Command-Line Options ) start by these words:

    DiskPart is a text-mode command interpreter in Windows Vista, Windows® XP, and the Windows Server 2003® family
    It means the documentation was probably updated lastly on 2006. Even at the time of Vista, GPT was not popular and large capacity drives are very rare. Anyway since both Vista and XP are obsolete, there won't be any practical benefit in examining how legacy version of DISKPART works.
      My Computer


  3. Posts : 25,847
    Windows 10 Pro. 64/ version 1709 Windows 7 Pro/64
       #3

    Keep in mind; both of you are many pay grades above me in such matters.

    I don't know what the charts mean and never will.
    I'm trying to understand what is trying to be proved and why.
    I have followed the other thread for days trying to learn something but I'm still lost. Could you explain it better with less teckie?

    What would a dummy like me do with this information?
    Where would it come in handy for a dummy like me?
      My Computer

  4.    #4

    For some years here we've used Diskpart Clean command heavily to overcome more than half of installation failures as well as occasionally when a drive is traced as blocking boot. I assumed it was because interfering boot code was neutralized along with possibly the partition table.

    Does this prove or disprove that theory, or shed any more light on exactly why Clean command works for these purposes?

    Nice work.
      My Computer


  5. Posts : 562
    Windows 7 Ultimate x64
       #5


    I don't know what the charts mean and never will.
    I'm trying to understand what is trying to be proved and why.
    I have followed the other thread for days trying to learn something but I'm still lost. Could you explain it better with less teckie?
    Typically a hard drive's sector is 512 bytes sized. As you know, sector 0 is reserved for MBR and all legacy operating systems like XP, DOS etc creates first partition at sector 63. There will be a 62 sector gap between the MBR and partition one. Windows usually considers this as "hidden sectors" but Linux may use these sectors to store parts of GRUB.

    The default behavior of creating first partition at sector 63 is changed with the release of "Vista". By default, Vista and higher operating systems only creates partitions starting from sector 2048. The reason for this is to maintain compatibility with modern "Advanced Format Disks" and Solid state disks. All partitions created under Vista/7/8 using either installer, Dikpart or Disk Management will always start on a number divisible by 8.

    If we issue DIKPART CLEAN command from "Windows 7" or it's install disc, first 1 MB ( LBA 0 to 2047 ) and last 1 MB seems to be filled with zeros. Sector 2048 and onward won't be wiped unless we use DISKPART CLEAN ALL command. When we scan for lost partitions with "Partition Wizard" or "TestDisk", both will search for NTFS boot sectors starting from sector zero and probably will find the first partition's boot sector on LBA 2048 and parse partition information by reading it. Then this info is used to create a new partition table entry.

    On the other hand if we issue DISKPART CLEAN command against a disk which is partitioned by legacy partitioning tools ( XP setup, Partition Wizard Bootable CD etc ), NTFS boot sector which starts at sector 63 will be zeroed as part of first 1 MB wipe. So the chances of successfully recovering the partition will be marginally low. In my test, "TestDisk" was able to find the partition by locating the backup copy of boot sector but it took a long time to do that.

    For whatever reason a deep scan with neither "TestDisk" nor "Partition Wizard" failed to find the lost partition in OP's external HDD. This may happen if both primary and backup "Boot Sectors" are damaged.
      My Computer


  6. Posts : 7,055
    Windows 7 Home Premium 32 bit
    Thread Starter
       #6

    Layback Bear said:
    ...... What would a dummy like me do with this information?
    Where would it come in handy for a dummy like me?
    The message is loud and clear. Do what a dummy like me does.:)

    Know your HDD.

    By that I mean check each and every HDD you have. Know whether the start LBA of your partition is LBA 63 or LBA 2048. Make a note of it.

    If it is LBA63, don't run diskpart clean on it under any circumstances - even if recommended by a Microsoft Certified Professional.



    gregrocker said:
    For some years here we've used Diskpart Clean command heavily to overcome more than half of installation failures as well as occasionally when a drive is traced as blocking boot. I assumed it was because interfering boot code was neutralized along with possibly the partition table.

    Does this prove or disprove that theory, or shed any more light on exactly why Clean command works for these purposes?

    Nice work.
    If one suspects boot sector related problems or Windows booting related problems :

    If it is an already existing HDD with a single volume or multiple volumes, it shall be prudent to examine the start sector of the first volume ( this I would presume can be done in many ways. Even by running a partitioning utility from a boot device. The properties of the volume may show the start sector) and recommend diskpart clean only if the start sector is LBA 2048. If it is LBA 63 it is a no no as it will zero it and make the disk inaccessible. This may perhaps increase the success rate from the present estimate you had indicated by eliminating one cause of failure of recommended action.

    In the case of start sector LBA 2048 drives - Many alien OS like Linux may write data in Sector 64 to 2047 and any dirty data left behind may be a potential source of Windows booting related problems. So wiping it with diskpart clean may be advantageous. (E & O.E. - Errors and Omissions Excepted. )

    We already seem to have another problem of this kind here where another forum had recommended diskpart clean. DISKPART clean performed accidently. how to recover data? I am just closing my eyes. I need sometime off. I can afford to now that Anshad is here to battle.:)
      My Computer

  7.    #7

    How will running Clean command make a disk inaccessible? I've never seen this. It appears from your discussion it would make the data irretrievable by undelete but that is not what we're attempting to do in installation troubleshooting where we only need the MBR boot code and Partition Table zeroed.

    Are you saying that to Clean a disk with LBA 63 would make the disk inaccessible to use at all? I've never heard of that.
      My Computer


  8. Posts : 562
    Windows 7 Ultimate x64
       #8

    Are you saying that to Clean a disk with LBA 63 would make the disk inaccessible to use at all? I've never heard of that.
    Possibility for a successful recovery depends on more than one factor - especially the presence of a valid backup boot sector and the contents of LBA 64 to 2047. These sectors will be part of NTFS (if partition start at sector 63 ) and may or may not used to store critical file system structure data.

    In my test, i was able to successfully recover the partition since backup boot sector was not destroyed. However Windows refused to recognize the NTFS due to the wiped out sectors inside the file system ( LBA 64 to 2047 ). Fortunately running CHKDSK was able to successfully repair the damage and all files were in tact.

    But the backup boot sector may also be destroyed if it is stored at the very end of the disk. In that case partition recovery will be very difficult if not impossible.
      My Computer


  9. Posts : 7,055
    Windows 7 Home Premium 32 bit
    Thread Starter
       #9

    Greg, it is simple to carryout this experiment.

    What all you need is one external HDD and bootable pendrive with Partition Wizard.

    Format the drive with Partition Wizard running from the pendrive.

    The first partition will start at LBA 63.

    Now put some data in the external HDD.

    Check that what all you have put is inside the HDD.

    Run diskpart clean.

    When it completes , see what happens.

    Check whether you can access the data. You will not be able to - because LBA 63 where the NTFS VBR is there has been zeroed and Partition Wizard cannot identify that it is the beginning of a partition, to be able to rewrite it into the first sector. So undelete not possible.

    I had performed this experiment and speak. If you want to contest you are welcome. Please do it and check for yourself.

    This is exactly what happened in this thread Recover data from a diskpart > clean command Here it is a data drive.

    This is exactly what has happened in this thread DISKPART clean performed accidently. how to recover data? Here it is OP's system disk.

    I see you have recommended Partition Wizard. Let us see the result.

    Whether it is possible to retrieve the data: That is what we are trying to in the first thread.

    To my mind, data retrieval may be possible by trying PhotoRec since photoRec does not require a file system present.Anshad is trying his best to reconstruct the boot record on LBA63.We have to see whether his attempt succeeds.

    Whatever, undelete by PW just not possible.
    Last edited by jumanji; 26 Jun 2014 at 13:28.
      My Computer

  10.    #10

    I only asked if these findings reveal any more about why Clean command works for Win7 installation failures. I am not contesting anything about partition recovery, but am trying to understand better how exactly Clean command works to resolve installation failures.

    I think Kaktussoft answered it in another thread:

    Kaktussoft said:
    gregrocker said:
    Would you want to theorize why Clean command works to overcome about half or more of all installation failures? I assume it's because it wipes boot sector and the partition table, one or both of which interferes with attempts to install Win7.

    Likewise on multiple occasions we've had drives which failed to boot that traced to a hard drive where the solution was to wipe the drive with Clean command.
    After the diskpart->clean command the MBR, so master bootcode and partition table, is zeroed. Both are in sector 0. So "logically" the disk is totally empty. It doesn't have boot code and no partitions at all afterwards.
    Do you concur?
      My Computer


 
Page 1 of 4 123 ... LastLast

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 22:00.
Find Us