How to change the number of reserved filesystem blocks

Change the number of reserved filesystem blocks.

Default number of reserved filesystem blocks

Display current values of the filesystem parameters.

$ sudo tune2fs -l /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Filesystem volume name:   
Last mounted on:          /
Filesystem UUID:          0db04d02-6e6b-491d-a13e-f1e00c9a8cd1
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash 
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              15491072
Block count:              61932544
Reserved block count:     3096627
Free blocks:              12697518
Free inodes:              13987896
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1024
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Thu Jun 14 20:04:09 2018
Last mount time:          Wed Sep 18 00:10:49 2019
Last write time:          Wed Sep 18 00:10:48 2019
Mount count:              25
Maximum mount count:      -1
Last checked:             Thu Jun 14 20:04:09 2018
Check interval:           0 ()
Lifetime writes:          4091 GB
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
First orphan inode:       7602256
Default directory hash:   half_md4
Directory Hash Seed:      b2be8da3-dcad-4029-b282-05c63e4890ab
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0xcc7e4256

This filesystem is using 4096 block size, it has 61932544 blocks, including 3096627 reserved ones.

Report of the filesystem disk space usage will be slightly different, but there is nothing to worry about as it takes into consideration blocks used by the journal and inode blocks.

$ df --block-size=4K /
Filesystem                  Type 4K-blocks     Used Available Use% Mounted on
/dev/sda3                   ext4  60697961 44235478  13361760  77% /
$ df --human-readable /
Filesystem                  Type  Size  Used Avail Use% Mounted on
/dev/sda3                   ext4  232G  169G   53G  77% /

By default the number of reserved blocks is set to 5%.

$ echo "61932544*5/100" | bc
3096627

In this case it will be around 11GB.

$ echo "(3096627*4096)/1024^3" | bc
11

Alter the number of reserved filesystem blocks by a percentage

Increase number of reserved blocks to 10%.

$ sudo tune2fs -m 10 /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Setting reserved blocks percentage to 10% (6193254 blocks)

In this case it will be around 23GB or 24192MB to be more exact.

$ echo "(6193254*4096)/1024^3" | bc
23
$ echo "(6193254*4096)/1024^2" | bc
24192

Display altered values of the filesystem parameters.

$ sudo tune2fs -l /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Filesystem volume name:   
Last mounted on:          /
Filesystem UUID:          0db04d02-6e6b-491d-a13e-f1e00c9a8cd1
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              15491072
Block count:              61932544
Reserved block count:     6193254
Free blocks:              12697518
Free inodes:              13987896
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1024
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Thu Jun 14 20:04:09 2018
Last mount time:          Wed Sep 18 00:10:49 2019
Last write time:          Wed Nov 20 01:14:22 2019
Mount count:              25
Maximum mount count:      -1
Last checked:             Thu Jun 14 20:04:09 2018
Check interval:           0 ()
Lifetime writes:          4091 GB
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
First orphan inode:       7602256
Default directory hash:   half_md4
Directory Hash Seed:      b2be8da3-dcad-4029-b282-05c63e4890ab
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0x39f657c8

Do not reserve any filesystem blocks.

Set the number of reserved blocks to 0%.

$ sudo tune2fs -m 0 /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Setting reserved blocks percentage to 0% (0 blocks)

Set the number of reserved blocks to 0 blocks.

$ sudo tune2fs -r 0 /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Setting reserved blocks count to 0

Display altered values of the filesystem parameters.

$ sudo tune2fs -l /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Filesystem volume name:   
Last mounted on:          /
Filesystem UUID:          0db04d02-6e6b-491d-a13e-f1e00c9a8cd1
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              15491072
Block count:              61932544
Reserved block count:     0
Free blocks:              12697518
Free inodes:              13987896
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1024
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Thu Jun 14 20:04:09 2018
Last mount time:          Wed Sep 18 00:10:49 2019
Last write time:          Wed Nov 20 01:16:46 2019
Mount count:              25
Maximum mount count:      -1
Last checked:             Thu Jun 14 20:04:09 2018
Check interval:           0 ()
Lifetime writes:          4091 GB
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
First orphan inode:       7602256
Default directory hash:   half_md4
Directory Hash Seed:      b2be8da3-dcad-4029-b282-05c63e4890ab
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0x39f657c8

Alter the number of reserved filesystem blocks by a block count

Calculate the number of blocks for 10GB

$ echo "(10*1024^3)/4096" | bc
2621440

Set the number of reserved blocks to 2621440.

$ sudo tune2fs -r 2621440 /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Setting reserved blocks count to 2621440

Display altered values of the filesystem parameters.

$ sudo tune2fs -l /dev/sda3
tune2fs 1.44.1 (24-Mar-2018)
Filesystem volume name:   
Last mounted on:          /
Filesystem UUID:          0db04d02-6e6b-491d-a13e-f1e00c9a8cd1
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent 64bit flex_bg sparse_super large_file huge_file dir_nlink extra_isize metadata_csum
Filesystem flags:         signed_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              15491072
Block count:              61932544
Reserved block count:     2621440
Free blocks:              12697518
Free inodes:              13987896
First block:              0
Block size:               4096
Fragment size:            4096
Group descriptor size:    64
Reserved GDT blocks:      1024
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         8192
Inode blocks per group:   512
Flex block group size:    16
Filesystem created:       Thu Jun 14 20:04:09 2018
Last mount time:          Wed Sep 18 00:10:49 2019
Last write time:          Wed Nov 20 01:19:58 2019
Mount count:              25
Maximum mount count:      -1
Last checked:             Thu Jun 14 20:04:09 2018
Check interval:           0 ()
Lifetime writes:          4091 GB
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
First orphan inode:       7602256
Default directory hash:   half_md4
Directory Hash Seed:      b2be8da3-dcad-4029-b282-05c63e4890ab
Journal backup:           inode blocks
Checksum type:            crc32c
Checksum:                 0x39f657c8