LVM: Difference between revisions

From HPCWIKI
Jump to navigation Jump to search
(Created page with "LVM(Logical volume management) creates an easy to use layer over multiple physical disks. We can combine multiple disks and create logical storage volumes. LVM features are<ref>https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/</ref> # No restriction on disk size # Increased disk throughput # Mirroring volumes for business critical data # Volume snapshots # Easy backups and restores using snapshots # Easy data relocation # Re...")
 
(Fix: remove --- horizontal lines (7 removed))
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Status
|status=Draft
|owner=Knowledge Agent
|last_update=2026-07-16
|review=Pending
}}
{{TOC}}
== Overview ==
LVM에 대한 기술 문서입니다.
=== Summary ===
* 무엇인가? - LVM
* 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
* 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시
== Purpose ==
이 문서가 존재하는 이유
* Goal: LVM에 대한 기술 정보 제공
* Scope: LVM의 개념, 사용법, 설정
* Non-goals: 다른 주제로의 확장
== Key Concepts ==
{| class="wikitable"
! Concept
! Description
! Related
|-
| LVM
| HPC/서버 환경에서 중요한 기술 개념
| [[Linux]], [[Server]]
|}
== Detailed Explanation ==
LVM(Logical volume management) creates an easy to use layer over multiple physical disks. We can combine multiple disks and create logical storage volumes.  
LVM(Logical volume management) creates an easy to use layer over multiple physical disks. We can combine multiple disks and create logical storage volumes.  
LVM features are<ref>https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/</ref>
LVM features are<ref>https://www.cyberciti.biz/faq/howto-add-disk-to-lvm-volume-on-linux-to-increase-size-of-pool/</ref>
# No restriction on disk size
# No restriction on disk size
# Increased disk throughput
# Increased disk throughput
Line 10: Line 52:
# Easy data relocation
# Easy data relocation
# Resizing storage pools (add or remove disks) without reformatting disks
# Resizing storage pools (add or remove disks) without reformatting disks
== LVM Terminologies ==
{| class="wikitable"
{| class="wikitable"
!Type
!Type
Line 22: Line 62:
<code>$sudo pvs</code>
<code>$sudo pvs</code>
|-
|-
|'''Volume Groups (VG)'''  
|'''Volume Groups (VG)'''
|Physical volumes are combined into volume groups. (e.g. my_vg = /dev/sda + /dev/sdb.)
|
|-
|'''Logical Volumes (LV)'''
|A volume group is divided up into logical volumes
(e.g. my_vg divided into my_vg/data, my_vg/backups, my_vg/home, my_vg/mysqldb and so on)
|
|}


== Create LVM with two or more disk ==
<syntaxhighlight lang="bash">
    #assuming we have two device sdb and sdc
    _pvs=( /dev/sdb /dev/sdc )
    for _pv in "${_pvs[@]}"
    do 
        echo "Create PV (Physical Volume) : $_pv"
        pvcreate $_pv
    done


    # Create VG (Volume Group) using PVs
== Best Practices ==
    sudo vgcreate $_vgname /dev/sdb /dev/sdc


    # Create LV (Logical Volume) using VG
* 최신 버전 사용 권장
    sudo lvcreate -n $_lvname -l 100%free --wipesignatures y --yes --zero y $_vgname
* 공식 문서 참고
* 테스트 환경에서 먼저 검증


    # Format LVM Partition depending on the filesystem
    #sudo mkfs.ext4 /dev/$_vgname/$_lvname
    #sudo mkfs.xfs  /dev/$_vgname/$_lvname


    # mount LVS to mount point, example /mnt/storage
== References ==
    sudo mkdir -p /mnt/storage
    sudo mount /dev/$_vgname/$_lvname /mnt/storage
   
    # add LVM into fstab
    echo '/dev/$_vgname/$_lvname  /mnt/storage  ext4  defaults 0 0' | sudo  tee -a /etc/fstab
    sudo mount -a
</syntaxhighlight>
 
== Remove LVM ==
<syntaxhighlight lang="bash">
    #unmount before to remove
    sudo umount /mnt/storage


    #disable LVM
* [https://wiki.hpcmate.com LVM]
    sudo lvchange -an /dev/$_vgname/$_lvname
    #delete LVM
    sudo lvremove -f /dev/$_vgname/$_lvname


    #delete VGs
    sudo vgremove -f $_vgname


    # Delete physical volumes
== Related Pages ==
    _pvs=( /dev/sdb /dev/sdc )
    for _pv in "${_pvs[@]}"
    do
        echo "Delete PV (Physical Volume) : $_pv"
        sudo pvremove -f $_pv
    done
</syntaxhighlight>


== Display LVM status ==
* [[Linux]]
* [[Server]]
* [[Hardware]]
* [[Network]]


=== PV status ===
<syntaxhighlight lang="bash">
# pvs
  PV        VG  Fmt  Attr PSize  PFree
  /dev/sda3  rl  lvm2 a--  <2.00t    0
  /dev/sdb  vg01 lvm2 a--  <20.00g    0
  /dev/sdc  vg01 lvm2 a--  <10.00g    0


[[Category:Linux]]
== Knowledge Graph ==


# pvdisplay
Related
  --- Physical volume ---
  PV Name              /dev/sdb
  VG Name              vg01
  PV Size              20.00 GiB / not usable 4.00 MiB
  Allocatable          yes (but full)
  PE Size              4.00 MiB
  Total PE              5119
  Free PE              0
  Allocated PE          5119
  PV UUID              jkuGmw-Dcvm-GTo3-DMUj-h9xu-bG2I-l70qO0
 
  --- Physical volume ---
  PV Name              /dev/sdc
  VG Name              vg01
  PV Size              10.00 GiB / not usable 4.00 MiB
  Allocatable          yes (but full)
  PE Size              4.00 MiB
  Total PE              2559
  Free PE              0
  Allocated PE          2559
  PV UUID              zOtlUy-Gh4t-KIVd-DLaq-qS9X-7SN4-d634eV
 
  --- Physical volume ---
  PV Name              /dev/sda3
  VG Name              rl
  PV Size              <2.00 TiB / not usable 0 
  Allocatable          yes (but full)
  PE Size              4.00 MiB
  Total PE              524031
  Free PE              0
  Allocated PE          524031
  PV UUID              enc5P4-hS0a-Tdpx-SUVj-8BSf-hsnM-ClWfmH
</syntaxhighlight>


=== VG status ===
→ [[Linux]]
<syntaxhighlight lang="bash">
→ [[Server]]
# vgs
→ [[Hardware]]
  VG  #PV #LV #SN Attr  VSize  VFree
→ [[Network]]
  rl    1  3  0 wz--n- <2.00t    0
  vg01  2  1  0 wz--n- 29.99g    0


 
[[Category:Configuration]]
# vgdisplay
  --- Volume group ---
  VG Name              vg01
  System ID           
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  2
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                1
  Open LV              1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size              29.99 GiB
  PE Size              4.00 MiB
  Total PE              7678
  Alloc PE / Size      7678 / 29.99 GiB
  Free  PE / Size      0 / 0 
  VG UUID              QeeTHC-n8LG-5jqB-Z5yo-0cdg-f8Y5-dRJyjp
 
  --- Volume group ---
  VG Name              rl
  System ID           
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access            read/write
  VG Status            resizable
  MAX LV                0
  Cur LV                3
  Open LV              3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size              <2.00 TiB
  PE Size              4.00 MiB
  Total PE              524031
  Alloc PE / Size      524031 / <2.00 TiB
  Free  PE / Size      0 / 0 
  VG UUID              fVQYRJ-kNSC-XAec-TxNi-BF0U-GbIA-LaImvg
</syntaxhighlight>
 
=== LV status ===
<syntaxhighlight lang="bash">
# lvs
  LV  VG  Attr      LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home rl  -wi-ao---- <1.93t                                                   
  root rl  -wi-ao---- 70.00g                                                   
  swap rl  -wi-ao----  2.71g                                                   
  lv01 vg01 -wi-ao---- 29.99g 
 
# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vg01/lv01
  LV Name                lv01
  VG Name                vg01
  LV UUID                D6mc3r-lbtH-9gqc-3HjF-01Fg-7zrh-hPJzpC
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2024-01-11 01:28:30 -0500
  LV Status              available
  # open                1
  LV Size                29.99 GiB
  Current LE            7678
  Segments              2
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    8192
  Block device          253:3
 
  --- Logical volume ---
  LV Path                /dev/rl/swap
  LV Name                swap
  VG Name                rl
  LV UUID                cnVSkz-QhIp-UpeE-9Cb2-2neR-d6tc-YnJ5jy
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2024-01-10 21:19:57 -0500
  LV Status              available
  # open                2
  LV Size                2.71 GiB
  Current LE            695
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    8192
  Block device          253:1
 
  --- Logical volume ---
  LV Path                /dev/rl/home
  LV Name                home
  VG Name                rl
  LV UUID                eRA0eB-7PLr-JHaR-P8l7-UMoP-V1mz-eVVEJJ
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2024-01-10 21:19:58 -0500
  LV Status              available
  # open                1
  LV Size                <1.93 TiB
  Current LE            505416
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    8192
  Block device          253:2
 
  --- Logical volume ---
  LV Path                /dev/rl/root
  LV Name                root
  VG Name                rl
  LV UUID                yRgfqu-8slv-AzW8-LaUp-Mkto-fSJh-MOIAG4
  LV Write Access        read/write
  LV Creation host, time localhost.localdomain, 2024-01-10 21:19:59 -0500
  LV Status              available
  # open                1
  LV Size                70.00 GiB
  Current LE            17920
  Segments              1
  Allocation            inherit
  Read ahead sectors    auto
  - currently set to    8192
  Block device          253:0
</syntaxhighlight>
 
== References ==
<references />

Latest revision as of 11:29, 17 July 2026

Template:Status

Template:TOC

Overview

LVM에 대한 기술 문서입니다.

Summary

  • 무엇인가? - LVM
  • 왜 필요한가? - HPC 및 서버 환경에서 필수 개념
  • 언제 사용하는가? - 서버 구성, 성능 튜닝, 문제 해결 시


Purpose

이 문서가 존재하는 이유

  • Goal: LVM에 대한 기술 정보 제공
  • Scope: LVM의 개념, 사용법, 설정
  • Non-goals: 다른 주제로의 확장


Key Concepts

Concept Description Related
LVM HPC/서버 환경에서 중요한 기술 개념 Linux, Server


Detailed Explanation

LVM(Logical volume management) creates an easy to use layer over multiple physical disks. We can combine multiple disks and create logical storage volumes. LVM features are[1]

  1. No restriction on disk size
  2. Increased disk throughput
  3. Mirroring volumes for business critical data
  4. Volume snapshots
  5. Easy backups and restores using snapshots
  6. Easy data relocation
  7. Resizing storage pools (add or remove disks) without reformatting disks
Type Description Example
Physical Volumes (PV) Actual disks (e.g. /dev/sda, /dev,sdb, /dev/vdb and so on) display physical volumes

$sudo pvs

Volume Groups (VG)


Best Practices

  • 최신 버전 사용 권장
  • 공식 문서 참고
  • 테스트 환경에서 먼저 검증


References


Related Pages

Knowledge Graph

Related

LinuxServerHardwareNetwork