Jump to content











Photo
- - - - -

Extents

file copy in use

  • Please log in to reply
82 replies to this topic

#76 noel

noel

    Frequent Member

  • Advanced user
  • 111 posts
  • Location:nantes
  •  
    France

Posted 04 May 2019 - 01:09 PM

Hello,

I'm sure there is no impact with extents because unity is "clsuter", not sector. But i can be wrong.

 

For LBA,  unity is sector.

So, for LBA in MBR style with disk 4K 512e, i think that the "firmware/controler" inside the disk make the conversion from "normal" sector size(not physical sector size but which name to call the "normal" sector size, "logical size" perhaps). I think, not verify.

For LBA in MBR with disk 4Kn, so big new disk, not usb key, i think no problem because normal and physical sizes are identical.

In GPT disk, i think that the calculation must take care of the "protective MBR sector" if the disk is initialized by a MS program. And also struct is different, so calculation is complex ( i put links to ms info in a previous post).

 

All above is for basic disk.

For dynamic disk, i think that some extents can be on a physical disk 1 and some others extents can be on an other physical disk 2. But i'm not sure. It's only that i understand when i read MS informations.

 

I hope you can give more good, better, verified informations.

 

Ps : i know easy2boot doesn't need to play with these details ( Basic or not, 4K 512n, 4Kn, GPT/MBR ). And i will dead before a USB key comes with GPT and 4Kn !



#77 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 2665 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 01:16 PM

And to add some more complexity (because we just love it), if you apply wofcompress (see here), then the extents concept does not apply anymore :)

See below after applying wofcompress to f:\data0.vmdk:

>fsutil file queryextents f:\data0.vmdk
VCN : 0x0        Clusters : 0x650      LCN : 0xffffffffffffffff 

But lets keep that one for later as this is deviating from the main topic.

 

I am going to create various virtual disks : 512/512, 512/4096, 4096/4096 in MBR or GPT mode and see how some software (mainly mines... :) ) behave.

 

Being a dirty dev myself, I would not be surprised to find some code out there with a ugly 512 value hardcoded which in some situations may lead to at best wierd results, at worse catastrophic failures.

 

Thanks for bringing this (4k disk) to my attention : i have always dealt with (old) 512 sector size disks but cannot ignore different sector sizes. 



#78 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 2665 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 02:53 PM

Version 1.4 out.

 

sector size = 4096 was not handled properly.

 

Adding all extents sector count and multiplying by the sector size was not matching the filesize in bytes.

 

Thanks goes to Noel to spot this out ! :)

 

Before

>extents-win64.exe f:\test.dmp
extents 1.3 by erwan2212@gmail.com
***************************
Bytes Per Sector:4096
Sectors per Cluster:1
Cluster size :4096
Filesystem :NTFS
***************************
Filename:f:\test.dmp
File Cluster count :36938 (151298048 bytes)
File size in bytes :151298048
File cluster first :29920
Extents count :2

extents_[0] -  VCN : 0 LCN : 29920 Lba : 30176 Sectors : 282864
extents_[1] -  VCN : 35358 LCN : 1343 Lba : 1599 Sectors : 12640

After

>extents-win64.exe f:\test.dmp
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:4096
Sectors per Cluster:1
Cluster size :4096
Filesystem :NTFS
***************************
Filename:f:\test.dmp
File Cluster count :36938 (151298048 bytes)
File size in bytes :151298048
File cluster first :29920
Extents count :2

extents_[0] -  VCN : 0 LCN : 29920 Lba : 30176 Sectors : 35358
extents_[1] -  VCN : 35358 LCN : 1343 Lba : 34595 Sectors : 1580


#79 noel

noel

    Frequent Member

  • Advanced user
  • 111 posts
  • Location:nantes
  •  
    France

Posted 04 May 2019 - 04:16 PM

Hi,

your disk containing the target file is it MBR or GPT?

If GPT, i think LBA is wrong ( if i understand correctly MS documentation ).

But i cut my hair by 4 !



#80 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 2665 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 04:38 PM

But i cut my hair by 4 !

 

You are not going to have much hair left if you keep doing that :)

I know I would not !

 

Will look at MBR vs GPT now (now that the 512/4096 is sorted out).



#81 erwan.l

erwan.l

    Platinum Member

  • Developer
  • 2665 posts
  • Location:Nantes - France
  •  
    France

Posted 04 May 2019 - 05:39 PM

If GPT, i think LBA is wrong ( if i understand correctly MS documentation ).

 

Tried on a GPT disk.

LBA looks ok to me: I editer the underlying disk with HxD, reached offset LBA*512 and could witness my file was there.

>extents-win64.exe f:\test.dmp
extents 1.4 by erwan2212@gmail.com
***************************
Bytes Per Sector:512
Sectors per Cluster:8
Cluster size :4096
Filesystem :NTFS
***************************
Filename:f:\test.dmp
File Cluster count :36938 (151298048 bytes)
File size in bytes :151298048
File cluster first :39543
Extents count :1

extents_[0] -  VCN : 0 LCN : 39543 Lba : 316472 Sectors : 295504


#82 noel

noel

    Frequent Member

  • Advanced user
  • 111 posts
  • Location:nantes
  •  
    France

Posted 04 May 2019 - 09:41 PM

Hi,

I understand my mistake : your LBA is allways good/right because you use the  IOCTL_VOLUME_LOGICAL_TO_PHYSICAL API (and don't calculate it manually). Thank you for the code.

I miss this information in the posts.

So, no problem with GPT disk and LBA got from API.

Bravo !



#83 Wonko the Sane

Wonko the Sane

    The Finder

  • Advanced user
  • 14778 posts
  • Location:The Outside of the Asylum (gate is closed)
  •  
    Italy

Posted 06 May 2019 - 11:34 AM

LBA is a way to measure an absolute offset from the first sector (Sector LBA 0) and it is ABSOLUTELY THE SAME in both MBR and GPT, API, manually or otherwise.

 

When you read (say) LBA 5874, it means that there are 5874 sectors before it, this is true as well in a non-initialized or not partitioned device.

 

:duff:

Wonko






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users