1

Is there a way to find out the used size of an umounted filesystem?

I want to resize the ext4 / filesystem, so I boot into a live Lubuntu using a Lubuntu bootable flash drive. Since the / filesystem is not mounted, I don't know how much I can shrink it.

Thanks.

  • 1
    I would use gparted, it is a graphical tool. I love command live, but I do this so infrequently. Graphical tools are good for infrequent jobs, and visualisation. Both of which apply here. – ctrl-alt-delor Feb 23 at 18:50
5

For ext2/3/4 filesystems you could use dumpe2fs or tune2fs -l (from e2fsprogs) to get the total, used, and available block counts (among other properties) e.g.

$ sudo tune2fs -l /dev/sda5 | grep -i block
Block count:              3999755
Reserved block count:     199987
Free blocks:              3396721
First block:              0
Block size:               4096
Reserved GDT blocks:      1024
Blocks per group:         32768
Inode blocks per group:   509
Flex block group size:    16
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
Journal backup:           inode blocks
  • Thanks. Can you make the output in human readable sizes (e.g. GB/MB) – Tim Feb 23 at 18:50
  • For example <<<'scale=1;(3396721)*4096/2^30' bc to get it in GiB, and <<<'scale=1;(3396721-199987)*4096/2^30' bc to make it match approximately the output of df -h (df works only when mounted of course). – sudodus Feb 23 at 21:44

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.