Creating a Linux Swap partition for ESX service console
search cancel

Creating a Linux Swap partition for ESX service console


Article ID: 339380


Updated On:


VMware vSphere ESXi


This article provides steps to create a Linux Swap partition for ESX service console.
You want to create a Linux Swap partition if:
  • No swap partitions were configured during ESX install.
  • The swap partition is lost. The swap partition can be lost if, in boot from SAN environments, you configure swap on a local disk and then replace the local disk.




VMware ESX Server 3.5.x
VMware ESX Server 3.0.x
VMware ESX 4.0.x


If no swap partitions were configured during ESX install, you can only create a swap partition if there is free, unpartitioned space on the hard disk.
Note: If you have free space on the local disk, start from step 2. Ensure that the partition number created is used for the specified commands.
If the swap partition is lost, perform these steps to identify the correct disk and create a fresh swap partition:
  1. Identify the correct disk
    1. Login to the ESX host using vSphere Client.
    2. Select the ESX host, then click Configuration > Storage Adapters tab.
    3. Determine the controller to which the local disk is attached and note the LUN ID using the runtime name (for example, vmhba0:0:0).
    4. Log in to the ESX Service Console as root.
    5. Run this command and find the device the LUN is mapped to (for example, /dev/sda):

      esxcfg-vmhbadevs -q (for ESX 3.x)
      esxcfg-scsidevs -c (for ESX 4.0)
  2. Create a swap partition of size 2 GB.
    1. Run this command:

      fdisk -u /dev/sda

    2. Press n to add a new partition.
    3. Press p to add a primary partition (if you are already using 3 primary partitions, press e for extended partition)
    4. Select partition 1.
    5. Accept the default start sector (63). The end sector value for 2 GB size is 4194304.
    6. Press t to select the type of file system.
    7. Select 82 for Linux Swap.
    8. Press w to save and exit.
  3. Run this command to create a swap file system on this partition:

    mkswap /dev/sda1
  4. Run this command to activate the swap:

    swapon /dev/sda1
  5. Run one of these commands to to verify that the swap is active:
    • free -m
    • top