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.

On my machine, fdisk -lu /dev/sda displays following output:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048    73947135    36972544   83  Linux
/dev/sda2        73949182    78139391     2095105    5  Extended
/dev/sda5        73949184    78139391     2095104   82  Linux swap / Solaris

What is this "blocks" unit? Is one "fdisk block" a 1KiB? Where does this unit come from?

share|improve this question

3 Answers 3

up vote 2 down vote accepted

You should know some concepts like sector, track, cylinder to understand block. Here is a simple definition:

Blocks and clusters

The Unix communities employ the term block to refer to a sector or group of
sectors. For example, the Linux fdisk utility normally displays partition
table information using 1024-byte blocks, but also uses the word sector to
help describe a disk's size in the phrase, 63 sectors per track.

You can read more in this link.

share|improve this answer

In the first versions of Unix, a block was 512 bytes all the way from the hardware through the filesystem through C code to user tools.

Nowadays there are many different types of hardware and many different filesystems (some of which don't have any notion of block size), so “block size” is an arbitrary definition chosen by each tool. Most traditional Unix systems have retained the 512-byte block size by default for backward compatibility, and this is what POSIX mandates for several commands (dd, du, df, ls, find -size, …). Several GNU/Linux utilities display 1kB units by default (du, df, ls, …) unless invoked in POSIXLY_CORRECT mode. I think the move to 1kB is solely motivated because it's a lot friendlier to humans.

The Linux fdisk utility uses 1kB blocks — the header might as well read kB. In expert mode, the unit is sectors of 512 bytes. 512 byte is a more natural low-level unit for traditional PC disks because they write in 512-byte sectors, and partition boundaries are aligned to 512 bytes, so using 1kB as the unit leads to ½ fractions. Modern large disks have larger sectors, and GPT partitions are normally aligned on 1MB.

share|improve this answer

I don't believe fdisk does do 1k block reports - or that it reports on blocks at all. From the man page:

-u, --units[=unit]

  • When listing partition tables, show sizes in sectors or in cylinders. The default is to show sizes in sectors. For backward compatibility, it is possible to use the option without the unit argument - then the default is used. Note that the optional unit argument cannot be separated from the -u option by a space, the correct form is for example -u=cylinders.

Ok, so fdisk doesn't list output as blocks, then. It uses cylinders or sectors by default. Well, here's what wikipedia has to say about a sector:

In computer disk storage, a sector is a subdivision of a track on a magnetic disk or optical disc. Each sector stores a fixed amount of user-accessible data, traditionally 512 bytes for hard disk drives (HDDs) and 2048 bytes for CD-ROMs and DVD-ROMs. Newer HDDs use 4096-byte (4 KiB) sectors, which are known as the Advanced Format (AF).

Now that makes more sense to me. I had never heard of a 1K sector before, and so stumbling upon this confused me. Some googling though did reveal that there was a small run of Seagate branded drives which shipped for a portion of the year 2005 that did report a sector size of 1K.

And anyway, it's right there in the header output:

Disk /dev/sda: 111.8 GiB, 120034123776 bytes, 234441648 sector
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: E12A6152-B1E6-4D4A-9799-491B339BA633

Device        Start       End   Sectors  Size Type
/dev/sda1      4096   6197247   6193152    3G EFI System
/dev/sda2   6293504  31459327  25165824   12G Linux filesystem
/dev/sda3  31459328 234441614 202982287 96.8G Linux filesystem

See? Units: sectors of 1 * 512 = 512 bytes...

share|improve this answer

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.