Skip to content

Instantly share code, notes, and snippets.

@wtip
Created May 18, 2020 20:23
Show Gist options
  • Save wtip/681cd244611ff637756f15f3a895fabb to your computer and use it in GitHub Desktop.
Save wtip/681cd244611ff637756f15f3a895fabb to your computer and use it in GitHub Desktop.
Ansible task to change the reserved filesystem blocks
tasks:
- name: Change reserved blocks to 1 percent on ext4 filesystems that are not / mounted
shell: tune2fs -l {{ item.device }} | egrep "Reserved block count|Block count" | paste -sd\ | awk '{print ($7 / $3 * 100)}' | grep -q 1 || tune2fs -m1 {{ item.device }}
with_items:
- "{{ ansible_mounts }}"
when: item.fstype == 'ext4' and item.mount != '/'
register: tune2fs
changed_when: tune2fs.stdout != ""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment