• VMware

    Learn about VMware virtualization for its products like vsphere ESX and ESXi, vCenter Server, VMware View, VMware P2V and many more

  • Linux

    Step by step configuration tutorials for many of the Linux services like DNS, DHCP, FTP, Samba4 etc including many tips and tricks in Red Hat Linux.

  • Database

    Learn installation and configuration of databases like Oracle, My SQL, Postgresql, etc including many other related tutorials in Linux.

  • Life always offers you a second chance ... Its called tomorrow !!!

    Saturday, August 11, 2012

    How to Increase swap memory size in Linux

    You must have faced a condition when you need to increase your swap size. Well I faced one when I was trying to install Oracle Database and I was out of swap memory.

    I will show you two ways which can be used to do the same.

    Method 1

    If you have additional space in your hard disk create swap based partition.
    # fdisk /dev/sda
    Command (m for help):
    n
    Command action
       e   extended
       p   primary partition (1-4)
    e
    Partition number (1-4): 1
    First cylinder (1-48699, default 1): 1
    Last cylinder, +cylinders or +size{K,M,G} (1-48699, default 48699): +100M
    Command (m for help): p

    Disk /dev/sda: 51.1 GB, 51064602624 bytes
    64 heads, 32 sectors/track, 48699 cylinders
    Units = cylinders of 2048 * 512 = 1048576 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disk identifier: 0x3a369b23
    Device    Boot      Start         End      Blocks   Id  System
    /dev/sda4                    1         101      103408    5   Extended

    Command (m for help): t
    Selected partition 1
    Hex code (type L to list codes): L
    Hex code (type L to list codes): 82
    Command (m for help):w

    Once the partition is created run the below commands
    # partprobe /dev/sda4
    # mkswap /dev/sda4

    To utilize the created partition as swap and making it "ON"
    # swapon /dev/sda4
    To check the swap report# swapon -s
    Ensure that when the system reboots, the swap file is made available to the kernel
    # vi /etc/fstab
    /dev/sda4                    swap                   swap     defaults        0 0

    Update the fstab file
    # mount -a
    If you want to turnoff the swap partition
    # swapoff
    To check the swap partitions
    # swapon -s
    Check the swap memory
    # free -m


    Method 2
    If you donot have additional space in your hard disk create swap based file.
    Create 512MB swap file
    dd if=/dev/zero of=/swapfile bs=1024 count=524288
    Calculation:
    For 512 MB = 512 * 1024
    For 2 GB = (2*1024) * 1024

    # mkswap /swapfile
    # swapon /swapfile

    Ensure that when the system reboots, the swap file is made available to the kernel
    # vi /etc/fstab
    /swapfile                    swap                   swap     defaults        0 0

    Update the fstab file
    # mount -a

    Related Articles
    What is swappiness and how do we change its value?

    Follow the below links for more tutorials

    Configure Red Hat Cluster using VMware, Quorum Disk, GFS2, Openfiler
    Tutorial for Monitoring Tools SAR and KSAR with examples in Linux
    How to configure Samba 4 Secondary Domain Controller
    How to secure Apache web server in Linux using password (.htaccess)
    How to register Red Hat Linux with RHN (Red Hat Network )
    Red hat Enterprise Linux 5.5 Installation Guide (Screenshots)
    15 tips to enhance security of your Linux machine
    Why is Linux more secure than windows and any other OS
    What is the difference between "su" and "su -" in Linux?
    What is swappiness and how do we change its value?
    How to log iptables messages in different log file
    What are the s and k scripts in the etc rcx.d directories
    How to check all the currently running services in Linux
    How to auto start service after reboot in Linux
    What is virtual memory, paging and swap space?

    1 comments:

    1. very good site ......i have become fan of this site......all thing at one point

      ReplyDelete