Jump to content
Micky1979

sectorsize v1.1 a tool to detect the physical and logical sector size of Hard disk (Advanced Format supported)

13 posts in this topic

Recommended Posts

sectorsize is a tiny command line I made to detect the Physical and logical sector size of your hard disk.

 

usage:

 
sudo sectorsize /dev/diskX
 
output on a AF (Advanced Formatted ) drive:
Physical sector size: 4096
Logical sector size: 512
output on non AF  drive:
Physical sector size: 512
Logical sector size: 512

OSX seem to show always 512-byte as "logical" sector size (*because is a standard?), but you can see that AF drive show a physical 4096-bytes sector, and probably this mean that this drive use the 512e tecnology (512 bytes emulation).

*NOTE: hard disk with 4K use firmware to emulate 512 sector size....as the OS wants..

 
This will be useful to see if your hard disk uses the Advanced Format technology or not.
 
Why?
Installing Chamelon (or Clover) currently can create the boot0 error on AF drives with physical 4096-bytes (or 4K).
This will be useful to understand what to do  before installing the bootloader on these drives.
A test will be performed by changing Chameleon installer to do all automatically.
stay tuned

 

Thanks to verdant for the tests made

 

Micky

sectorsize_v1.1_binary.zip

sectorsize_v1.1_source.zip

sectorsize_v1.2_scripting_easy.zip

Share this post


Link to post
Share on other sites
Advertisement

Nice little tool micky1979 :)

So maybe that DKIOCGETPHYSICALBLOCKSIZE is used to populate the 'Physical Block Size' value in Device Characteristics in ioreg?

ioreg -lw0 | grep "Device Characteristics"

Share this post


Link to post
Share on other sites

First I never look at this before  :hysterical:, but I think Yes, surely the ioreg is populated by sys/disk.h for extra details.

Diskarbitration framenwork (as I am using in Pandora show only Logical size or  I have to do something special that I did not understand), now I have more code to work on!

and DKIOCGETPHYSICALBLOCKSIZE seems a more direct and precise method, with just two lines of code and a clean output  :) ...(and the code can be use in a Cocoa app too)

EDIT

this because I want to use that in a bash script (or send this as argument from the app to the Chamelon/Clover scripts??), and I made variant of that command that exit in this way:

-------------------------------------------------------------------------------

USAGE:

sudo sectorsize /dev/diskX

 

This build is customized to be easily used with the bash/sh scripts ad return

the following output:

 

Physical XXX (if the Physical value is aqcuired..)

 

Logical XXX  (if the Physical value was not aquired for some reasons)

 

Standard 512 (if no Logical and nor Physical value was aquired for some reasons)

 

XXX can be 512 or 4096 (or any other aquired) as output in bytes.

 

sectorsize exit 0 on success for the cases above. 

-------------------------------------------------------------------------------

and use the result as argument for bs=n using dd.... only a test  to see if everything is ok. In the meantime, I gave an eye to an hard drive from an old laptop  I had(2 year), and surprisingly is a WD 512GB with 4K secotrs :lol:

Share this post


Link to post
Share on other sites

Great. Thanks.

 

EDIT:

One benefit of reading the property from ioreg is you don't need root privileges, where as accessing the disk directly does require root privileges. Of course, this won’t be a problem with the Chameleon installer or DarwinDumper as root privileges will have already been granted for those particular actions.

Share this post


Link to post
Share on other sites

Great. Thanks.

 

EDIT:

One benefit of reading the property from ioreg is you don't need root privileges, where as accessing the disk directly does require root privileges. Of course, this won’t be a problem with the Chameleon installer or DarwinDumper as root privileges will have already been granted for those particular actions.

Reading now your EDIT.

Yep require Root privileges, otherwise can't be used.....but now I can something like that easily (see at the red arrow):

ZeusWindow.png

 

I just finished editing Chamelon and Clover scripts to acquire the real sectors  size, and tomorrow I'll do a test on the drives that you see in the picture.
 

Fingers crossed  :geek:

Share this post


Link to post
Share on other sites

The first test:

Pandora's BOX post-install log




InsanelyMac 11/24/14-21:28
--
-- Zeus post-installation Session started --
-- Running from OSx 10.10.1
--------------------------------------------------------------------
** Enoch **
--------------------------------------------------------------------
===============================================
Main Standard Post-Install Script
Darwin/x86 boot v5.0.132 - Enoch (PANDORA) r2472
*********************************
-----------------------------------------------

Check if target folders exist:
/Volumes/Lion/usr/local/bin folders exist
/Volumes/Lion/usr/standalone/i386 folders exist

Clean up old installations files..
Cleaning done

Installing new boot files:
all the boot files have been copied successfully
Running Standard postinstall script
Target volume = /Volumes/Lion on /dev/disk1s2
Target disk already has existing Chameleon stage 0 loader - boot0md (boot0workV2).
Detected a Windows installation on this volume.
===============================================
CheckFatType: Do we have FAT16 or FAT32?
****************************************
Written boot0md to /dev/disk1.
Physical 4096bytes sector size detected for /dev/rdisk1s2
0+1 records in
0+1 records out
1024 bytes (1,0 kB) copied, 0,000288 s, 3,6 MB/s
Written boot1h to /dev/rdisk1s2.
Written boot to /Volumes/Lion on /dev/disk1s2.
Preparing to check target disk for previous installations.
Checking disk1.
Nothing found that could cause any problems.

Windows is installed so that can remain the active partition

/Volumes/Lion already has an Extra folder

Standard script complete

===============================================
END - Standard Post-Install Script
********************************* 

"Physical 4096bytes sector size detected for /dev/rdisk1s2"

 

Booted and Writing from that hard disk with 4K sector :lol: EDIT, w/o umonting the Volume..

...need to do a build...soon

Share this post


Link to post
Share on other sites

Obviously this will require tests .. hoping that this does not happen only to me, ha ha ha.

However, there can be two types of 4k drives, and both seem to have different alignments with OSes based on their firmware and the bus where they are connected apparently (yes, this makes difference)..

Share this post


Link to post
Share on other sites
On 11/25/2014 at 8:53 PM, Micky1979 said:

Obviously this will require tests .. hoping that this does not happen only to me, ha ha ha.

However, there can be two types of 4k drives, and both seem to have different alignments with OSes based on their firmware and the bus where they are connected apparently (yes, this makes difference)..

 

As long as you align your partitions on a multiple of 4KB, you're fine. You don't otherwise have to do anything special for drives with 4KB physical sectors.

essay typer

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By fasullo
      Ciao a tutti. Giusto per non farvi mancare la mia presenza  sono qui per chiedervi come si fa a far vedere l'HD (quello che uso come dati) come HD interno. Vorrei fare in modo che non si possa espellere.
       
      Grazie mille....
    • By William Parker
      Using Clover and trying to install El capitan from a USB flash drive prepared using the terminal command listed elsewhere. Boots up all the way to install screen and seriously pretends to install progress bar and all, while the HDD snoozes merrily. No drive activity LED at all. As the installer finished it reboots and I can see there's nothing on the drive. Several attempts, same results. Completely different hardware, same results. Different USB same results. Same thing happened a year back on Yosemite. I don't remember how I solved it. The one common thing is the El Capitan download from Apple. So friends any ideas and suggestions please.
    • By iLeopard_PC
      Ciao a tutti,
      sto cercando un software che mi permetta di dire quali partizioni/hard disk montare sulla scrivania all'avvio di Mountain Lion. Per l'esattezza ho una partizione di installazione di ML (chiamata "Mac OS X Base System") e la partizione creata da Windows 7 in fase di installazione ("System Reserved"); la prima delle due, oltretutto, ad ogni avvio del sistema si apre in automatico creandomi non pochi fastidi.
       
      Purtroppo da Finder non posso selezionare cosa montare poiché mi costringe a montare tutto.
       
      Un saluto,
      iLeopard_PC
    • By iLeopard_PC
      Ciao a tutti,
      ho un hackintosh con Mountain Lion, Lion e Windows 7. Cerco un software capace di ridimensionare le partizioni di Mountain Lion e di Lion (che si trovano sul medesimo hard disk).
      I software da me trovati non permettono tale operazione perché le due partizione di sistemi Mac sono in uso. Avete idee su come risolvere? :'(
    • By T_A_Z
      please help
      i face a proplem that installation can't see internal hard disk i double checked the sata mode is AHCI i installed IOATAfamily.kext all the same can't see my hard just the usb flash
      that happend before when installing lion but it has been fixed by following another guide to create bootable usb from my hack but now nothing even with myhack methode
       
      Dell Latitude E5500
      Core2 Duo
×