linux lvm rocky9

agnusdei·2023년 12월 10일
0

LVM 구조


1. virtualbox : 저장소를 새로 만들어서 등록합니다.

lsblk
  1. 저장소 상태 확인
    VG: rl, VG01 / LV: root, swap, lv_data
lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINTS
sda                8:0    0   20G  0 disk
├─sda1             8:1    0    1G  0 part /boot
└─sda2             8:2    0   19G  0 part
  ├─rl-root      253:0    0   17G  0 lvm  /
  └─rl-swap      253:1    0    2G  0 lvm  [SWAP]
sdb                8:16   0   20G  0 disk
└─sdb1             8:17   0   20G  0 part
  └─VG01-lv_data 253:2    0   20G  0 lvm  /media
sr0               11:0    1 1024M  0 rom

LVM 사용 시 확인하는 명령어는 접미사에
s, scan, display 를 붙이면 됩니다.

fdisk -l

4.추가할 디스크를 확인합니다.
물리디스크가 linux os 에 인식되었음을 확인합니다.

Disk /dev/sdb: 20 GiB, 21474836480 bytes, 41943040 sectors
Disk model: VBOX HARDDISK
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: 0xd7da77f2

Device     Boot Start      End  Sectors Size Id Type
/dev/sdb1        2048 41943039 41940992  20G 8e Linux LVM


Disk /dev/mapper/rl-root: 17 GiB, 18249416704 bytes, 35643392 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

# 조금 전에 virtualbox 에서 생성한 저장소
Disk /dev/mapper/rl-swap: 2 GiB, 2147483648 bytes, 4194304 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/mapper/VG01-lv_data: 20 GiB, 21470642176 bytes, 41934848 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
  1. fdisk 명령어로 파티션을 진행합니다.
[root@localhost ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.37.4).
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 0x57f5eac2.

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): 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): t
Selected partition 1
Hex code or alias (type L to list all): 8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
  1. 파티션이 잘 되었는지 확인합니다.
fdisk -l
  1. PV 물리 볼륨을 생성합니다.
    (장치가 인식된 파티션 경로와 일치해야 합니다.)
pvcreate /dev/sdb
  1. PV 물리 볼륨을 확인합니다.
pvs

또는

pvdisplay
  1. VG 볼륨 그룹을 생성합니다.
vgcreate VG01 /dev/sdb
vgcreate VG이름 파티션경로
  1. VG를 확인합니다.
vgs

또는

vgdisplay
  1. LV 논리볼륨을 생성합니다. 관례적으로 lv_* 형태를 취합니다.
lvcreate -L 20G -n lv_data VG01
# 특정 용량을 설정하는 경우

또는

lvcreate -l 100%FREE -n lv_data VG01
# 남은 용량 전체를 설정하는 경우
  1. LV 를 확인합니다.
lvs

또는

lvscan

또는

lvdisplay
  1. LV 를 마운트할 폴더를 생성합니다.
mkdir /media/sdb
# 관례적으로 외부 저장장치는 media 에 저장합니다.
  1. LV 를 리눅스 파일시스템으로 포멧 또는 랩핑합니다.
    이제부터 리눅스의 파일시스템으로써 동작하고 관리하기 위함힙니다.
mkfs.xfs /dev/VG01/lv_data
ext4 또는 xfs 를 사용합니다.
ext4 는 일반적인 파일시스템이며
xfs 는 IO가 잦고 대용량 미디어 파일을 다루기에 적합합니다.
  1. LV 를 마운트합니다.
mount /dev/VG01/lv_data /media
  1. 마운트가 되었는지 확인합니다.
df -h
  1. 시스템 부팅 시에도 영구적으로 파일시스템이 LV를 인식하도록 설정합니다.
[root@localhost /]# nano /etc/fstab

# /etc/fstab
# Created by anaconda on Mon Feb  6 13:34:32 2023
#
# 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/VG01-lv_data /                        xfs     defaults        0 0

0개의 댓글

관련 채용 정보