| Storage Administration GuidePart II. Storage AdministrationThe Storage Administration section starts with storage considerations for Red Hat Enterprise Linux 6. Instructions regarding partitions, logical volume management, and swap partitions follow this. Disk Quotas, RAID systems are next, followed by the functions of mount command, volume_key, and acls. SSD tuning, write barriers, I/O limits and diskless systems follow this. The large chapter of Online Storage is next, and finally device mapper multipathing and virtual storage to finish. Use the following Daftar Isi to explore these Storage Administration tasks. Chapter 11. Storage Considerations During InstallationMany storage device and file system settings can only be configured at install time. Other settings, such as file system type, can only be modified up to a certain point without requiring a reformat. As such, it is prudent that you plan your storage configuration accordingly before installing Red Hat Enterprise Linux 6. This chapter discusses several considerations when planning a storage configuration for your system. For actual installation instructions (including storage configuration during installation), refer to the Installation Guide provided by Red Hat. 11.1. Updates to Storage Configuration During InstallationInstallation configuration for the following settings/devices has been updated for Red Hat Enterprise Linux 6: - Basic Path
For systems that only use locally attached disks and firmware RAID arrays as storage devices - Advanced Path
For systems that use SAN (e.g. multipath, iSCSI, FCoE) devices
11.2. Overview of Supported File SystemsThis section shows basic technical information on each file system supported by Red Hat Enterprise Linux 6. Table 11.1. Technical Specifications of Supported File Systems The listed maximum file and file system sizes are what Red Hat has tested and supports. This does not take into account the theoretical maximum limits. Both the maximum supported size and maximum file offset columns assume 4k blocks. 11.3. Special ConsiderationsThis section enumerates several issues and factors to consider for specific storage configurations. Separate Partitions for /home, /opt, /usr/localIf it is likely that you will upgrade your system in the future, place /home , /opt , and /usr/local on a separate device. This will allow you to reformat the devices/file systems containing the operating system while preserving your user and application data. DASD and zFCP Devices on IBM System ZOn the IBM System Z platform, DASD and zFCP devices are configured via the Channel Command Word (CCW) mechanism. CCW paths must be explicitly added to the system and then brought online. For DASD devices, this is simply means listing the device numbers (or device number ranges) as the DASD= parameter at the boot command line or in a CMS configuration file. For zFCP devices, you must list the device number, logical unit number (LUN), and world wide port name (WWPN). Once the zFCP device is initialized, it is mapped to a CCW path. The FCP_x= lines on the boot command line (or in a CMS configuration file) allow you to specify this information for the installer. Encrypting Block Devices Using LUKSFormatting a block device for encryption using LUKS/dm-crypt will destroy any existing formatting on that device. As such, you should decide which devices to encrypt (if any) before the new system's storage configuration is activated as part of the installation process. Moving a disk from a system configured for firmware RAID without removing the RAID metadata from the disk can prevent Anaconda from correctly detecting the disk. Removing/deleting RAID metadata from disk could potentially destroy any stored data. Red Hat recommends that you back up your data before proceeding. To delete RAID metadata from the disk, use the following command: dmraid -r -E /device /
iSCSI Detection and ConfigurationFor plug and play detection of iSCSI drives, configure them in the firmware of an iBFT boot-capable network interface card (NIC). CHAP authentication of iSCSI targets is supported during installation. However, iSNS discovery is not supported during installation. FCoE Detection and ConfigurationFor plug and play detection of fibre-channel over ethernet (FCoE) drives, configure them in the firmware of an EDD boot-capable NIC. Direct-access storage devices (DASD) cannot be added/configured during installation. Such devices are specified in the CMS configuration file. Block Devices with DIF/DIX EnabledDIF/DIX is a hardware checksum feature provided by certain SCSI host bus adapters and block devices. When DIF/DIX is enabled, errors will occur if the block device is used as a general-purpose block device. Buffered I/O or mmap(2) -based I/O will not work reliably, as there are no interlocks in the buffered write path to prevent buffered data from being overwritten after the DIF/DIX checksum has been calculated. This will cause the I/O to later fail with a checksum error. This problem is common to all block device (or file system-based) buffered I/O or mmap(2) I/O, so it is not possible to work around these errors caused by overwrites. As such, block devices with DIF/DIX enabled should only be used with applications that use O_DIRECT . Such applications should use the raw block device. Alternatively, it is also safe to use the XFS file system on a DIF/DIX enabled block device, as long as only O_DIRECT I/O is issued through the file system. XFS is the only file system that does not fall back to buffered I/O when doing certain allocation operations. The responsibility for ensuring that the I/O data does not change after the DIF/DIX checksum has been computed always lies with the application, so only applications designed for use with O_DIRECT I/O and DIF/DIX hardware should use DIF/DIX. The utility parted allows users to: View the existing partition table Change the size of existing partitions Add partitions from free space or additional hard drives
By default, the parted package is included when installing Red Hat Enterprise Linux. To start parted , log in as root and type the command parted /dev/sda at a shell prompt (where /dev/sda is the device name for the drive you want to configure). If you want to remove or resize a partition, the device on which that partition resides must not be in use. Creating a new partition on a device which is in use-while possible-is not recommended. For a device to not be in use, none of the partitions on the device can be mounted, and any swap space on the device must not be enabled. As well, the partition table should not be modified while it is in use because the kernel may not properly recognize the changes. If the partition table does not match the actual state of the mounted partitions, information could be written to the wrong partition, resulting in lost and overwritten data. The easiest way to achieve this it to boot your system in rescue mode. When prompted to mount the file system, select Skip. Alternately, if the drive does not contain any partitions in use (system processes that use or lock the file system from being unmounted), you can unmount them with the umount command and turn off all the swap space on the hard drive with the swapoff command. Table 12.1, "parted commands" contains a list of commonly used parted commands. The sections that follow explain some of these commands and arguments in more detail. Table 12.1. parted commands Command | Description |
---|
check minor-num | Perform a simple check of the file system | cp from to | Copy file system from one partition to another; from and to are the minor numbers of the partitions | help | Display list of available commands | mklabel label | Create a disk label for the partition table | mkfs minor-num file-system-type | Create a file system of type file-system-type | mkpart part-type fs-type start-mb end-mb | Make a partition without creating a new file system | mkpartfs part-type fs-type start-mb end-mb | Make a partition and create the specified file system | move minor-num start-mb end-mb | Move the partition | name minor-num name | Name the partition for Mac and PC98 disklabels only | print | Display the partition table | quit | Quit parted | rescue start-mb end-mb | Rescue a lost partition from start-mb to end-mb | resize minor-num start-mb end-mb | Resize the partition from start-mb to end-mb | rm minor-num | Remove the partition | select device | Select a different device to configure | set minor-num flag state | Set the flag on a partition; state is either on or off | toggle [NUMBER [FLAG ] | Toggle the state of FLAG on partition NUMBER | unit UNIT | Set the default unit to UNIT |
12.1. Viewing the Partition TableAfter starting parted , use the command print to view the partition table. A table similar to the following appears: Example 12.1. Partition table Model: ATA ST3160812AS (scsi)Disk /dev/sda: 160GBSector size (logical/physical): 512B/512BPartition Table: msdosNumber Start End Size Type File system Flags 1 32.3kB 107MB 107MB primary ext3 boot 2 107MB 105GB 105GB primary ext3 3 105GB 107GB 2147MB primary linux-swap 4 107GB 160GB 52.9GB extended root 5 107GB 133GB 26.2GB logical ext3 6 133GB 133GB 107MB logical ext3 7 133GB 160GB 26.6GB logical lvm The first line contains the disk type, manufacturer, model number and interface, and the second line displays the disk label type. The remaining output below the fourth line shows the partition table. In the partition table, the Minor number is the partition number . For example, the partition with minor number 1 corresponds to /dev/sda1 . The Start and End values are in megabytes. Valid Type are metadata, free, primary, extended, or logical. The Filesystem is the file system type, which can be any of the following: ext2 ext3 fat16 fat32 hfs jfs linux-swap ntfs reiserfs hp-ufs sun-ufs xfs
If a Filesystem of a device shows no value, this means that its file system type is unknown. The Flags column lists the flags set for the partition. Available flags are boot, root, swap, hidden, raid, lvm, or lba. To select a different device without having to restart parted , use the select command followed by the device name (for example, /dev/sda ). Doing so allows you to view or configure the partition table of a device. 12.2. Creating a PartitionDo not attempt to create a partition on a device that is in use. Procedure 12.1. Creating a partition Before creating a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device). Start parted , where /dev/sda is the device on which to create the partition: # parted /dev/sda
View the current partition table to determine if there is enough free space: # print
12.2.1. Making the PartitionFrom the partition table, determine the start and end points of the new partition and what partition type it should be. You can only have four primary partitions (with no extended partition) on a device. If you need more than four partitions, you can have three primary partitions, one extended partition, and multiple logical partitions within the extended. For an overview of disk partitions, refer to the appendix An Introduction to Disk Partitions in the Red Hat Enterprise Linux 6 Installation Guide. For example, to create a primary partition with an ext3 file system from 1024 megabytes until 2048 megabytes on a hard drive type the following command: # mkpart primary ext3 1024 2048
If you use the mkpartfs command instead, the file system is created after the partition is created. However, parted does not support creating an ext3 file system. Thus, if you wish to create an ext3 file system, use mkpart and create the file system with the mkfs command as described later. The changes start taking place as soon as you press Enter, so review the command before executing to it. After creating the partition, use the print command to confirm that it is in the partition table with the correct partition type, file system type, and size. Also remember the minor number of the new partition so that you can label any file systems on it. You should also view the output of cat /proc/partitions after parted is closed to make sure the kernel recognizes the new partition. 12.2.2. Formatting and Labeling the PartitionTo format and label the partition use the following procedure: Procedure 12.2. Format and label the partition The partition still does not have a file system. To create one use the following command: # /sbin/mkfs -t ext3 /dev/sda6
Formatting the partition permanently destroys any data that currently exists on the partition. Next, give the file system on the partition a label. For example, if the file system on the new partition is /dev/sda6 and you want to label it /work , use: # e2label /dev/sda6 /work
By default, the installation program uses the mount point of the partition as the label to make sure the label is unique. You can use any label you want. Afterwards, create a mount point (e.g. /work ) as root. 12.2.3. Add to /etc/fstab As root, edit the /etc/fstab file to include the new partition using the partition's UUID. Use the command blkid -o list for a complete list of the partition's UUID, or blkid device for individual device details. The first column should contain UUID= followed by the file system's UUID. The second column should contain the mount point for the new partition, and the next column should be the file system type (for example, ext3 or swap). If you need more information about the format, read the man page with the command man fstab . If the fourth column is the word defaults , the partition is mounted at boot time. To mount the partition without rebooting, as root, type the command: mount /work
12.3. Removing a PartitionDo not attempt to remove a partition on a device that is in use. Procedure 12.3. Remove a partition Before removing a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device). Start parted , where /dev/sda is the device on which to remove the partition: # parted /dev/sda
View the current partition table to determine the minor number of the partition to remove: # print
Remove the partition with the command rm . For example, to remove the partition with minor number 3: # rm 3
The changes start taking place as soon as you press Enter, so review the command before committing to it. After removing the partition, use the print command to confirm that it is removed from the partition table. You should also view the output of /proc/partitions to make sure the kernel knows the partition is removed. # cat /proc/partitions
The last step is to remove it from the /etc/fstab file. Find the line that declares the removed partition, and remove it from the file.
12.4. Resizing a PartitionDo not attempt to resize a partition on a device that is in use. Procedure 12.4. Resize a partition Before resizing a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device). Start parted , where /dev/sda is the device on which to resize the partition: # parted /dev/sda
View the current partition table to determine the minor number of the partition to resize as well as the start and end points for the partition: # print
To resize the partition, use the resize command followed by the minor number for the partition, the starting place in megabytes, and the end place in megabytes. Example 12.2. Resize a partition For example: resize 3 1024 2048
A partition cannot be made larger than the space available on the device After resizing the partition, use the print command to confirm that the partition has been resized correctly, is the correct partition type, and is the correct file system type. After rebooting the system into normal mode, use the command df to make sure the partition was mounted and is recognized with the new size.
Chapter 13. LVM (Logical Volume Manager)LVM is a tool for logical volume management which includes allocating disks, striping, mirroring and resizing logical volumes. With LVM, a hard drive or set of hard drives is allocated to one or more physical volumes. LVM physical volumes can be placed on other block devices which might span two or more disks. The physical volumes are combined into logical volumes, with the exception of the /boot/ partition. The /boot/ partition cannot be on a logical volume group because the boot loader cannot read it. If the root (/ ) partition is on a logical volume, create a separate /boot/ partition which is not a part of a volume group. Since a physical volume cannot span over multiple drives, to span over more than one drive, create one or more physical volumes per drive. The volume groups can be divided into logical volumes, which are assigned mount points, such as /home and / and file system types, such as ext2 or ext3. When "partitions" reach their full capacity, free space from the volume group can be added to the logical volume to increase the size of the partition. When a new hard drive is added to the system, it can be added to the volume group, and partitions that are logical volumes can be increased in size. On the other hand, if a system is partitioned with the ext3 file system, the hard drive is divided into partitions of defined sizes. If a partition becomes full, it is not easy to expand the size of the partition. Even if the partition is moved to another hard drive, the original hard drive space has to be reallocated as a different partition or not used. This chapter on LVM/LVM2 focuses on the use of the LVM GUI administration tool, i.e. system-config-lvm . For comprehensive information on the creation and configuration of LVM partitions in clustered and non-clustered storage, please refer to the Logical Volume Manager Administration guide also provided by Red Hat. In addition, the Installation Guide for Red Hat Enterprise Linux 6 also documents how to create and configure LVM logical volumes during installation. For more information, refer to the Create LVM Logical Volume section of the Installation Guide for Red Hat Enterprise Linux 6. LVM version 2, or LVM2, was the default for Red Hat Enterprise Linux 5, which uses the device mapper driver contained in the 2.6 kernel. LVM2 can be upgraded from versions of Red Hat Enterprise Linux running the 2.4 kernel. 13.2. Using system-config-lvm The LVM utility allows you to manage logical volumes within X windows or graphically. It does not come pre-installed, so to install it first run: # yum install system-config-lvm You can then access the application by selecting from your menu panel > > . Alternatively you can start the Logical Volume Management utility by typing system-config-lvm from a terminal. In the example used in this section, the following are the details for the volume group that was created during the installation: Example 13.1. Creating a volume group at installation /boot - (Ext3) file system. Displayed under 'Uninitialized Entities'. (DO NOT initialize this partition).LogVol00 - (LVM) contains the (/) directory (312 extents).LogVol02 - (LVM) contains the (/home) directory (128 extents).LogVol03 - (LVM) swap (28 extents). The logical volumes above were created in disk entity /dev/hda2 while /boot was created in /dev/hda1 . The system also consists of 'Uninitialised Entities' which are illustrated in Example 13.2, "Uninitialized entries". The figure below illustrates the main window in the LVM utility. The logical and the physical views of the above configuration are illustrated below. The three logical volumes exist on the same physical volume (hda2). The figure below illustrates the physical view for the volume. In this window, you can select and remove a volume from the volume group or migrate extents from the volume to another volume group. Steps to migrate extents are discussed in Figure 13.10, "Migrate Extents". The figure below illustrates the logical view for the selected volume group. The individual logical volume sizes are also illustrated. On the left side column, you can select the individual logical volumes in the volume group to view more details about each. In this example the objective is to rename the logical volume name for 'LogVol03' to 'Swap'. To perform this operation select the respective logical volume from the list (as opposed to the image) and click on the Edit Properties button. This will display the Edit Logical Volume window from which you can modify the Logical volume name, size (in extents, gigabytes, megabytes, or kilobytes) and also use the remaining space available in a logical volume group. The figure below illustrates this. Please note that this logical volume cannot be changed in size as there is currently no free space in the volume group. If there was remaining space, this option would be enabled (see Figure 13.17, "Edit logical volume"). Click on the OK button to save your changes (this will remount the volume). To cancel your changes click on the Cancel button. To revert to the last snapshot settings click on the Revert button. A snapshot can be created by clicking on the Create Snapshot button on the LVM utility window. If the selected logical volume is in use by the system (for example) the / (root) directory, this task will not be successful as the volume cannot be unmounted. 13.2.1. Utilizing Uninitialized Entities'Uninitialized Entities' consist of unpartitioned space and non LVM file systems. In this example partitions 3, 4, 5, 6 and 7 were created during installation and some unpartitioned space was left on the hard disk. Please view each partition and ensure that you read the 'Properties for Disk Entity' on the right column of the window to ensure that you do not delete critical data. In this example partition 1 cannot be initialized as it is /boot . Uninitialized entities are illustrated below. Example 13.2. Uninitialized entries In this example, partition 3 will be initialized and added to an existing volume group. To initialize a partition or unpartioned space, select the partition and click on the Initialize Entity button. Once initialized, a volume will be listed in the 'Unallocated Volumes' list. 13.2.2. Adding Unallocated Volumes to a Volume GroupOnce initialized, a volume will be listed in the 'Unallocated Volumes' list. The figure below illustrates an unallocated partition (Partition 3). The respective buttons at the bottom of the window allow you to: create a new volume group, add the unallocated volume to an existing volume group, remove the volume from LVM.
To add the volume to an existing volume group, click on the Add to Existing Volume Group button. Clicking on the Add to Existing Volume Group button will display a pop up window listing the existing volume groups to which you can add the physical volume you are about to initialize. A volume group may span across one or more hard disks. Example 13.3. Add a physical volume to volume group In this example only one volume group exists as illustrated below. Once added to an existing volume group the new logical volume is automatically added to the unused space of the selected volume group. You can use the unused space to: create a new logical volume (click on the Create New Logical Volume(s) button), select an existing logical volume and remove it from the volume group by clicking on the Remove Selected Logical Volume(s) button. Please note that you cannot select unused space to perform this operation.
The figure below illustrates the logical view of 'VolGroup00' after adding the new volume group. In the figure below, the uninitialized entities (partitions 3, 5, 6 and 7) were added to 'VolGroup00'. 13.2.3. Migrating ExtentsTo migrate extents from a physical volume, select the volume from the list in the left pane, highlight the desired extents in the central window, and click on the Migrate Selected Extent(s) From Volume button. Please note that you need to have a sufficient number of free extents to migrate extents within a volume group. An error message will be displayed if you do not have a sufficient number of free extents. To resolve this problem, please extend your volume group (see Section 13.2.6, "Extending a Volume Group"). If a sufficient number of free extents is detected in the volume group, a pop up window will be displayed from which you can select the destination for the extents or automatically let LVM choose the physical volumes (PVs) to migrate them to. This is illustrated below. The figure below illustrates a migration of extents in progress. In this example, the extents were migrated to 'Partition 3'. Once the extents have been migrated, unused space is left on the physical volume. The figure below illustrates the physical and logical view for the volume group. Please note that the extents of LogVol00 which were initially in hda2 are now in hda3. Migrating extents allows you to move logical volumes in case of hard disk upgrades or to manage your disk space better. 13.2.4. Adding a New Hard Disk Using LVMIn this example, a new IDE hard disk was added. The figure below illustrates the details for the new hard disk. From the figure below, the disk is uninitialized and not mounted. To initialize a partition, click on the Initialize Entity button. For more details, see Section 13.2.1, "Utilizing Uninitialized Entities". Once initialized, LVM will add the new volume to the list of unallocated volumes as illustrated in Example 13.4, "Create a new volume group". 13.2.5. Adding a New Volume GroupOnce initialized, LVM will add the new volume to the list of unallocated volumes where you can add it to an existing volume group or create a new volume group. You can also remove the volume from LVM. The volume if removed from LVM will be listed in the list of 'Uninitialized Entities' as illustrated in Figure 13.13, "Uninitialized hard disk". Example 13.4. Create a new volume group In this example, a new volume group was created as illustrated below. Once created a new volume group will be displayed in the list of existing volume groups as illustrated below. The logical view will display the new volume group with unused space as no logical volumes have been created. To create a logical volume, select the volume group and click on the Create New Logical Volume button as illustrated below. Please select the extents you wish to use on the volume group. Example 13.5. Select the extents In this example, all the extents in the volume group were used to create the new logical volume. The figure below illustrates the physical view of the new volume group. The new logical volume named 'Backups' in this volume group is also listed. 13.2.6. Extending a Volume GroupIn this example, the objective was to extend the new volume group to include an uninitialized entity (partition). This was to increase the size or number of extents for the volume group. To extend the volume group, ensure that on the left pane the Physical View option is selected within the desired Volume Group. Then click on the Extend Volume Group button. This will display the 'Extend Volume Group' window as illustrated below. On the 'Extend Volume Group' window, you can select disk entities (partitions) to add to the volume group. Please ensure that you check the contents of any 'Uninitialized Disk Entities' (partitions) to avoid deleting any critical data (see Figure 13.13, "Uninitialized hard disk"). In the example, the disk entity (partition) /dev/hda6 was selected as illustrated below. Once added, the new volume will be added as 'Unused Space' in the volume group. The figure below illustrates the logical and physical view of the volume group after it was extended. 13.2.7. Editing a Logical VolumeThe LVM utility allows you to select a logical volume in the volume group and modify its name, size and specify file system options. In this example, the logical volume named 'Backups" was extended onto the remaining space for the volume group. Clicking on the Edit Properties button will display the 'Edit Logical Volume' popup window from which you can edit the properties of the logical volume. On this window, you can also mount the volume after making the changes and mount it when the system is rebooted. Please note that you should indicate the mount point. If the mount point you specify does not exist, a popup window will be displayed prompting you to create it. The 'Edit Logical Volume' window is illustrated below. If you wish to mount the volume, select the 'Mount' checkbox indicating the preferred mount point. To mount the volume when the system is rebooted, select the 'Mount when rebooted' checkbox. In this example, the new volume will be mounted in /mnt/backups . This is illustrated in the figure below. The figure below illustrates the logical and physical view of the volume group after the logical volume was extended to the unused space. Please note in this example that the logical volume named 'Backups' spans across two hard disks. A volume can be stripped across two or more physical devices using LVM. Use these sources to learn more about LVM. rpm -qd lvm2 - This command shows all the documentation available from the lvm package, including man pages.
lvm help - This command shows all LVM commands available.
14.1. What is Swap Space?Swap space in Linux is used when the amount of physical memory (RAM) is full. If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. While swap space can help machines with a small amount of RAM, it should not be considered a replacement for more RAM. Swap space is located on hard drives, which have a slower access time than physical memory. Swap space can be a dedicated swap partition (recommended), a swap file, or a combination of swap partitions and swap files. Swap should equal 2x physical RAM for up to 2 GB of physical RAM, and then an additional 1x physical RAM for any amount above 2 GB, but never less than 32 MB. Example 14.1. Swap RAM So, if: M = Amount of RAM in GB, and S = Amount of swap in GB, then If M < 2S = M *2ElseS = M + 2 Using this formula, a system with 2 GB of physical RAM would have 4 GB of swap, while one with 3 GB of physical RAM would have 5 GB of swap. Creating a large swap space partition can be especially helpful if you plan to upgrade your RAM at a later time. For systems with really large amounts of RAM (more than 32 GB) you can likely get away with a smaller swap partition (around 1x, or less, of physical RAM). File systems and LVM2 volumes assigned as swap space should not be in use when being modified. Any attempts to modify swap will fail if a system process or the kernel is using swap space. Use the free and cat /proc/swaps commands to verify how much and where swap is in use. Red Hat advises that you modify swap space while the system is booted in rescue mode; for instructions on how to boot in rescue mode, refer to the Installation Guide. When prompted to mount the file system, select Skip. Sometimes it is necessary to add more swap space after installation. For example, you may upgrade the amount of RAM in your system from 1 GB to 2 GB, but there is only 2 GB of swap space. It might be advantageous to increase the amount of swap space to 4 GB if you perform memory-intense operations or run applications that require a large amount of memory. You have three options: create a new swap partition, create a new swap file, or extend swap on an existing LVM2 logical volume. It is recommended that you extend an existing logical volume. 14.2.1. Extending Swap on an LVM2 Logical VolumeBy default, Red Hat Enterprise Linux 6 uses all available space during installation. If this is the case with your system, then you must first add a new physical volume to the volume group used by the swap space. For instructions on how to do so, refer to Section 13.2.2, "Adding Unallocated Volumes to a Volume Group". After adding additional storage to the swap space's volume group, it is now possible to extend it. To do so, perform the following procedure (assuming /dev/VolGroup00/LogVol01 is the volume you want to extend by 2 GB): Procedure 14.1. Extending Swap on an LVM2 Logical Volume Disable swapping for the associated logical volume: # swapoff -v /dev/VolGroup00/LogVol01 Resize the LVM2 logical volume by 2 GB: # lvresize /dev/VolGroup00/LogVol01 -L +2G Format the new swap space: # mkswap /dev/VolGroup00/LogVol01 Enable the extended logical volume: # swapon -v /dev/VolGroup00/LogVol01
To test if the logical volume was successfully extended, use cat /proc/swaps or free to inspect the swap space. 14.2.2. Creating an LVM2 Logical Volume for SwapTo add a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to add): Create the LVM2 logical volume of size 2 GB: # lvcreate VolGroup00 -n LogVol02 -L 2G Format the new swap space: # mkswap /dev/VolGroup00/LogVol02 Add the following entry to the /etc/fstab file: # /dev/VolGroup00/LogVol02 swap swap defaults 0 0 Enable the extended logical volume: # swapon -v /dev/VolGroup00/LogVol02
To test if the logical volume was successfully created, use cat /proc/swaps or free to inspect the swap space. 14.2.3. Creating a Swap FileTo add a swap file: Procedure 14.2. Add a swap file Determine the size of the new swap file in megabytes and multiply by 1024 to determine the number of blocks. For example, the block size of a 64 MB swap file is 65536. At a shell, type the following command with count being equal to the desired block size: # dd if=/dev/zero of=/swapfile bs=1024 count=65536 Setup the swap file with the command: # mkswap /swapfile To enable the swap file immediately but not automatically at boot time: # swapon /swapfile To enable it at boot time, edit /etc/fstab to include the following entry: /swapfile swap swap defaults 0 0
The next time the system boots, it enables the new swap file.
To test if the new swap file was successfully created, use cat /proc/swaps or free to inspect the swap space. 14.3. Removing Swap SpaceSometimes it can be prudent to reduce swap space after installation. For example, say you downgraded the amount of RAM in your system from 1 GB to 512 MB, but there is 2 GB of swap space still assigned. It might be advantageous to reduce the amount of swap space to 1 GB, since the larger 2 GB could be wasting disk space. You have three options: remove an entire LVM2 logical volume used for swap, remove a swap file, or reduce swap space on an existing LVM2 logical volume. 14.3.1. Reducing Swap on an LVM2 Logical VolumeTo reduce an LVM2 swap logical volume (assuming /dev/VolGroup00/LogVol01 is the volume you want to reduce): Procedure 14.3. Reducing an LVM2 swap logical volume Disable swapping for the associated logical volume: # swapoff -v /dev/VolGroup00/LogVol01 Reduce the LVM2 logical volume by 512 MB: # lvreduce /dev/VolGroup00/LogVol01 -L -512M Format the new swap space: # mkswap /dev/VolGroup00/LogVol01 Enable the extended logical volume: # swapon -v /dev/VolGroup00/LogVol01
To test if the swap's logical volume size was successfully reduced, use cat /proc/swaps or free to inspect the swap space. 14.3.2. Removing an LVM2 Logical Volume for SwapTo remove a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to remove): Procedure 14.4. Remove a swap volume group Disable swapping for the associated logical volume: # swapoff -v /dev/VolGroup00/LogVol02 Remove the LVM2 logical volume of size 512 MB: # lvremove /dev/VolGroup00/LogVol02 Remove the following entry from the /etc/fstab file: /dev/VolGroup00/LogVol02 swap swap defaults 0 0
To test if the logical volume size was successfully removed, use cat /proc/swaps or free to inspect the swap space. 14.3.3. Removing a Swap FileTo remove a swap file: Procedure 14.5. Remove a swap file At a shell prompt, execute the following command to disable the swap file (where /swapfile is the swap file): # swapoff -v /swapfile Remove its entry from the /etc/fstab file. Remove the actual file: # rm /swapfile
To move swap space from one location to another, follow the steps for removing swap space, and then follow the steps for adding swap space. |
| |