Score:0

resize2fs -M doesn't remove all (most) free blocks

cn flag

I'm trying to create a smaller version of a Rasbian OS Lite image. I have tried to run resize2fs -M /dev/sda2 on the SD card root partition. But as you can see below, after resize2fs there is still a huge number of free blocks. Mounting it you can also see there is 12% free space. What am I missing here? Can't I reduce the size of an ext4 fs more than this? Also, why isn't the block count same as df reported fs size? 263798*4096 (1030M) vs 979M

pi@raspberry:~ $ sudo resize2fs -p -M /dev/sda2
resize2fs 1.46.2 (28-Feb-2021)
Resizing the filesystem on /dev/sda2 to 263798 (4k) blocks.
Begin pass 2 (max = 1)
Relocating blocks             XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Begin pass 3 (max = 9)
Scanning inode table          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/sda2 is now 263798 (4k) blocks long.

pi@raspberry:~ $ sudo tune2fs -l /dev/sda2
tune2fs 1.46.2 (28-Feb-2021)
Filesystem volume name:   rootfs
Last mounted on:          /
Filesystem UUID:          6d2ff93e-eacd-415c-96d5-4611ad21e05f
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype extent flex_bg sparse_super large_file dir_nlink extra_isize metadata_csum
Filesystem flags:         unsigned_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              73440
Block count:              263798
Reserved block count:     1999
Free blocks:              35619
Free inodes:              37552
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      95
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8160
Inode blocks per group:   510
Flex block group size:    16
Filesystem created:       Thu Sep 22 00:23:04 2022
Last mount time:          Sat Oct 15 20:14:34 2022
Last write time:          Sat Oct 15 20:49:03 2022
Mount count:              0
Maximum mount count:      -1
Last checked:             Sat Oct 15 20:33:10 2022
Check interval:           0 (<none>)
Lifetime writes:          2152 MB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
Default directory hash:   half_md4
Directory Hash Seed:      2691ef59-d6a4-453d-8399-6bf963318a73
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0xa9df5888
pi@raspberry:~ $ sudo mount /dev/sda2 /mnt/sda2
pi@raspberry:~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        29G  880M   27G   4% /
devtmpfs        333M     0  333M   0% /dev
tmpfs           462M     0  462M   0% /dev/shm
tmpfs           185M  980K  184M   1% /run
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/mmcblk0p1  255M   50M  206M  20% /boot
tmpfs            93M     0   93M   0% /run/user/1000
/dev/sda2       979M  840M  116M  88% /mnt/sda2 <-- THIS ONE

pi@raspberry:~ $ sudo resize2fs -p -d 32 -M /dev/sda2
resize2fs 1.46.2 (28-Feb-2021)
fs has 35888 inodes, 5 groups required.
fs requires 223086 data blocks.
With 5 group(s), we have 158747 blocks available.
Added 2 extra group(s), blks_needed 223086, data_blocks 224283, last_start 160989
Last group's overhead is 5093
Need 62097 data blocks in last group
Final size of last group is 67190
Estimated blocks needed: 263798
The filesystem is already 263798 (4k) blocks long.  Nothing to do!
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.