Different results between df & fdisk commands

0

I did resizing of my disk partition (/dev/mmcblk0p2), but after the process is done, what i get is the following results:

df -h :

Filesystem      Size  Used Avail Use% Mounted on
/dev/mmcblk0p2  3.1G  3.1G  2.5M 100% /
devtmpfs        360M     0  360M   0% /dev
tmpfs           489M  4.0K  489M   1% /dev/shm
tmpfs           489M   26M  464M   6% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           489M     0  489M   0% /sys/fs/cgroup
/dev/mmcblk0p1   40M   16M   25M  40% /boot
tmpfs            98M     0   98M   0% /run/user/0
tmpfs            98M     0   98M   0% /run/user/1000

and fdisk -l result is :

Disk /dev/mmcblk0: 7.4 GiB, 7948206080 bytes, 15523840 sectors
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: dos
Disk identifier: 0x00000000

Device         Boot  Start      End  Sectors  Size Id Type
/dev/mmcblk0p1       49152   131071    81920   40M 83 Linux
/dev/mmcblk0p2      131072 15523839 15392768  7.3G 83 Linux

why in df i don't get the full size of /dev/mmcblk0p2 ???

resizing done by the following set of commands

totalSize=`sfdisk -l /dev/mmcblk0 | grep "Disk /dev/mmcblk0" | cut -d ' ' -f 7`;

p2Start=`sfdisk -d /dev/mmcblk0 | grep "/dev/mmcblk0p2" | cut -d ',' -f 1 | cut -d '=' -f 2 | awk '{$1=$1};1'`;

newSize=$((totalSize - p2Start));

sfdisk -d /dev/mmcblk0 > /tmp/DiskLayout;

sed -i -E "s/\/dev\/mmcblk0p2.*size=[ ]*[0-9]+, type=83/\/dev\/mmcblk0p2 : start=       ${p2Start}, size=    ${newSize}, type=83/" /tmp/DiskLayout;

sfdisk /dev/mmcblk0  --no-reread < /tmp/DiskLayout;

reboot

resize2fs /dev/mmcblk0p2

reboot

resize2fs output:

Filesystem at /dev/mmcblk0p2 is mounted on /;
on-line resizing required old_desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/mmcblk0p2 to 1924096 (4k) blocks.

this is a part of a process for preparing sd in mass production, so it must be done dynamically using a split script parts

linux
ubuntu
partitioning
asked on Super User Apr 11, 2019 by Rami Khawaly • edited Apr 11, 2019 by Rami Khawaly

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0