How to set up a swap space on an existing Debian server
- myVesta
- Site Admin
- Posts: 824
- Joined: Fri Jun 19, 2020 9:59 am
- Has thanked: 5 times
- Been thanked: 6 times
Since you can't do repartition of existing disk (in order to add swap partition), you can create swap inside an file:
Code: Select all
dd if=/dev/zero of=/swapfile1 bs=1024 count=1048576 # this is 1GB file
chown root:root /swapfile1
chmod 0600 /swapfile1
mkswap /swapfile1
swapon /swapfile1
echo "/swapfile1 none swap sw 0 0" >> /etc/fstab
free -m