Coder Social home page Coder Social logo

xtaran / unburden-home-dir Goto Github PK

View Code? Open in Web Editor NEW
50.0 6.0 12.0 902 KB

Automatically unburden $HOME from caches, etc. Useful for $HOME on SSDs, small disks or slow NFS homes. Can be triggered via an hook in /etc/X11/Xsession.d/.

Home Page: https://unburden-home-dir.readthedocs.io/

License: GNU General Public License v2.0

Perl 93.94% Shell 2.35% Makefile 3.71%
disk-space perl tmpfs cleanup ssd nfs backup homedir symlinks

unburden-home-dir's Introduction

Unburden Your Home Directory

GitHub Workflow Status Documentation Status Coverage by Coveralls Coverage by Codecov CII Best Practices

Packaging status unburden-home-dir

unburden-home-dir allows users to move cache files from browsers, etc. off their home directory, i.e. on a local harddisk or tmpfs and replace them with a symbolic link to the new location (e.g. on /tmp/ or /scratch/) upon login. Optionally the contents of the directories and files can be removed instead of moved.

This is helpful at least in the following cases:

  • The idea-giving case are big workstation setups where $HOME is on NFS and all those caches put an unnecessary burden (hence the name) on the file server since caching over NFS doesn't have the best performance and may clog the NFS server, too.

  • A similar case, but with different purpose is reducing I/O on mobile devices like laptops or netbooks to extend the battery life or reduce the wearing down of CF or SD cards, e.g. in single board computers like the Raspberry Pi or ALIX or APU boards: Moving browser caches etc. off the real disk into a tmpfs filesystem reduces the amount of disk I/O which reduces the power consumption of the disk.

  • Another type of use cases for unburden-home-dir is to reduce disk space usage, e.g. on devices with small disk space but a lot of RAM as seen often on boxes with flash disks or early netbooks, e.g. the first EeePC with 4GB disk space and 2GB RAM are not seldom. In this case you want to move off as many cache files, etc. as possible to some tmpfs filesystem, e.g. /tmp/.

  • It may also help to reduce the amount of needed backup disk space by keeping those files in places where they don't get backed up. In that case it's an alternative to keeping the blacklist in your backup software up-to-date.

  • Another pragmatic use case may be to stay โ€” as a user โ€” within a given disk quota. :-)

This project initially started as an Xsession hook. It now consists of a perl script which optionally can also be called from a provided Xsession hook.

The full documentation can be read online at ReadTheDocs, at Gitbook or downloaded as e-book at Gitbook.

Author

Axel Beckert [email protected]

unburden-home-dir initially has been developed for usage at Dept. of Physics, ETH Zurich.

License

unburden-home-dir is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program in the file COPYING. If not, see GNU's license web page.

unburden-home-dir's People

Contributors

amdmi3 avatar empee584 avatar jwilk avatar kochd avatar thkoch2001 avatar xtaran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

unburden-home-dir's Issues

gnome-keyring 3.4 no more works as ssh-agent replacement when .cache is moved away

The typical error message seems: "Agent admitted failure to sign using the key."

GNOME Keyring changed the keyring socket's location from somewhere under /tmp/ to somewhere under $HOME/.cache with 3.3.92 (i.e. a 3.4 beta release).

This should be at least documented and the default configuration should care about it if it's no GNOME Keyring bug.

Doesn't affect Debian Squeeze or Ubuntu Precise, but will affect Debian Wheezy if not fixed.

WARNING: lsof not found, not checking for files in use

This WARNING is in my .xsession-errors. Although I have lsof installed
$ rpm -q lsof
lsof-4.88-2.fc22.x86_64

On my Fedora 22 desktop (and I guess on all fedora/redhat clones/derivatives) lsof is located at /usr/sbin:
$ which lsof
/usr/sbin/lsof

Unfortunately when snippet is run by xinit, '/usr/[local/]sbin' directories are not part of the PATH.
They are added by /etc/profile which means on interactive shells only.

unburden-home-dir can't move .cache folder because find command already use it

I configure moving .cache folder on Ubuntu 14.04 with KDE environment, but each time on login I see in logs this problem:

WARNING: Can't handle /home/user1/.cache: in use, not (re)moving. Process list:
   3813 (find)
   3813 (find)

So .cache folder will never moved to unburden location.

Seems that unburden-home-dir script launch find process, that don't finish on this check. How can I fix the problem? Maybe can help sleep command for some seconds before this check?

How to deal with spaces in path?

for example if i want to handle some chromium files, then a list entry
m f .config/chromium/Default/Cookies chromium/Default/Cookies
works totally fine, but how to handle a file with spaces in its name, e.g. Network Action Predictor?
I have tried
m f .config/chromium/Default/Network Action Predictor chromium/Default/Network Action Predictor
and
m f ".config/chromium/Default/Network Action Predictor" "chromium/Default/Network Action Predictor"
at the moment this entries in the list will be just silently ignored.

Problem with file links

I have a config option that looks like:

m F app/output.txt app

If there is an existing symlink with a file as the target, i.e.

output.txt -> /user_data/.tmp/app.jvd/output.txt

Then you'll get errors like:

WARNING: Can't handle /u/jvd/app/output.txt: /user_data/.tmp/app.jvd/output.txt not equal /user_data/.tmp/app.jvd/ at /usr/bin/unburden-home-dir line 184, line 16.

If you remove the link, and run unburden again, it creates the link OK. Second time you run, you'll now see errors:

ERROR: Can't handle /user_data/.tmp/app.jvd/: Unexpected type (not a file) at /usr/bin/unburden-home-dir line 189, line 16.

So it looks to me when you evaluate the target for a link, that target is always a directory. But then check_for_unexpected_target is trying to ensure that the target is the same type as the source. So I don't see how that can work if you're symlinking a file to a directory?

Unless I've got the wrong end of the stick somewhere?

Add mask for move all Electron apps caches

All Electron apps store cache files in .config and other folders and eat a lot of space, here is issue about this problem: electron/electron#8124

Until this issue solved, will be good to have default configuration for unburden all those folders, something like this:

# Electron apps in .config folder
m D .config/*/Cache electronApp-%1-Cache
m D .config/*/GPUCache electronApp-%1-GPUCache
m D .config/*/*/Cache electronApp-%1-%2-Cache
m D .config/*/*/GPUCache electronApp-%1-%2-GPUCache

What do you think about this idea?

zram: using a compressed in-memory fs?

as inspiration, my /usr/local/bin/overlay-zram

#!/bin/bash -xv
set -e # die if one step fails

echo "called $0 $@"
dir=$(basename "$@")
zram=/tmp/zram

modprobe -v zram
zramdev=$(zramctl --find --size 20GiB --algorithm lz4)
mkfs.ext4 -O ^has_journal ${zramdev}
mkdir -pv ${zram}
mount -vo discard,dax,noatime ${zramdev} ${zram}
mkdir -pv "/tmp/${dir}-union" "${zram}/${dir}"/{.work,.upper}
modprobe -v overlay
mount -vt overlay overlay -o "lowerdir=${@},upperdir=${zram}/${dir}/.upper,workdir=${zram}/${dir}/.work" "/tmp/${dir}-union"
chown -v --reference="${@}" "/tmp/${dir}-union"

Compression ratio can be looked at with zramctl ..
hard to know if it's worth the fuzz without trying..

Do not override XDG_CACHE_HOME

Hi,

I have to set XDG_CACHE_HOME="$HOME/.cache" because if it's empty unburden-home-dir overrides it. Is there a way of use unburden-home-dir without it set XDG_CACHE_HOME to the /tmp/.unburden-%u/cache ?

major browsers cache location is wrong

I hope that I am not wrong on this:
Looking at contents of /etc/unburden-home-dir.list

  • google-chrome
    I don't see files .config/google-chrome/*/Thumbnails[-journal]
    (actually I am using beta channel and dir for me is .config/google-chrome-beta, maybe its good idea to consider beta users too or maybe even unstable?)
    $ find . -name Thumbnails (in $HOME) returns nothing, so its not moved, just not valid (at least for beta)
    but there are 2 cache dirs at ~/.cache/google-chrome-beta/Default/
    google-chrome-beta-46.0.2490.13-1.x86_64
  • for firefox
    cache dirs are under ./.cache/mozilla/firefox/{profile}/
    there is no Cache.Trash but few more
    firefox-40.0.3-1.fc22.x86_64

I guess I can fork/patch/create pull request but maybe that is not valid for every distribution,
I really have no idea.

Question: Use in NFS-based multiple seat environments?

I'm just wondering if anyone has used this in multiple seat environments, i.e. where I might be on workstation A on one day, and workstation B another, or even both at the same time?

Are all the the "unburdened" directories non-essential in the sense they could disappear and everything would keep working?

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.