Cari di RHE Linux 
    RHE Linux User Manual
Daftar Isi
(Sebelumnya) 20 : Chapter 10. FS-Cache - St ...20 : Chapter 15. Disk Quotas - ... (Berikutnya)

Storage Administration Guide

Part II. Storage Administration

The 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.

Daftar Isi

11. Storage Considerations During Installation
11.1. Updates to Storage Configuration During Installation
11.2. Overview of Supported File Systems
11.3. Special Considerations
12. Partitions
12.1. Viewing the Partition Table
12.2. Creating a Partition
12.2.1. Making the Partition
12.2.2. Formatting and Labeling the Partition
12.2.3. Add to /etc/fstab
12.3. Removing a Partition
12.4. Resizing a Partition
13. LVM (Logical Volume Manager)
13.1. What is LVM2?
13.2. Using system-config-lvm
13.2.1. Utilizing Uninitialized Entities
13.2.2. Adding Unallocated Volumes to a Volume Group
13.2.3. Migrating Extents
13.2.4. Adding a New Hard Disk Using LVM
13.2.5. Adding a New Volume Group
13.2.6. Extending a Volume Group
13.2.7. Editing a Logical Volume
13.3. References
14. Swap Space
14.1. What is Swap Space?
14.2. Adding Swap Space
14.2.1. Extending Swap on an LVM2 Logical Volume
14.2.2. Creating an LVM2 Logical Volume for Swap
14.2.3. Creating a Swap File
14.3. Removing Swap Space
14.3.1. Reducing Swap on an LVM2 Logical Volume
14.3.2. Removing an LVM2 Logical Volume for Swap
14.3.3. Removing a Swap File
14.4. Moving Swap Space
15. Disk Quotas
15.1. Configuring Disk Quotas
15.1.1. Enabling Quotas
15.1.2. Remounting the File Systems
15.1.3. Creating the Quota Database Files
15.1.4. Assigning Quotas per User
15.1.5. Assigning Quotas per Group
15.1.6. Setting the Grace Period for Soft Limits
15.2. Managing Disk Quotas
15.2.1. Enabling and Disabling
15.2.2. Reporting on Disk Quotas
15.2.3. Keeping Quotas Accurate
15.3. References
16. Redundant Array of Independent Disks (RAID)
16.1. What is RAID?
16.2. Who Should Use RAID?
16.3. RAID Types
16.4. RAID Levels and Linear Support
16.5. Linux RAID Subsystems
16.6. RAID Support in the Installer
16.7. Configuring RAID Sets
16.8. Advanced RAID Device Creation
17. Using the mount Command
17.1. Listing Currently Mounted File Systems
17.1.1. Specifying the File System Type
17.2. Mounting a File System
17.2.1. Specifying the File System Type
17.2.2. Specifying the Mount Options
17.2.3. Sharing Mounts
17.2.4. Moving a Mount Point
17.3. Unmounting a File System
17.4. Documentation
17.4.1. Manual Page Documentation
17.4.2. Useful Websites
18. The volume_key function
18.1. Commands
18.2. Using volume_key as an individual user
18.3. Using volume_key in a larger organization
18.3.1. Preparation for saving encryption keys
18.3.2. Saving encryption keys
18.3.3. Restoring access to a volume
18.3.4. Setting up emergency passphrases
18.4. Documentation
19. Access Control Lists
19.1. Mounting File Systems
19.1.1. NFS
19.2. Setting Access ACLs
19.3. Setting Default ACLs
19.4. Retrieving ACLs
19.5. Archiving File Systems With ACLs
19.6. Compatibility with Older Systems
19.7. References
20. Solid-State Disk Deployment Guidelines
20.1. Deployment Considerations
20.2. Tuning Considerations
21. Write Barriers
21.1. Importance of Write Barriers
21.2. Enabling/Disabling Write Barriers
21.3. Write Barrier Considerations
22. Storage I/O Alignment and Size
22.1. Parameters for Storage Access
22.2. Userspace Access
22.3. Standards
22.4. Stacking I/O Parameters
22.5. Logical Volume Manager
22.6. Partition and File System Tools
23. Setting Up A Remote Diskless System
23.1. Configuring a tftp Service for Diskless Clients
23.2. Configuring DHCP for Diskless Clients
23.3. Configuring an Exported File System for Diskless Clients
24. Online Storage Management
24.1. Fibre Channel
24.1.1. Fibre Channel API
24.1.2. Native Fibre Channel Drivers and Capabilities
24.2. iSCSI
24.2.1. iSCSI API
24.2.2. iSCSI Target Setup
24.3. Persistent Naming
24.3.1. WWID
24.3.2. UUID and Other Persistent Identifiers
24.4. Removing a Storage Device
24.5. Removing a Path to a Storage Device
24.6. Adding a Storage Device or Path
24.7. Configuring a Fibre-Channel Over Ethernet Interface
24.7.1. Fibre-Channel over Ethernet (FCoE) Target Setup
24.8. Configuring an FCoE Interface to Automatically Mount at Boot
24.9. Scanning Storage Interconnects
24.10. iSCSI Discovery Configuration
24.11. Configuring iSCSI Offload and Interface Binding
24.11.1. Viewing Available iface Configurations
24.11.2. Configuring an iface for Software iSCSI
24.11.3. Configuring an iface for iSCSI Offload
24.11.4. Binding/Unbinding an iface to a Portal
24.12. Scanning iSCSI Interconnects
24.13. Logging In to an iSCSI Target
24.14. Resizing an Online Logical Unit
24.14.1. Resizing Fibre Channel Logical Units
24.14.2. Resizing an iSCSI Logical Unit
24.14.3. Updating the Size of Your Multipath Device
24.14.4. Changing the Read/Write State of an Online Logical Unit
24.15. Adding/Removing a Logical Unit Through rescan-scsi-bus.sh
24.16. Modifying Link Loss Behavior
24.16.1. Fibre Channel
24.16.2. iSCSI Settings With dm-multipath
24.16.3. iSCSI Root
24.17. Controlling the SCSI Command Timer and Device Status
24.18. Troubleshooting
25. Device Mapper Multipathing and Virtual Storage
25.1. Virtual Storage
25.2. DM-Multipath

Chapter 11.  Storage Considerations During Installation

Many 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 Installation

Installation configuration for the following settings/devices has been updated for Red Hat Enterprise Linux 6:
Fibre-Channel over Ethernet (FCoE)
Anaconda can now configure FCoE storage devices during installation.
Storage Device Filtering Interface
Anaconda now has improved control over which storage devices are used during installation. You can now control which devices are available/visible to the installer, in addition to which devices are actually used for system storage. There are two paths through device filtering:
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
Auto-partitioning and /home
Auto-partitioning now creates a separate logical volume for the /home file system when 50GB or more is available for allocation of LVM physical volumes. The root file system (/) will be limited to a maximum of 50GB when creating a separate /home logical volume, but the /home logical volume will grow to occupy all remaining space in the volume group.

11.2. Overview of Supported File Systems

This 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

File SystemMax Supported SizeMax File OffsetMax Subdirectories (per directory)Max Depth of Symbolic LinksACL SupportDetails
Ext28TB2TB32,0008YesN/A
Ext316TB2TB32,0008YesChapter 5, The Ext3 File System
Ext416TB16TB[a]Unlimited[b]8YesChapter 6, The Ext4 File System
XFS100TB100TB[c]Unlimited8YesChapter 8, The XFS File System
[a] This maximum file size is based on a 64-bit machine. On a 32-bit machine, the maximum files size is 8TB.
[b] When the link count exceeds 65,000, it is reset to 1 and no longer increases.
[c] This maximum file size is only on 64-bit machines. Red Hat Enterprise Linux does not support XFS on 32-bit machines.

Note: Maximum file and file system sizes

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 Considerations

This section enumerates several issues and factors to consider for specific storage configurations.

Separate Partitions for /home, /opt, /usr/local

If 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 Z

On 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 LUKS

Formatting 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.

Stale BIOS RAID Metadata

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.

Warning

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/
For more information about managing RAID devices, refer to man dmraid and Chapter 16, Redundant Array of Independent Disks (RAID).

iSCSI Detection and Configuration

For 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 Configuration

For plug and play detection of fibre-channel over ethernet (FCoE) drives, configure them in the firmware of an EDD boot-capable NIC.

DASD

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 Enabled

DIF/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.

Chapter 12. Partitions

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

CommandDescription
check minor-numPerform a simple check of the file system
cp from toCopy file system from one partition to another; from and to are the minor numbers of the partitions
helpDisplay list of available commands
mklabel labelCreate a disk label for the partition table
mkfs minor-num file-system-typeCreate a file system of type file-system-type
mkpart part-type fs-type start-mb end-mbMake a partition without creating a new file system
mkpartfs part-type fs-type start-mb end-mbMake a partition and create the specified file system
move minor-num start-mb end-mbMove the partition
name minor-num nameName the partition for Mac and PC98 disklabels only
printDisplay the partition table
quitQuit parted
rescue start-mb end-mbRescue a lost partition from start-mb to end-mb
resize minor-num start-mb end-mbResize the partition from start-mb to end-mb
rm minor-numRemove the partition
select deviceSelect a different device to configure
set minor-num flag stateSet the flag on a partition; state is either on or off
toggle [NUMBER [FLAG]Toggle the state of FLAG on partition NUMBER
unit UNITSet the default unit to UNIT

12.1. Viewing the Partition Table

After 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.

Note

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 Partition

Warning

Do not attempt to create a partition on a device that is in use.

Procedure 12.1. Creating a partition

  1. Before creating a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).
  2. Start parted, where /dev/sda is the device on which to create the partition:
    # parted /dev/sda
  3. View the current partition table to determine if there is enough free space:
    # print
If there is not enough free space, you can resize an existing partition. Refer to Section 12.4, "Resizing a Partition" for details.

12.2.1. Making the Partition

From 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

Note

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 Partition

To format and label the partition use the following procedure:

Procedure 12.2. Format and label the partition

  1. The partition still does not have a file system. To create one use the following command:
    # /sbin/mkfs -t ext3 /dev/sda6

    Warning

    Formatting the partition permanently destroys any data that currently exists on the partition.
  2. 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 Partition

Warning

Do not attempt to remove a partition on a device that is in use.

Procedure 12.3. Remove a partition

  1. Before removing a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).
  2. Start parted, where /dev/sda is the device on which to remove the partition:
    # parted /dev/sda
  3. View the current partition table to determine the minor number of the partition to remove:
    # print
  4. 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.
  5. 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
  6. 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 Partition

Warning

Do not attempt to resize a partition on a device that is in use.

Procedure 12.4. Resize a partition

  1. Before resizing a partition, boot into rescue mode (or unmount any partitions on the device and turn off any swap space on the device).
  2. Start parted, where /dev/sda is the device on which to resize the partition:
    # parted /dev/sda
  3. 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
  4. 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

    Warning

    A partition cannot be made larger than the space available on the device
  5. 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.
  6. 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.
Logical Volumes
LVM Group

Figure 13.1. Logical Volumes


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.
Logical Volumes
Logical Volumes

Figure 13.2. Logical Volumes


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.

Important

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.

13.1. What is LVM2?

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 System > Administration > Logical Volume Management. 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).
Main LVM Window
Main LVM Window

Figure 13.3. Main LVM Window


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".
Physical View Window
Physical View Window

Figure 13.4. Physical View Window


The figure below illustrates the logical view for the selected volume group. The individual logical volume sizes are also illustrated.
Logical View Window
Logical View Window

Figure 13.5. Logical View Window


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.
Edit Logical Volume
Edit Logical Volume

Figure 13.6. Edit Logical Volume


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

Uninitialized Entities
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 Group

Once 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.
Unallocated Volumes
Unallocated Volumes

Figure 13.7. Unallocated Volumes


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.
Add physical volume to volume group

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 one of the existing logical volumes and increase the extents (see Section 13.2.6, "Extending a Volume Group"),
  • 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.
Logical view of volume group
Logical view of volume group

Figure 13.8. Logical view of volume group


In the figure below, the uninitialized entities (partitions 3, 5, 6 and 7) were added to 'VolGroup00'.
Logical view of volume group
Logical view of volume group

Figure 13.9. Logical view of volume group


13.2.3. Migrating Extents

To 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.
Migrate Extents
Migrate Extents

Figure 13.10. Migrate Extents


The figure below illustrates a migration of extents in progress. In this example, the extents were migrated to 'Partition 3'.
Migrating extents in progress
Migrating extents in progress

Figure 13.11. Migrating extents in progress


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.
Logical and physical view of volume group
Logical and physical view of volume group

Figure 13.12. Logical and physical view of volume group


13.2.4. Adding a New Hard Disk Using LVM

In 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".
Uninitialized hard disk
Uninitialized hard disk

Figure 13.13. Uninitialized hard disk


13.2.5. Adding a New Volume Group

Once 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.
Create new volume group

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.
Create 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.
Physical view of new volume group
Physical view of new volume group

Figure 13.14. Physical view of new volume group


13.2.6. Extending a Volume Group

In 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.
Select disk entities
Select disk entities

Figure 13.15. Select disk entities


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.
Logical and physical view of an extended volume group
Logical and physical view of an extended volume group

Figure 13.16. Logical and physical view of an extended volume group


13.2.7. Editing a Logical Volume

The 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.
Edit logical volume
Edit logical volume

Figure 13.17. Edit logical volume


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.
Edit logical volume - specifying mount options
Edit logical volume - specifying mount options

Figure 13.18. Edit logical volume - specifying mount options


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.
Edit logical volume
Edit logical volume

Figure 13.19. Edit logical volume


13.3. References

Use these sources to learn more about LVM.

Installed Documentation

  • 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.

Useful Websites

Chapter 14. Swap Space

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).

Important

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.

14.2. Adding Swap Space

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 Volume

By 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

  1. Disable swapping for the associated logical volume:
    # swapoff -v /dev/VolGroup00/LogVol01
  2. Resize the LVM2 logical volume by 2 GB:
    # lvresize /dev/VolGroup00/LogVol01 -L +2G
  3. Format the new swap space:
    # mkswap /dev/VolGroup00/LogVol01
  4. 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 Swap

To add a swap volume group (assuming /dev/VolGroup00/LogVol02 is the swap volume you want to add):
  1. Create the LVM2 logical volume of size 2 GB:
    # lvcreate VolGroup00 -n LogVol02 -L 2G
  2. Format the new swap space:
    # mkswap /dev/VolGroup00/LogVol02
  3. Add the following entry to the /etc/fstab file:
    # /dev/VolGroup00/LogVol02 swap swap defaults 0 0
  4. 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 File

To add a swap file:

Procedure 14.2. Add a swap file

  1. 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.
  2. 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
  3. Setup the swap file with the command:
    # mkswap /swapfile
  4. To enable the swap file immediately but not automatically at boot time:
    # swapon /swapfile
  5. 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 Space

Sometimes 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 Volume

To 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

  1. Disable swapping for the associated logical volume:
    # swapoff -v /dev/VolGroup00/LogVol01
  2. Reduce the LVM2 logical volume by 512 MB:
    # lvreduce /dev/VolGroup00/LogVol01 -L -512M
  3. Format the new swap space:
    # mkswap /dev/VolGroup00/LogVol01
  4. 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 Swap

To 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

  1. Disable swapping for the associated logical volume:
    # swapoff -v /dev/VolGroup00/LogVol02
  2. Remove the LVM2 logical volume of size 512 MB:
    # lvremove /dev/VolGroup00/LogVol02
  3. 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 File

To remove a swap file:

Procedure 14.5. Remove a swap file

  1. At a shell prompt, execute the following command to disable the swap file (where /swapfile is the swap file):
    # swapoff -v /swapfile
  2. Remove its entry from the /etc/fstab file.
  3. Remove the actual file:
    # rm /swapfile

14.4. Moving Swap Space

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.
(Sebelumnya) 20 : Chapter 10. FS-Cache - St ...20 : Chapter 15. Disk Quotas - ... (Berikutnya)