Create/Add swap file

Linux specific questions/information are gathered here. The main thrust of topics are applied to Centos/RedHat(RH)/Debian/Ubuntu/Gentoo distributives

Create/Add swap file

Postby lik » Wed Jan 05, 2011 2:56 pm

Use dd command to create swapfile. Next you need to use mkswap command to set up a Linux swap area on a device or in a file.

1. Type following command to create 2048MB swap file (1024 * 2048MB = 2097152 block size):
Code: Select all
dd if=/dev/zero of=/swapfile bs=1024 count=2097152

2. Set up a Linux swap area:
Code: Select all
mkswap /swapfile

3. Activate /swapfile swap space:
Code: Select all
swapon /swapfile

4. To activate /swapfile after Linux system reboot, append the following entry to /etc/fstab file:
Code: Select all
/swapfile swap swap defaults 0 0
Posts: 497
Joined: Wed Dec 15, 2010 3:21 am

Return to Linux specific


  • Related topics
    Last post