Created
October 1, 2013 13:25
-
-
Save inlanger/6778396 to your computer and use it in GitHub Desktop.
Create 1024mb swap partition
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 | |
### BEGIN INIT INFO | |
# Provides: swap | |
# Required-Start: | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 1 0 6 | |
# Short-Description: add fake swap. | |
### END INIT INFO | |
SWAP="${1:-512}" | |
NEW="$[SWAP*1024]"; TEMP="${NEW//?/ }"; OLD="${TEMP:1}0" | |
umount /proc/meminfo 2> /dev/null | |
sed "/^Swap\(Total\|Free\):/s,$OLD,$NEW," /proc/meminfo > /etc/fake_meminfo | |
mount --bind /etc/fake_meminfo /proc/meminfo | |
free -m |
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
swapon -s | |
dd if=/dev/zero of=/swapfile bs=1024 count=1024k | |
mkswap /swapfile | |
swapon /swapfile | |
echo "/swapfile none swap sw 0 0" > /etc/fstab | |
sudo chown root:root /swapfile | |
sudo chmod 0600 /swapfile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment