Created
November 17, 2016 14:32
-
-
Save arpat/5f8dd71e1b7c4335d3ed54b250cf13f0 to your computer and use it in GitHub Desktop.
Make a swapfile on Linux of 1GB
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 | |
## blame: [email protected] | |
## Make a 1G swapfile in CWD | |
SwapFile="~~SWAPFILE.$(date +%H%m%s%N | sha1sum | cut -c1-12)" | |
# fallocate -l 1G $SwapFile \ ## caused issue for f2fs | |
dd if=/dev/zero of="$SwapFile" bs=1024 count=1048576 \ | |
&& chmod 600 $SwapFile \ | |
&& mkswap $SwapFile \ | |
&& swapon $SwapFile | |
echo "MAKE SURE to switch swap off before making $SwapFile inaccessible with" | |
echo " swapoff $PWD/$SwapFile" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment