1

I'm using buildroot to build a custom linux system for my raspi A+.

Using genimage, I've created two partitions on a 1 GB sdcard. The first partion is the boot partition. It's vfat and it is 32 MB. The second partition is ext4, it is the rootfs and it is 512 MB.

Once I boot my raspi with the newly burned sdcard and that I type df -h I get this in the output:

Filesystem                Size      Used Available Use% Mounted on
/dev/root                17.1M     14.0M      1.8M  89% /
devtmpfs                200.6M         0    200.6M   0% /dev
tmpfs                   200.7M         0    200.7M   0% /dev/shm
tmpfs                   200.7M         0    200.7M   0% /tmp
tmpfs                   200.7M      4.0K    200.7M   0% /run

as you can see, /dev/root is 17.1 MB instead of 512 MB.

Then, I issue cat /proc/partitions:

major minor  #blocks  name

  1        0       4096 ram0
  1        1       4096 ram1
  1        2       4096 ram2
  1        3       4096 ram3
  1        4       4096 ram4
  1        5       4096 ram5
  1        6       4096 ram6
  1        7       4096 ram7
  1        8       4096 ram8
  1        9       4096 ram9
  1       10       4096 ram10
  1       11       4096 ram11
  1       12       4096 ram12
  1       13       4096 ram13
  1       14       4096 ram14
  1       15       4096 ram15
179        0     969728 mmcblk0
179        1      32768 mmcblk0p1
179        2     524288 mmcblk0p2

We clearly see that the sdcard (mmcblk0) is 1 GB, the boot partition (mmcblk0p1) is 32 MB and the rootfs partition (mmcblk0p2) is 512 MB.

So, to convince myself that the mmcblk0p2 partition may have been imporperly mounted, I mount it again with mount -t ext4 -o rw /dev/mmcblk0p2 /mnt and then I issue df -h again:

Filesystem                Size      Used Available Use% Mounted on
/dev/root                17.1M     14.0M      1.8M  89% /
devtmpfs                200.6M         0    200.6M   0% /dev
tmpfs                   200.7M         0    200.7M   0% /dev/shm
tmpfs                   200.7M         0    200.7M   0% /tmp
tmpfs                   200.7M      4.0K    200.7M   0% /run
/dev/mmcblk0p2           17.1M     14.0M      1.8M  89% /mnt

Again, I see that mmcblk0p2 size is 17.1 MB.

So, my question is Why is cat /proc/partitions returning the expected size for my rootfs partition while df -h returns a totally different and bogus size ?

  • Have you expanded the file system and rebooted? – Dr.Rabbit Oct 3 '17 at 1:59
  • How can I expand the file system? – slaadvak Oct 3 '17 at 2:13
  • should be the first option in sudo raspi-config, the other only thing I can think of is internally the block size is higher than 512B and being interpreted as 512B when using df -h, but when using cat /proc/partitions is showing an internal of 4096 – Dr.Rabbit Oct 3 '17 at 2:59
  • I don't have access to raspi-config in this custom distro. Maybe I could try to expand the partition on a desktop linux system? Also, is there any way to change the block size description or even just to check the values used by Linux? – slaadvak Oct 3 '17 at 11:11
  • Block size is fixed, I believe its hardware ie in the hdd or sdcard. as with expanding read up on fdisk and resize2fs link – Dr.Rabbit Oct 3 '17 at 11:35
0

When you created the partitions, did you give the size in blocks? A block is half a kilobyte (512 bytes). It looks like you created the partitions with 32k blocks and 512k blocks, which would be about 16M and about 256M.

Try repartitioning and pay attention to whether the partitioning tool is asking for the size in blocks or kB. With some tools (I like cfdisk) you can give the size in human units, eg "512M".

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.