LVM 구성 방법
1. 물리 Disk 추가 및 기본 설정
[root@lim-Rocky810-T1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
loop0 7:0 0 13.2G 0 loop /DVD
sda 8:0 0 40G 0 disk
└─sda1 8:1 0 40G 0 part
└─vg_system-lv_root 253:0 0 40G 0 lvm /
sdb 8:16 0 10G 0 disk
├─sdb1 8:17 0 1023M 0 part /boot
└─sdb2 8:18 0 8G 0 part [SWAP]
sdc 8:32 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
sdc 디스크가 추가된 것을 확인할 수 있다.
이제 sdc를 LVM에서 사용할 수 있도록 Disk 타입을 바꿔주어야 한다.
[root@lim-Rocky810-T1 ~]# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0x96bc50bf.
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):
First sector (2048-41943039, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-41943039, default 41943039):
Created a new partition 1 of type 'Linux' and of size 20 GiB.
Command (m for help): p
Disk /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x96bc50bf
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 41943039 41940992 20G 83 Linux
위와 같이 Disk를 파티셔닝을 하고 파티션 정보를 확인한다.
생성된 /dev/sdc1은 ID가 83이며, LVM에서 사용하기 위해서는 ID값을 바꿔야 한다.
Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Empty' to 'Linux LVM'.
Command (m for help): p
Disk /dev/sdc: 20 GiB, 21474836480 bytes, 41943040 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
Disklabel type: dos
Disk identifier: 0x96bc50bf
Device Boot Start End Sectors Size Id Type
/dev/sdc1 2048 41943039 41940992 20G 8e Linux LVM
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
LVM Disk Code는 8e 이다.
이제 생성된 Disk를 이용하여 LVM을 구성한다.
2. 물리 볼륨 생성 및 볼륨 그룹 생성
[root@lim-Rocky810-T1 ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created.
[root@lim-Rocky810-T1 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdc1
VG Name DB
PV Size <20.00 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 5119
Free PE 5119
Allocated PE 0
PV UUID qXNeFO-0qPO-LSkM-OOIf-pQBe-Hori-JHx8Cj
[root@lim-Rocky810-T1 ~]# vgcreate DB /dev/sdc1
Volume group "DB" successfully created
[root@lim-Rocky810-T1 ~]# vgdisplay
--- Volume group ---
VG Name DB
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 <20.00 GiB
PE Size 4.00 MiB
Total PE 5119
Alloc PE / Size 0 / 0
Free PE / Size 5119 / <20.00 GiB
VG UUID gkULbL-FGGL-Qvfe-5kbR-QNPj-fAoB-yl3S4C
이렇게 Volume Group을 생성하여, Physical Volume을 등록한다.
이제 실제 사용자가 사용을 하는 Logical Volume을 생성하고 경로에 Mount만 하면 된다.
3. 논리 볼륨 생성
[root@lim-Rocky810-T1 ~]# lvdisplay
--- Logical volume ---
LV Path /dev/DB/DB_Data
LV Name DB_Data
VG Name DB
LV UUID u8yt0u-3KB6-mWz3-S8bu-On88-0Y2D-0fCmlo
LV Write Access read/write
LV Creation host, time lim-Rocky810-T1, 2025-03-11 13:11:25 +0900
LV Status available
# open 0
LV Size 15.00 GiB
Current LE 3840
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
4. 논리 볼륨 파일 시스템 구성 및 Mount 하여 사용
[root@lim-Rocky810-T1 ~]# mkdir /DB_Data
[root@lim-Rocky810-T1 ~]# mkfs.xfs /dev/DB/DB_Data
meta-data=/dev/DB/DB_Data isize=512 agcount=4, agsize=983040 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1 bigtime=0 inobtcount=0
data = bsize=4096 blocks=3932160, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
Discarding blocks...Done.
[root@lim-Rocky810-T1 ~]# mount /dev/DB/DB_Data /DB_Data
[root@lim-Rocky810-T1 ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs tmpfs 3.8G 0 3.8G 0% /dev/shm
tmpfs tmpfs 3.8G 8.5M 3.8G 1% /run
tmpfs tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/mapper/vg_system-lv_root xfs 40G 16G 25G 39% /
/dev/loop0 iso9660 14G 14G 0 100% /DVD
/dev/sdb1 xfs 1018M 228M 791M 23% /boot
tmpfs tmpfs 770M 0 770M 0% /run/user/0
/dev/mapper/DB-DB_Data xfs 15G 140M 15G 1% /DB_Data
[root@lim-Rocky810-T1 ~]# cat /etc/fstab
#
# /etc/fstab
# Created by anaconda on Fri Mar 7 04:53:08 2025
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/vg_system-lv_root / xfs defaults 0 0
UUID=59ed4503-600d-47b8-8158-da813270d3fb /boot xfs defaults 0 0
UUID=8164fb3e-4750-416a-8f7b-06e7665f2245 none swap defaults 0 0
/root/Rocky-8.10-x86_64-dvd1.iso /DVD iso9660 defaults 0 0
/dev/mapper/DB-DB_Data /DB_Data xfs defaults 0 0
위와 같이 /etc/fstab 까지 등록을 하면 사용 준비 완료!!
'IT 관련 > Linux' 카테고리의 다른 글
[Linux] Local Repository설정_RHEL (0) | 2021.03.17 |
---|