LVM logical volume and management swap space for Linux

Source: Internet
Author: User

LVM logical Volumes

1. Manage the scattered space.

2. Expansion and reduction of logical volume dynamics.

First, a number of physical volumes (PV) are formed into a volume group (VG),

The logical volume (LV) is then divided from the volume group.

Command: Create creation

Extend extension

Vgcreate Volume Group name partition

PVS displays physical volume basic information

VGS Display Volume Group basic information

LVS Display Logical Volume basic information

First, create physical volumes and volume groups

Format: vgcreate volume Group name partition

Example: Vgcreate myvg/dev/sda[1-3]

Creating a volume group physical volume directly can be formed.


Ii. Creating a logical volume

Format: lvcreate-l Logical Volume Size-n Logical volume name of the volume group

Example: Lvcreate-l 16g-n mylv MYVG

Third, use the logical volume LV

Example: MKDIR/LVLV

Vim/etc/fstab

/DEV/MYVG/MYLV/LVLV EXT4 Defaults 0 0

Mount-a

Df-h

Expansion of logical volumes

A logical volume extension that supports on-line operations.

One, the volume group has enough space left.

1. Directly extend the space of the logical volume

Example: VGS

Lvs

Lvextend-l 18G/DEV/MYVG/MYLV

2. Extending the file system

Extended Ext4 File system: RESIZE2FS partition

Extended XFS File system: XFS_GROWFS partition

Example: RESIZE2FS/DEV/MYVG/MYLV

Df-h

Second, the volume group does not have enough space left

1. Expand the volume group first

Format: Vgextend Extended volume Group name partition

Example: Vgextend myvg/dev/sda5

2. Extending the space of a logical volume group

Example: Lvextend-l 25g/dev/myvg/mylv

3. Extended File System size

Example: RESIZE2FS/DEV/MYVG/MYLV

Settings for PE

PE: The unit of volume group partition space, default 4M.

Function: The size of the logical volume can be created more precisely.

To set the size of a PE when creating a volume group

Format: vgcreate-s PE size Volume group name partition

Lvcreate-l PE number-n test Volume group name

Vgchange-s PE Size Volume group name (Modify PE size)

Example: Vgchange-s 2M MYVG

Lvcreate-l 50-n Test MYVG


Managing swap space (equivalent to virtual memory)

When physical memory is insufficient, use disk space to simulate memory.

To some extent, alleviate the problem of insufficient memory.

Swap partition: Swap space acting as an idle partition

Command:

MKSWAP partition Format Swap command

Example: Mkswap/dev/sda6

Swapon-s View Swap command

SWAPON/DEV/SDA6 Enable swap space

SWAPOFF/DEV/SDA7 Deactivate swap Space

SWAPON-A is designed to detect swap mounts

Auto mount on Boot

Example: Vim/etc/fstab

/dev/sda6 swap swap Defautls 0 0

Swapon-a

Swapon-s

LVM logical volume and management swap space for Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.