Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Most hard drive and partition inspection tools seem to list the items using sectors, head.. etc. From another question I was told that these are virtual because they have to be converted from lba, which causes conversion errors. Are there any unix tools that list a hard drive by logical blocks?

share|improve this question
    
What tools are you saying about? –  gelraen Dec 26 '11 at 15:11
    
like fdisk and gparted don't seem to have an option to display the number of blocks –  rubixibuc Dec 27 '11 at 1:55
    
fdisk and gpart (it's not gparted) on FreeBSD shows start sector in LBA and size in sectors for each partition –  gelraen Dec 27 '11 at 8:02
    
I think it does say the sectors, but I was told these are virtual, I wanted to be able to find the logical block. My /boot partition (using master boot record partition scheme), didn't seem to be right. It said it started at sector 2048. The start is sector number right (in fdisk)? I thought it would start at sector 1 or 2 (are they zero indexed)? Since the mbr would only take up the first sector. Also it says blocks, why would it measure using a mix of lba and sectors? Sorry if this sounds stupid. –  rubixibuc Dec 27 '11 at 8:54
    
Usually "block" means same as "sector". Why do you think that /boot partition cannot start at sector 2048? MBR handles free space between partitions just fine. –  gelraen Dec 27 '11 at 14:39

1 Answer 1

up vote 4 down vote accepted

CHS (Cylinder/Head/Sector) was used in the past for this. CHS addresses did (originally) map to actual, physical locations on disk platters.

However, as drives modernized, this C/H/S division stopped making sense. The fixed number of sector per cylinder is not practical at all (cylinders closer to the outer edge of the disk can store more data than those closer to the inner edge), so a different system was needed.

LBA (Logical block addressing) is what is used on (probably all) modern drives. The drive is logically divided into blocks (512 byte or 4k byte sectors mostly), the first block is block 0, the next one block 1, etc.
How the actual physical drive maps those logical sectors to physical areas of its platters is up to the drive. So in this sense, it is a "virtual" address. But it is also perfectly accurate.

  • If you have a drive that does use CHS (unlikely), something will have to convert LBA address to CHS, and if the drive geometry information somewhere is wrong, you'll get inaccuracies.
  • If you have a modern drive, attempts to use CHS will also lead to problems, since a conversion needs to be done, and CHS doesn't map well with modern drives.

What fdisk lists by default is "LBA", using 512 byte sectors (possibly 4k sectors on drives that have that - I don't have one to check). It does list heads/sectors/tracks/cylinder as information but that is the "virtual" measure these days.

cfdisk can print the partition table with C/H/S start/end values if you really want that (use the Print then Table then enter twice).

share|improve this answer
    
I must be both ignorant and an old fart. What sort of drive uses 4,096 byte sectors? –  Alexios Mar 4 '12 at 21:49
2  
Some "newer" ones. (Here's an article with some info.) It is/was actually quite problematic for a lot of stuff (here for some info on Linux), and 512 byte sector emulation has caused serious performance niceties (and data integrity concerns for RAID setups to boot). –  Mat Mar 4 '12 at 21:56
    
I see — so it's still transparent. It makes perfect sense to enlarge sector sizes on the medium itself (and hide this from the host to a certain extent), and I mostly assumed it was done behind the scenes anyway. Thanks for the info! (though I noticed some info on the sites was a little inaccurate. Caveat emptor) –  Alexios Mar 4 '12 at 22:04
    
That's just the first links I pulled from google, no proof-reading ;) It's "transparent" as long as the OS and partitioning tools deal with it properly. –  Mat Mar 4 '12 at 22:06
    
Yeah, I gathered that. Partitions/volumes/slices/quanta have to be 4k-sector-aligned. That's true of any block-access medium when you want to store items smaller than the block size. Anyway, it's interesting that my favourite disk already uses 4k sectors. I'm going to have to power up the machine in the next few days and see what the kernel and hdparm have to say about it. –  Alexios Mar 4 '12 at 22:41

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.