Different results between df & fdisk commands

-1

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  1.4G  1.7G  46% /
devtmpfs        360M     0  360M   0% /dev
tmpfs           489M  4.0K  489M   1% /dev/shm
tmpfs           489M  7.3M  482M   2% /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/1000
tmpfs            98M     0   98M   0% /run/user/0

and fdisk -l result is :

Disk /dev/mmcblk0: 14.9 GiB, 15931539456 bytes, 31116288 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 31116287 30985216 14.8G 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

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
disk-partitioning
asked on Stack Overflow Apr 11, 2019 by Rami Khawaly

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0