Giter Site home page Giter Site logo

puyral / zfs-snapshot-disk-usage-matrix Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mafm/zfs-snapshot-disk-usage-matrix

0.0 0.0 0.0 24 KB

ZFS snapshot disk space usage accounting (Where did all my disk space go?!)

License: MIT License

Python 100.00%

zfs-snapshot-disk-usage-matrix's Introduction

Useful ZFS snapshot disk space usage accounting

Confusion and frustration over ZFS snapshots disk space usage seems to be common.

This script produces useful disk space accounting for snapshots on a ZFS filesystem.

The problem

When you ask ZFS about the disk space used by snapshots, it really only wants to tell you about how much space is being uniquely used by individual snapshots. If two adjacent snapshots:

  • both reference a shared Gigabyte of space that is not referenced by any other snapshot, but
  • each uniquely reference only 1 Megabyte of space,

"zfs list" will tell you that each snapshot is consuming only a one Megabyte of space. This is not helpful if you're trying to work out which snapshots to delete to free up diskspace.

Although the example scenario might seem unlikely, it seems to be a common cause of confusion and frustration. In the archives of the zfs-discuss mailing list, there's recurring advice that the best way out of the situation is to blindly start deleting snapshots and see how much disk space comes back.

A solution

If you use "zfs destroy -nv filesystem@snap1%snap2" ZFS will actually tell you how much space the sequence of snapshots between snap1 and snap2 is using. This is more useful for working out which snapshots are consuming disk space. In the example from the previous paragraph, this would inform you that deleting both snapshots together would free 1.002 Gigabytes - clearly more useful than telling you that freeing either one individually would free one Megabyte.

This script

This script runs "zfs destroy -nv" for all pairs of snapshots in a filesystem, and shows how much space would be freed by deleting the corresponding sequence of snapshots. It produces a csv-formatted matrix with row and column headers. If you send the output to a file, it can be read using Excel or some other spreadsheet-type software to see exactly which snapshots are using the space.

Output from this script:

  • converts sizes reported by ZFS into bytes
  • strips any common prefix from snapshot names (e.g. "zfs-auto-snap")

Options could be added to enable/disable this, but I can't be bothered right now.

There may be an easier way of doing this. If you know about it, please tell me.

Example:

zfs-snapshot-disk-usage-matrix.py local-fast-tank-machine0/Virtual-Machines/VirtualBox/vpn-linux-u14 | tee vpn-snapshot-usage.csv

zfs-snapshot-disk-usage-matrix's People

Contributors

mafm avatar marcelwaldvogel avatar s-m-e avatar gdevenyi avatar jgottula avatar nxg avatar timdau avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.