1 - 2 IT Essentials II v2.0 - Lab 7.2.6 Copyright 2002, Cisco Systems, Inc. Lab 7.2.6: AddingSwapFileSpaceinaLinuxSystem Estimated Time: 20 minutes Objective To assess and add swapspaceinaLinux Red Hat operating system. Equipment • A computer with Linux Red Hat 7.X installed Scenario The system administrator of a large company notices that one of the Linux Apache Web servers for the internal company Web site has been running slowly, and most of its resources have been used up. Most of the IT budget for the year has been spent. Therefore, adding more RAM is not an option. The administrator decides to add more swapspace to the server instead. Procedures Step 1: Assessing swap usage In order to determine how much swapspace to add, first look at the size of some files on the system. Determine how much memory is being used and how much is left on the system. The free command inLinux can be used to check the system memory. Type free –m –t at the shell prompt. How much physical memory is available? How much physical memory is being used? __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ __________________________________________________________________ 2 - 2 IT Essentials II v2.0 - Lab 7.2.6 Copyright 2002, Cisco Systems, Inc. Step 2: Addingaswapfile To add swapspace on a system, add aswapfile by using the following steps: 1. Create afile that is equal in size to the swapfile that is going to be created. Do this by using the dd command. Enter the following command at the shell prompt: dd if=/dev/zero of=swap.swp bs=1024 count=131072 2. The swap.swp file that was created will need to be initialized. When it is initialized, the Linuxsystem can use it to swap memory to a disk. Use the mkswap command to enable Linux to use the new swap file. However, the new swapfile will not be active. Enter the following command at the shell prompt: mkswap –f /root/swap.swp or type /sbin/mkswap –f /root/swap.swp 3. To activate this swap file, use the swapon command. To make this swapfile inactive, use the swapoff command in place of the swapon command. Enter the following command at the shell prompt: swapon /root/swap.swp or type /sbin/swapon /root/swap.swp The swapfile that was just created will not be used the next time the system is rebooted unless the entry in made in /etc/fstab. Reflection This method is the quickest and easiest way to add swap space. However, it does create some problems. By creating this swapfile on a partition that is already being used, the file can become fragmented as the partition gets used more and more. What are some other methods that can be used to add aswap file? . To assess and add swap space in a Linux Red Hat operating system. Equipment • A computer with Linux Red Hat 7.X installed Scenario The system administrator. Essentials II v2.0 - Lab 7.2.6 Copyright 2002, Cisco Systems, Inc. Step 2: Adding a swap file To add swap space on a system, add a swap file by using the