Giter Club home page Giter Club logo

discard-everything's Introduction

Introduction

SSDs have sophisticated wear-leveling algorithms which need to know about free blocks to work correctly [1]. Widespread Linux filesystems (e.g. Ext4, XFS, Btrfs) support to issue the needed commands automatically after removing data by adding the discard mount option but doing so can have a negative effect on performance [2], [3].

To read more about SSD handling in Linux see the help pages of your distribution (e.g. Arch Linux, Debian, Fedora, SUSE Linux).

discard-everything.sh

This script does currently do two things:

  • Run fstrim on all mounted filesystems that reside on block devices supporting discards.
    This does not check if the actual file system supports discard.
  • Run blkdiscard on any free discardable space covered by LVM.
    It does so by creating temporary volumes covering 100% of the free VG space and issuing blkdiscard on them.

Requirements

You need to have fstrim and blkdiscard (as well as all other support utilities used such as lvm and blockdev) available for execution. Besides that, the file systems as well as all block layers beneath them (e.g. LVM, dm-crypt) need to be configured to pass the trim commands on to the next layer. Of course it does only make sense to use discard-everything.sh if you don't mount your filesystems with the discard option.

LVM

Make sure you have issue_discards = 1 in the devices section of your lvm.conf (see [4] or your local manpage: man lvm.conf).

dm-crypt

For devices created by crypttab add allow-discards as optional argument [5].
For those created by cryptsetup use the --allow-discards parameter (see [6] or your local manpage: man cryptsetup).

Usage

Just copy discard-everything.sh into /etc/cron.weekly/ or a similar place, or execute it manually regularly (as root).

discard-everything's People

Contributors

stefanct avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

danbst

discard-everything's Issues

Why not `fstrim --all`?

The first part of the script traverses all mounted systems and discard each.
Why didn't you use fstrim --all instead?

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.