Skip to content

Instantly share code, notes, and snippets.

@jettero
Created January 14, 2022 20:00
Show Gist options
  • Save jettero/e83cc128bf310e94bd887261d92f199d to your computer and use it in GitHub Desktop.
Save jettero/e83cc128bf310e94bd887261d92f199d to your computer and use it in GitHub Desktop.
In [8]: import re
...: import subprocess
...: def get_ext_info(dev):
...: try:
...: output = subprocess.check_output(['sudo', 'dumpe2fs', '-h', dev], stderr=subprocess.DEVNULL).decode()
...: except:
...: pass
...: data = dict()
...: for line in output.splitlines():
...: if m := re.match(r'^([^:]+):\s+(.+)$', line):
...: data[m.group(1)] = m.group(2)
...: return data
...:
...: get_ext_info("/dev/sda1")["Reserved GDT blocks"]
Out[8]: '1010'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment