Created
April 30, 2021 14:26
-
-
Save VottusCode/d4fc95356ea04c418b7dbd135a41566d to your computer and use it in GitHub Desktop.
Fuck Hiberfile right off your drive. Just rewrite /dev/sda to your Windows drive.
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
if ! [ $(id -u) = 0 ]; then | |
echo "You need to run this script as root (or use sudo)." >&2 | |
exit 1 | |
fi | |
if grep -qs '/dev/sda4 ' /proc/mounts; then | |
echo '/dev/sda4 is already mounted, proceeding to unmount' | |
umount /dev/sda4 | |
if [ $? -eq 0 ]; then | |
echo "Successfully unmounted /dev/sda4!" | |
else | |
echo "An error occurred while unmounting /dev/sda4" | |
exit 1; | |
fi | |
fi | |
RANDOM_TEMPMOUNT=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1) | |
echo 'Creating a temporary mount endpoint $RANDOM_TEMPMOUNT' | |
mkdir $RANDOM_TEMPMOUNT | |
echo 'Mounting drive with remove_hiberfile...' | |
ntfs-3g -o remove_hiberfile /dev/sda4 $RANDOM_TEMPMOUNT | |
if [ $? -eq 0 ]; then | |
echo "Mounted successfully to $RANDOM_TEMPMOUNT..." | |
else | |
echo "An error occurred while mounting /dev/sda4 to $RANDOM_TEMPMOUNT" | |
exit 1; | |
fi | |
echo 'Unmounting /dev/sda4...' | |
umount /dev/sda4 | |
if [ $? -eq 0 ]; then | |
echo "Successfully unmounted /dev/sda4!" | |
else | |
echo "An error occurred while unmounting /dev/sda4" | |
exit 1; | |
fi | |
rm -rf $RANDOM_TEMPMOUNT | |
echo 'Hiberfile was successfully removed.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment