Created
July 7, 2021 09:14
-
-
Save aivanise/8a53492e6a2b12604c1d98dd4b5bd414 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# zero all the free blocks on a (mounted) root fs to TRIM it | |
# and/or make it more compressible for backups | |
# during this process the machine is basically dead (only ssh works) | |
# reboots at the end | |
systemctl isolate rescue-ssh | |
sleep 3 | |
systemctl stop systemd-journald.socket | |
systemctl stop systemd-journald-audit.socket | |
systemctl stop systemd-journald-dev-log.socket | |
systemctl stop systemd-journald | |
systemctl stop systemd-udevd-control.socket | |
systemctl stop systemd-udevd-kernel.socket | |
systemctl stop systemd-udevd | |
sleep 10 | |
systemctl stop systemd-journald.socket | |
systemctl stop systemd-journald-audit.socket | |
systemctl stop systemd-journald-dev-log.socket | |
systemctl stop systemd-journald | |
systemctl stop systemd-udevd-control.socket | |
systemctl stop systemd-udevd-kernel.socket | |
systemctl stop systemd-udevd | |
echo s > /proc/sysrq-trigger | |
sleep 1 | |
echo u > /proc/sysrq-trigger | |
sleep 1 | |
zerofree $(findmnt -no SOURCE /) | |
systemctl reboot |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment