Ask Your Question
2

Increase swap space in fedora 19

asked 2013-10-03 10:59:27 -0500

kb2592 gravatar image

Hi, I just installed fedora 19 live version and i want to increase the swap memory size from 2 gb to 4 gb.I have a standard partition.Please help.

edit retag flag offensive close merge delete

Comments

Are you using logical volumes? LVM?

lnxslck gravatar imagelnxslck ( 2013-10-03 11:16:17 -0500 )edit

Please add the output of the lsblk and fdisk -l commands. You can either enlarge the existing swap partition (i.e. resize the partition and reformat it), which is best if you have free space immediately after the current partition; or you can add a second swap partition where you do have free space.

Gareth Jones gravatar imageGareth Jones ( 2013-10-03 11:19:32 -0500 )edit

1 Answer

Sort by » oldest newest most voted
3

answered 2013-10-03 11:25:09 -0500

updated 2015-12-08 10:36:47 -0500

florian gravatar image

You can increase swap size with 2 different ways:

Method A - Add a hard drive partition

  1. With fdisk, cfdisk or any other tool (gui tool also) create a new partition with the size you want, let's say 2 GB and the name is /dev/sdc1

  2. Now create this simple partition into swap

# mkswap /dev/sdc1
  1. Enable the swap partition
# swapon /dev/sdc1
  1. Make this swap persistent (after reboots), add the following line to the /etc/fstab file.
# /dev/sdc1       swap          swap   defaults        0 0
  1. Verify whether the newly created swap area is available for your use.
# swapon -s

Filename                        Type   Size    Used    Priority

/dev/sda2     partition       4192956  0   -1 /dev/sdc1

partition       1048568 0       -2

Method B: Add a File

You can also use a file on your disk to use as swap.

  1. Let's create a swap file with the name “myswapfile” under /root directory with a size of 2048MB (2GB).
# dd if=/dev/zero of=/root/myswapfile bs=1M count=2048

2048+0 records in 2048+0 records out

# ls -l /root/myswapfile
-rw-r--r--    1 root     root     1073741824 Aug 14 23:47 /root/myswapfile
  1. Change the permission of the swap file so that only root can access it.
# chmod 600 /root/myswapfile
  1. Make this file as a swap file using mkswap command.
# mkswap /root/myswapfile
  1. Enable the newly created swapfile.
# swapon /root/myswapfile
  1. Make swap file persistent after reboots, add the following line to the /etc/fstab file.
# cat /etc/fstab

/root/myswapfile      swap         swap   defaults     0 0
  1. Verify whether the newly created swap area is available for your use.
# swapon -s
Filename                        Type            Size    Used   

Priority

/dev/sda2                       partition       4192956 0       -1
/root/myswapfile                file            1048568 0       -2

Please read more from aritcle source here.

edit flag offensive delete link more

Comments

How to see My Swap space?

Muhammad Ali gravatar imageMuhammad Ali ( 2014-04-17 18:00:51 -0500 )edit

You can try as root swapon -s Also you can try free

lnxslck gravatar imagelnxslck ( 2014-05-05 08:18:49 -0500 )edit
1

@lnxslck: Just changed a line in your instructions:

# cat /etc/fstab /dev/sdc1       swap          swap   defaults        0 0

to

# /dev/sdc1       swap          swap   defaults        0 0
florian gravatar imageflorian ( 2015-12-08 10:38:34 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2013-10-03 10:59:27 -0500

Seen: 5,019 times

Last updated: Dec 08 '15