-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquick_swap.sh
executable file
·46 lines (43 loc) · 1.21 KB
/
quick_swap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
# Swap performance optimizer
#
# Sometimes you need PLENTY of EFFICIENT swap for a short period.
# In that case, the secure cryptoswap is going to cost you too much.
# This utility create an uncrypted, large, fast swapfile, deactivating
# the crypted swap, allowing you to safely crunch your data.
# When you are done, just hit return and the original configuration
# is restored, while the swapfile is securely shredded.
# on
echo "Creating swapfile"
sudo fallocate -l 32G /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile --label "swapfile"
echo "Switching swap"
sudo swapon /swapfile
sudo swapoff /dev/mapper/cryptswap1
echo " done!"
echo
sudo swapon -s
echo
# ready
echo "Quick swap on, enjoy"
echo "Once done, press 'ENTER' to roll back"
read kthxbye
echo
# off
echo "Switching back swap"
sudo swapon /dev/mapper/cryptswap1
sudo swapoff /swapfile
echo "Schredding swapfile"
echo "(feel free to interrupt this if you didn't"
echo " actually get to use the swap)"
# Shredding alternatives: http://askubuntu.com/questions/57572/how-to-delete-files-in-secure-manner
# sudo shred -uvn 1 /swapfile
sudo shred -uvzn 0 /swapfile
echo
echo "Removing swapfile"
sudo rm /swapfile
echo " done!"
echo
sudo swapon -s
echo