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:
- Identify the correct disk
- Login to the ESX host using vSphere Client.
- Select the ESX host, then click Configuration > Storage Adapters tab.
- Determine the controller to which the local disk is attached and note the LUN ID using the runtime name (for example, vmhba0:0:0).
- Log in to the ESX Service Console as root.
- 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)
- Create a swap partition of size 2 GB.
-
- Run this command:
fdisk -u /dev/sda
- Press n to add a new partition.
- Press p to add a primary partition (if you are already using 3 primary partitions, press e for extended partition)
- Select partition 1.
- Accept the default start sector (63). The end sector value for 2 GB size is 4194304.
- Press t to select the type of file system.
- Select 82 for Linux Swap.
- Press w to save and exit.
- Run this command to create a swap file system on this partition:
mkswap /dev/sda1
- Run this command to activate the swap:
swapon /dev/sda1
- Run one of these commands to to verify that the swap is active:
-