2020.08.04
1. LVM 개요
- CentOS에서 기본 제공되는 볼륨 매니저로 물리 디스크를 논리적으로 구성하여, 논리적인 그룹들을 묶거나 유연하게 확장 또는 제거할 수 있는 기능
2. LVM 설치
# yum install lvm2
3. LVM 구성
a. 물리적 디스크 확인 (/dev/sdb)
# lsblk -l
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 893.8G 0 disk
sda1 8:1 0 200M 0 part /boot/efi
sda2 8:2 0 1G 0 part /boot
sda3 8:3 0 892.6G 0 part
centos-root 253:0 0 888.6G 0 lvm /
centos-swap 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 3.5T 0 disk
sdc 8:32 0 14.6T 0 disk
sr0 11:0 1 1024M 0 rom
#
# fdisk /dev/sdb -l
Disk /dev/sdb: 3840.1 GB, 3840103415808 bytes, 7500201984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
#
b. 파티션 생성 (/dev/sdb1)
- parted 또는 fdisk 명령어로 Partition 생성
- Disk가 2T 이상인 경우 GPT(GUID Partition Table) type으로 생성해야 함
- parted 명령어로 파티션 생성
# parted /dev/sdb
GNU Parted 3.1
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mklabel GPT
(parted) mkpart primary 1 100%
(parted) set 1 lvm on
(parted) print free
Model: DELL PERC H730P Adp (scsi)
Disk /dev/sdb: 3840GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:
Number Start End Size File system Name Flags
17.4kB 1049kB 1031kB Free Space
1 1049kB 3840GB 3840GB primary lvm
3840GB 3840GB 1032kB Free Space
(parted) q
Information: You may need to update /etc/fstab.
#
- fdisk 명령어로 파티션 생성
# fdisk /dev/sdb
…
Command (m for help): g
Building a new GPT disklabel (GUID: 3C4077B6-E6EC-4476-B0FE-F17BF9268F48)
Command (m for help): p
Disk /dev/sdb: 3840.1 GB, 3840103415808 bytes, 7500201984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt
Disk identifier: 3C4077B6-E6EC-4476-B0FE-F17BF9268F48
# Start End Size Type Name
Command (m for help): n
Partition number (1-128, default 1):
First sector (2048-7500201950, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-7500201950, default 7500201950):
Created partition 1
Command (m for help): t
Selected partition 1
Partition type (type L to list all types): 31
Changed type of partition 'Linux filesystem' to 'Linux LVM'
Command (m for help): p
Disk /dev/sdb: 3840.1 GB, 3840103415808 bytes, 7500201984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt
Disk identifier: 3C4077B6-E6EC-4476-B0FE-F17BF9268F48
# Start End Size Type Name
1 2048 7500201950 3.5T Linux LVM
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
#
- 파티션 생성 결과 확인
# fdisk /dev/sdb -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/sdb: 3840.1 GB, 3840103415808 bytes, 7500201984 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt
Disk identifier: 3C4077B6-E6EC-4476-B0FE-F17BF9268F48
# Start End Size Type Name
1 2048 7500201950 3.5T Linux LVM
#
c. PV 생성 (/dev/sdb1) : Partition ⇢ PV
# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.
[root@iap12 ~]# pvscan
PV /dev/sda3 VG centos lvm2 [892.55 GiB / 0 free]
PV /dev/sdb1 lvm2 [3.49 TiB]
Total: 2 [4.36 TiB] / in use: 1 [892.55 GiB] / in no VG: 1 [3.49 TiB]
#
# pvdisplay /dev/sdb1
"/dev/sdb1" is a new physical volume of "3.49 TiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 3.49 TiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID KNHZFa-ZZVo-7zjh-QcCY-HqEz-rNs0-1gXwmU
#
d. VG 생성 (vg0) : Partition ⇢ PV ⇢ VG
# vgcreate vg0 /dev/sdb1
Volume group "vg0" successfully created
#
# vgscan
Reading volume groups from cache.
Found volume group "vg0" using metadata type lvm2
Found volume group "centos" using metadata type lvm2
# vgdisplay vg0
--- Volume group ---
VG Name vg0
System ID
Format lvm2
...
VG Size 3.49 TiB
PE Size 4.00 MiB
Total PE 915551
Alloc PE / Size 0 / 0
Free PE / Size 915551 / 3.49 TiB
VG UUID huBzFU-z2fW-6gIW-3kFT-2y68-MySX-NVo2tC
# pvdisplay /dev/sdb1
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg0
PV Size 3.49 TiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 915551
Free PE 915551
Allocated PE 0
PV UUID KNHZFa-ZZVo-7zjh-QcCY-HqEz-rNs0-1gXwmU
#
- VG에 신규 PV를 추가할 경우
# vgextend vg0 /dev/sdc1
Volume group "vg0" successfully extended
#
d. LV 생성 (/dev/vg0/data_01): Partition ⇢ PV ⇢ VG ⇢ LV
# lvcreate -L 1024G -n data_01 vg0
Logical volume "data_01" created.
#
# lvscan
ACTIVE '/dev/vg0/data_01' [1.00 TiB] inherit
ACTIVE '/dev/centos/root' [888.55 GiB] inherit
ACTIVE '/dev/centos/swap' [4.00 GiB] inherit
# vgdisplay vg0
--- Volume group ---
VG Name vg0
...
Alloc PE / Size 262144 / 1.00 TiB
Free PE / Size 653407 / 2.49 TiB
VG UUID huBzFU-z2fW-6gIW-3kFT-2y68-MySX-NVo2tC
# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 892.55g 0
vg0 1 1 0 wz--n- 3.49t 2.49t
#
e. 파일시스템 생성 및 마운트 (/data_01)
# mkfs.xfs /dev/mapper/vg0-data_01
...
# mkdir /data_01 && mount /dev/mapper/vg0-data_01 /data_01
# vi /etc/fstab
...
/dev/mapper/vg0-data_01 /data_01 xfs defaults 0 0
#
- 결과 확인
# df -h | egrep 'File|data_01'
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-data_01 1.0T 33M 1.0T 1% /data_01
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 893.8G 0 disk
├─sda1 8:1 0 200M 0 part /boot/efi
├─sda2 8:2 0 1G 0 part /boot
└─sda3 8:3 0 892.6G 0 part
├─centos-root 253:0 0 888.6G 0 lvm /
└─centos-swap 253:1 0 4G 0 lvm [SWAP]
sdb 8:16 0 3.5T 0 disk
└─sdb1 8:17 0 3.5T 0 part
└─vg0-data_01 253:2 0 1T 0 lvm /data_01
sdc 8:32 0 14.6T 0 disk
sr0 11:0 1 1024M 0 rom
#
'Linux' 카테고리의 다른 글
NTP(Network Time Protocol) 설정 (0) | 2021.11.30 |
---|---|
LVM - LV 사이즈 확장 (0) | 2021.11.10 |
댓글