I have a sample emmc block info from an android device

From /proc/partitions

major minor  #blocks  name
 179    1    5120    mmcblk0p1

Using my little intelligence I am assuming /proc/partitions uses blocks since it says partition 1 has 5120 blocks

From /sys/dev/block/179:0/mmcblk0p1/size


It is seeming the partition values in /sys/…/size are double the values of /proc/partitions. Hence why are they different hence what the units in both of them?


/proc/partitions shows the size in 1024-byte blocks.

/sys/dev/block/*/*/size shows the size in 512-byte sectors.

Both irrespective of the logical/physical block/sector size of the device.

For the 1st, you can look in the proc(5) manpage:


Contains the major and minor numbers of each partition as well as the number of 1024-byte blocks and the partition name.

For the 2nd, it certainly should be documented somewhere but you can also look directly at the Linux source code in block/partition-generic.c:

ssize_t part_size_show(struct device *dev,
                       struct device_attribute *attr, char *buf)
        struct hd_struct *p = dev_to_part(dev);
        return sprintf(buf, "%llu\n",(unsigned long long)part_nr_sects_read(p));
static DEVICE_ATTR(size, 0444, part_size_show, NULL);

and how it relates to the code which generates the /proc/partitions info in block/genhd.c:

static int show_partition(struct seq_file *seqf, void *v)
        while ((part = disk_part_iter_next(&piter)))
                seq_printf(seqf, "%4d  %7d %10llu %s\n",
                           MAJOR(part_devt(part)), MINOR(part_devt(part)),
                           (unsigned long long)part_nr_sects_read(part) >> 1,
                           disk_name(sgp, part->partno, buf));
static const struct seq_operations partitions_op = {
        .show   = show_partition

Both are using part_nr_sects_read() which for the case of /proc/partitions is divided by 2 (with >> 1).

part_nr_sects_read() retrieves the nr_sects field of the struct hd_struct, which is always in 512-byte sectors, irrespective of the sector/block size of the device. For instance, you can look at how drivers/block/nbd.c uses the set_capacity() function (which sets the same nr_sects field) with the byte size divided by 512 (with >> 9):

static void nbd_size_update(struct nbd_device *nbd)
        set_capacity(nbd->disk, config->bytesize >> 9);
| improve this answer | |
  • Thank you; I've been looking for the canonical answer to this question for an hour. – Edward Falk Oct 4 '19 at 23:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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