Created
September 20, 2022 12:03
-
-
Save Himura2la/11d8335ed8ac0822b52af09b334d4451 to your computer and use it in GitHub Desktop.
Use Azure temporary disk for swap without waagent (on Debian)
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
cat <<'EOF' | sudo tee /usr/local/sbin/addswap.sh | |
#!/bin/sh | |
if [ ! -f /mnt/swapfile ] | |
then | |
/usr/bin/fallocate -l 30G /mnt/swapfile | |
/usr/bin/chmod 600 /mnt/swapfile | |
/usr/sbin/mkswap /mnt/swapfile | |
/usr/sbin/swapon /mnt/swapfile | |
fi | |
EOF | |
sudo chmod 744 /usr/local/sbin/addswap.sh | |
cat <<'EOF' | sudo tee /etc/systemd/system/addswap.service | |
[Unit] | |
Description=Enable 30G swap on Azure temp-disk | |
[Service] | |
Type=oneshot | |
ExecStart=/usr/local/sbin/addswap.sh | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
sudo chmod 644 /etc/systemd/system/addswap.service | |
sudo systemctl enable addswap.service |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment