5

I've installed Debian Wheezy; after installation completed, I realized that I forgot to set the swap memory. So now, how can I configure the swap space?

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Zignd
  • 3,003
  • 10
  • 35
  • 48

3 Answers3

8

Try this:

  1. Create a partition or RAID array or logical volume... (or use an existing one) for swap
  2. mkswap that partition
  3. Run blkid that-block-device
  4. Add an entry to /etc/fstab in the form UUID=7321174b-e4d8-4d9d-b223-113a1b8e9c9f swap swap sw 0 0 (see step 3 for actual UUID)
  5. swapon -a or reboot
Stéphane Chazelas
  • 522,931
  • 91
  • 1,010
  • 1,501
Renan
  • 16,976
  • 8
  • 69
  • 88
  • 2
    You can also use a file instead of a partition. It's slower, but will get the job done if you don't have room for an additional partition. – jordanm Sep 17 '12 at 22:50
0

If you can't create a new partition or add new disks, you can increase your swap with the following :

swapfile=swapfile01
dd if=/dev/zero of=/var/$swapfile bs=1024 count=$(( 2*1024*1024 ))
mkswap -L $swapfile /var/$swapfile
echo "/var/$swapfile swap swap defaults 0 0" >> /etc/fstab
swapon /var/$swapfile

NB - this creates a 2GB swapfile. Adjust count= to requirements.

Leolo
  • 123
  • 5
-3

FYI. If you configure a swap space on an encrypted container, it will break! I strongly advise you to configure swap volume during the OS setup phase.