Last active
July 4, 2022 23:25
-
-
Save tuklusan/cae51fb885661d75488e960f72ec5432 to your computer and use it in GitHub Desktop.
Zero Out Free Disk Space on Virtual Machines and Compact them Before Backup: Solaris, Linux, Windows, OpenVMS: http://supratim-sanyal.blogspot.com/2016/12/zero-out-free-disk-space-on-virtual.html
This file contains hidden or 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 -x | |
# | |
# --- | |
# zerofill.sh | |
# --- | |
# | |
# Poor man's zerofill to fill up unusued space with zeroes | |
# for better compaction of virtual hard-disk. | |
# | |
# For my simple solaris 11 openindiana installation, this zeroes out empty | |
# disk space on /tmp/ (user partitions are TBD) | |
# Zeroing out other partitions not supported yet | |
# | |
# This script just creates a big file with zeroes and deletes it. To monitor | |
# progress you can you something like | |
# while [ 1 ]; do date; ls -lh /tmp/zero* ; df -h; sleep 10; done | |
# | |
# Supratim Sanyal - http://mcaf.ee/sdlg9f | |
# License: GNU AGPLv3 (http://tuklusan.decsystem.org/agpl-3.0-standalone.html) | |
# --- | |
# | |
if cd /tmp/ ; then | |
cat /dev/zero > zero.delete-me | |
sync | |
rm -f zero.delete-me | |
sync | |
else | |
echo "FAIL - no directory to create zero file in" | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment