sane-reclaim-disk-space: add --fast
flag to skip rmlint check
This commit is contained in:
parent
d6e34c6e98
commit
487dfd3378
|
@ -33,6 +33,7 @@ resholve.mkDerivation {
|
||||||
ssh-to-age
|
ssh-to-age
|
||||||
sops
|
sops
|
||||||
sudo
|
sudo
|
||||||
|
util-linux
|
||||||
which
|
which
|
||||||
];
|
];
|
||||||
keep = {
|
keep = {
|
||||||
|
|
|
@ -1,17 +1,41 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -ex
|
|
||||||
# script to reclaim some hard drive space
|
# script to reclaim some hard drive space
|
||||||
|
set -e
|
||||||
|
|
||||||
|
options=$(getopt -l "fast" -o "f" -- "$@")
|
||||||
|
do_rmlint=true
|
||||||
|
for arg in $options; do
|
||||||
|
case $arg in
|
||||||
|
-f|--fast)
|
||||||
|
do_rmlint=false
|
||||||
|
;;
|
||||||
|
--)
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# always claim nix garbage
|
||||||
sudo nix-collect-garbage
|
sudo nix-collect-garbage
|
||||||
# identify duplicate files in the nix store
|
|
||||||
rmlint --types="duplicates" --config=sh:handler=clone --output=sh:/tmp/rmlint.sh --output=json:/dev/null --progress /nix/store
|
if [ $do_rmlint = true ]
|
||||||
# link the dupes together (uses ioctl_fideduperange)
|
then
|
||||||
# see: https://btrfs.wiki.kernel.org/index.php/Deduplication
|
# identify duplicate files in the nix store
|
||||||
# see: https://rmlint.readthedocs.io/en/latest/tutorial.html
|
rmlint --types="duplicates" --config=sh:handler=clone --output=sh:/tmp/rmlint.sh --output=json:/dev/null --progress /nix/store
|
||||||
sudo mount -o remount,rw /nix/store
|
# link the dupes together (uses ioctl_fideduperange)
|
||||||
# XXX: does rmlint really need to be invoked as root?
|
# see: https://btrfs.wiki.kernel.org/index.php/Deduplication
|
||||||
sudo /tmp/rmlint.sh -d || true # on failure, we still want to remount ro
|
# see: https://rmlint.readthedocs.io/en/latest/tutorial.html
|
||||||
# XXX this doesn't work: 'mount point is busy.'
|
fi
|
||||||
sudo mount -o remount,ro /nix/store
|
|
||||||
|
if [ $do_rmlint = true ]
|
||||||
|
then
|
||||||
|
sudo mount -o remount,rw /nix/store
|
||||||
|
# XXX: does rmlint really need to be invoked as root?
|
||||||
|
sudo /tmp/rmlint.sh -d || true # on failure, we still want to remount ro
|
||||||
|
# XXX this doesn't work: 'mount point is busy.'
|
||||||
|
sudo mount -o remount,ro /nix/store
|
||||||
|
fi
|
||||||
|
|
||||||
# TODO: instead of using rmlint, could use dduper: https://github.com/Lakshmipathi/dduper
|
# TODO: instead of using rmlint, could use dduper: https://github.com/Lakshmipathi/dduper
|
||||||
# better perf for btrfs (checksum tests)
|
# better perf for btrfs (checksum tests)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user