- LINUX

[Rocky] LVM 생성 및 용량 추가






1. 개요

LVM 생성 및 용량 추가







2. 버전

Rocky-8.6







3. 설명





3-1. LVM(Logical Volume Manager) 이란?

LVM은 스토리지 장치의 물리적 볼륨을 논리적 볼륨으로 관리할 수 있게 해주는 시스템
필요에 따라 크기를 조절하거나 디스크를 추가




3-2. PV(Physical Volume) 이란?

PV는 LVM에서 가장 기본적인 스토리지 단위
HDD, SSD 또는 파티션 등을 물리적 볼륨으로 변환하여 LVM 시스템에 포함할 수 있음
PV는 Volume Group을 생성하기 위한 기본 블록




3-3. VG(Volume Group) 이란?

볼륨 그룹(VG)은 하나 이상의 물리적 볼륨(PV)을 결합하여 단일 스토리지 풀을 만드는 것
여러 개의 PV를 하나의 VG로 묶어서 사용하면, VG 내에서 논리적 볼륨을 생성하고 관리할 수 있음
VG는 LVM의 중앙 집중식 관리 단위로, 스토리지 공간을 보다 유연하게 활용할 수 있게 해줌




3-4. LV(Logical Volume) 이란?

논리적 볼륨(LV)은 사용자가 실제로 데이터를 저장하고 사용할 수 있는 LVM의 최종 단위
논리적 볼륨은 볼륨 그룹(VG)에서 필요한 크기만큼 할당받아 생성
LV는 파일 시스템을 생성하고 마운트하여 일반 디스크 파티션처럼 사용할 수 있음




3-5. PE(Physical Extent) 이란?

물리적 볼륨(PV)을 관리하는 데 사용되는 가장 작은 단위
고정된 크기의 블록으로, 물리적 볼륨의 전체 크기를 작은 단위로 나눔
논리적 볼륨(LV)에서 사용할 수 있는 할당 단위로 활용







4. 참고 링크





4-1. [Rocky] Rocky-9.2 LVM으로 설치

BLOG
YouTube







5. LVM 생성





5-1. DISK 확인

# fdisk -l

Disk /dev/sdc: 256 GiB, 274877906944 bytes, 536870912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sdb: 256 GiB, 274877906944 bytes, 536870912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sda: 256 GiB, 274877906944 bytes, 536870912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 272C1634-ABD6-4631-9D29-96B9F6834D06

Device        Start       End   Sectors  Size Type
/dev/sda1      2048   2099199   2097152    1G EFI System
/dev/sda2   2099200  10487807   8388608    4G Linux swap
/dev/sda3  10487808 536868863 526381056  251G Linux filesystem


Disk /dev/sdd: 256 GiB, 274877906944 bytes, 536870912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/sde: 256 GiB, 274877906944 bytes, 536870912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes




5-2. DISK 설정

# fdisk /dev/sdb




5-2-1. Partition 생성

$ Command (m for help): n

Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)

$ Select (default p): p
$ Partition number (1-4, default 1): ${Enter}
$ First sector (2048-536870911, default 2048):${Enter}
$ Last sector, +sectors or +size{K,M,G,T,P} (2048-536870911, default 536870911): ${Enter}

Created a new partition 1 of type 'Linux' and of size 256 GiB.



5-2-2. Type 변경

$ Command (m for help): t
$ Hex code (type L to list all codes): L

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden or  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi ea  Rufus alignment
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         eb  BeOS fs
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ee  GPT
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        ef  EFI (FAT-12/16/
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f0  Linux/PA-RISC b
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f1  SpeedStor
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f4  SpeedStor
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      f2  DOS secondary
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fb  VMware VMFS
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fc  VMware VMKCORE
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fd  Linux raid auto
1c  Hidden W95 FAT3 75  PC/IX           bc  Acronis FAT32 L fe  LANstep
1e  Hidden W95 FAT1 80  Old Minix       be  Solaris boot    ff  BBT


$ Hex code (type L to list all codes): 8e
$ Command (m for help): p

Disk /dev/sdb: 256 GiB, 274877906944 bytes, 536870912 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x72b3be50

Device     Boot Start       End   Sectors  Size Id Type
/dev/sdb1        2048 536870911 536868864  256G 8e Linux LVM



5-2-3. 저장

$ Command (m for help): wq




5-3. PV 생성

# pvcreate /dev/sdb1

  Physical volume "/dev/sdb1" successfully created.


# pvdisplay

  "/dev/sdb1" is a new physical volume of "<256.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdb1
  VG Name
  PV Size               <256.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               MZi3Qw-1jYS-zBG1-2cIq-y5Xd-lj4d-PflfxY




5-4. VG 생성

# vgcreate vg_file /dev/sdb1

  Volume group "vg_file" successfully created


# vgdisplay -v

  --- Volume group ---
  VG Name               vg_file
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <256.00 GiB
  PE Size               4.00 MiB
  Total PE              65535
  Alloc PE / Size       0 / 0
  Free  PE / Size       65535 / <256.00 GiB
  VG UUID               weItuh-ZsDS-WHb8-60DY-ih20-5Hof-NSWzar

  --- Physical volumes ---
  PV Name               /dev/sdb1
  PV UUID               MZi3Qw-1jYS-zBG1-2cIq-y5Xd-lj4d-PflfxY
  PV Status             allocatable
  Total PE / Free PE    65535 / 65535




5-5. LV 생성

# lvcreate -L 100GB vg_file -n lv_file

  Logical volume "lv_file" created.


# lvdisplay

  --- Logical volume ---
  LV Path                /dev/vg_file/lv_file
  LV Name                lv_file
  VG Name                vg_file
  LV UUID                283LpD-4n2l-AYdv-y1mV-PyI7-6f3s-UUnHrh
  LV Write Access        read/write
  LV Creation host, time FILE01, 2024-03-13 15:35:37 +0900
  LV Status              available
  # open                 0
  LV Size                100.00 GiB
  Current LE             25600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0




5-6. 포멧

# mkfs.xfs /dev/vg_file/lv_file




5-7 확인

# blkid

/dev/mapper/vg_file-lv_file: UUID="577ffddf-1275-4bc3-9224-1bbfe431e434" BLOCK_SIZE="512" TYPE="xfs"


# mount /dev/mapper/vg_file-lv_file /mnt/
# df -Th

Filesystem                  Type      Size  Used Avail Use% Mounted on
/dev/mapper/vg_file-lv_file xfs       100G  746M  100G   1% /mnt







6. LVM 추가





6-1. PV 추가

# pvcreate /dev/sdc1

  Physical volume "/dev/sdc1" successfully created.


# pvdisplay

  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               vg_file
  PV Size               <256.00 GiB / not usable 3.00 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              65535
  Free PE               39935
  Allocated PE          25600
  PV UUID               MZi3Qw-1jYS-zBG1-2cIq-y5Xd-lj4d-PflfxY

  "/dev/sdc1" is a new physical volume of "<256.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/sdc1
  VG Name
  PV Size               <256.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               3qpPIW-2uU2-39J4-7pIi-nJo3-tAsC-odv54y




6-2. VG 추가

# vgextend vg_file /dev/sdc1

  Volume group "vg_file" successfully extended


# vgdisplay

  --- Volume group ---
  VG Name               vg_file
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  3
  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               511.99 GiB
  PE Size               4.00 MiB
  Total PE              131070
  Alloc PE / Size       25600 / 100.00 GiB
  Free  PE / Size       105470 / 411.99 GiB
  VG UUID               weItuh-ZsDS-WHb8-60DY-ih20-5Hof-NSWzar




6-3. LV 추가

# lvextend /dev/vg_file/lv_file -l +10000

  Size of logical volume vg_file/lv_file changed from 100.00 GiB (25600 extents) to 139.06 GiB (35600 extents).
  Logical volume vg_file/lv_file successfully resized.


# lvdisplay

  --- Logical volume ---
  LV Path                /dev/vg_file/lv_file
  LV Name                lv_file
  VG Name                vg_file
  LV UUID                283LpD-4n2l-AYdv-y1mV-PyI7-6f3s-UUnHrh
  LV Write Access        read/write
  LV Creation host, time FILE01, 2024-03-13 15:35:37 +0900
  LV Status              available
  # open                 1
  LV Size                139.06 GiB
  Current LE             35600
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0




6-4. 적용




6-4-1. 파일 시스템이 XFS인 경우

# xfs_growfs /dev/mapper/vg_file-lv_file



6-4-2. 파일 시스템이 XFS가 아닌 경우

# resize2fs /dev/vg_file/lv_file




6-5. 확인

# df -Th

Filesystem                  Type      Size  Used Avail Use% Mounted on
/dev/mapper/vg_file-lv_file xfs       140G  1.1G  139G   1% /mnt







7. Parted

용량이 2TB 이상인 경우 사용





7-1. Parted 실행

# parted /dev/sdd




7-2. 파티션 설정

$ (parted) mkpart
$ Partition name? []? ${Enter}
$ File system type? [ext2]? xfs
$ Start? 1
$ End? -1




7-3. 생성 파티션 확인

$ (parted) p

Model: VMware Virtual disk (scsi)
Disk /dev/sdd: 275GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 275GB 275GB xfs




7-4. LVM 변경

$ (parted) set 1 lvm on




7-5. LVM 변경 확인

(parted) p

Model: VMware Virtual disk (scsi)
Disk /dev/sdd: 275GB
Sector size (logical/physical): 512B/512B
Partition Table: gpt
Disk Flags:

Number Start End Size File system Name Flags
1 1049kB 275GB 275GB xfs lvm




7-6. Parted 종료

(parted) q



seuheu

최근 게시물

[Linux] Rocky Linux란 무엇인가?

1. 개요 Rocky Linux는 엔터프라이즈 환경에서 사용되는 RHEL(Red Hat Enterprise Linux)과 완전히 호환되는 오픈소스 Linux…

%일 전

[Hardware] Supermicro IPMIView 설치 및 사용법

https://youtu.be/XwG4jBWakzQ 1. 개요 Supermicro IPMIView는 Supermicro에서 제공하는 IPMI (Intelligent Platform Management Interface) 기반의 통합 관리…

%일 전

[Rocky 8.10] KVM NIC Bonding + Bridge 구성하기

1. 개요 이 문서는 두 개의 NIC (enp5s0f0, enp5s0f1)를 bonding(active-backup) 방식으로 구성하고, 해당 bond 장치를 브리지(br0) 와 연결하여 KVM 가상머신에서…

%일 전

[Rocky] KVM에서 NVIDIA GPU Passthrough 시 RmInitAdapter failed 오류 해결하기

1. 개요 KVM에서 NVIDIA GPU를 Passthrough 설정하여 VM에 할당할 때 RmInitAdapter failed 오류를 자주 접하게…

%일 전

[Proxmox] pGPU와 vGPU 동시 사용 설정

1. 개요 Proxmox에서 pGPU(Physical GPU)와 vGPU(Virtual GPU)를 동일한 서버에서 동시에 사용하는 방법을 정리합니다. 2. 버전…

%일 전

[Proxmox] vGPU 설정

1. 개요 Proxmox에서 vGPU를 설정하는 방법을 정리합니다. 2. 버전 Proxmox 8.2 3. vGPU란? vGPU(Virtual GPU)는…

%일 전