[리눅스] LVM 구성 ①편 - PV,VG,LV,FS 생성 및 마운트
- IT/linux
- 2021. 5. 7. 02:26
반응형
Linux LVM 구성(운영) 가이드
· Linux LVM 구성①편 - PV,VG,LV,FS 생성 및 마운트 ← 현재 보고 있는 페이지★
· Linux LVM 구성②편 - PV,VG,LV,FS 운영(증설,삭제)
LVM 구성 시작 전 현재 서버 상태 확인
[root@Eloquence /]# fdisk -l // 추가된 디스크 확인 (sdb) Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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 [root@Eloquence /]# df -h // 현재 파일시스템 마운트 상태 Filesystem Size Used Avail Use% Mounted on devtmpfs 974M 0 974M 0% /dev tmpfs 991M 0 991M 0% /dev/shm tmpfs 991M 11M 981M 2% /run tmpfs 991M 0 991M 0% /sys/fs/cgroup /dev/mapper/centos-root 17G 4.3G 13G 25% / /dev/sda1 1014M 171M 843M 17% /boot tmpfs 199M 12K 199M 1% /run/user/42 tmpfs 199M 0 199M 0% /run/user/0 |
파티션 생성
1. 물리적 디스크(sdb)를 이용해 파티션 생성
[root@Eloquence /]# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). 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 Building a new DOS disklabel with disk identifier 0x0708e7fc. Command (m for help): n // 새 파티션 추가 Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-209715199, default 2048): (Enter) Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): (Enter) Using default value 209715199 Partition 1 of type Linux and of size 100 GiB is set Command (m for help): p // (프린트) 현재 파티션 정보 출력 Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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 label type: dos Disk identifier: 0x0708e7fc Device Boot Start End Blocks Id System /dev/sdb1 2048 209715199 104856576 83 Linux Command (m for help): t // 파티션 시스템 id 변경 Selected partition 1 Hex code (type L to list all codes): 8e // Linux LVM Type Code = 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 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 label type: dos Disk identifier: 0x0708e7fc Device Boot Start End Blocks Id System /dev/sdb1 2048 209715199 104856576 83 Linux LVM // LVM으로 변경됨을 확인 Command (m for help): w // 설정값 저장 The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. |
PV (물리적 볼륨) 생성
1. 현재 PV 정보 확인 (pvs, pvdisplay, pvscan)
[root@Eloquence /]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.00g 0 |
2. PV 생성
[root@Eloquence /]# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created. |
3. 생성된 PV 확인
[root@Eloquence /]# pvs PV VG Fmt Attr PSize PFree /dev/sda2 centos lvm2 a-- <19.00g 0 /dev/sdb1 lvm2 --- <100.00g <100.00g |
VG (볼륨 그룹) 생성
1. 현재 VG 정보 확인 (vgs, vgdisplay, vgscan)
[root@Eloquence /]# vgs VG #PV #LV #SN Attr VSize VFree centos 1 2 0 wz--n- <19.00g 0 |
2. VG 생성
[root@Eloquence /]# vgcreate testvg /dev/sdb1 // testvg를 생성함과 동시에 PV(sdb1)를 할당 Volume group "testvg" successfully created |
3. 생성된 VG 확인
[root@Eloquence /]# vgs VG #PV #LV #SN Attr VSize VFree centos 1 2 0 wz--n- <19.00g 0 testvg 1 0 0 wz--n- <100.00g <100.00g |
LV (논리적 볼륨) 생성
1. 현재 LV 정보 확인 (lvs, lvdisplay, lvscan)
[root@Eloquence /]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- <17.00g swap centos -wi-ao---- 2.00g |
2. LV 생성
[root@Eloquence /]# lvcreate -n datalv -L 70GB testvg // testvg의 70GB를 datalv에 할당 Logical volume "datalv" created. [root@Eloquence /]# lvcreate -n backuplv -l +100%FREE testvg // testvg에 남은 모든 용량을 backuplv에 할당 Logical volume "backuplv" created. |
3. 생성된 LV 확인
[root@Eloquence /]# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root centos -wi-ao---- <17.00g swap centos -wi-ao---- 2.00g backuplv testvg -wi-a----- <30.00g datalv testvg -wi-a----- 70.00g |
파일시스템 포맷
1. 생성된 LV를 바탕으로 파일시스템 타입 지정 및 포맷
[root@Eloquence /]# mkfs.ext4 /dev/testvg/datalv // datalv를 ext4 타입으로 파일시스템 포맷 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 4587520 inodes, 18350080 blocks 917504 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2166358016 560 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000, 7962624, 11239424 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done [root@Eloquence /]# mkfs.ext4 /dev/testvg/backuplv // backuplv를 ext4 타입으로 파일시스템 포맷 mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1966080 inodes, 7863296 blocks 393164 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2155872256 240 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done |
마운트
1. 마운트 포인트 생성
[root@Eloquence /]# mkdir /data [root@Eloquence /]# mkdir /backup |
2. 수동 마운트
[root@Eloquence /]# mount /dev/testvg/datalv /data [root@Eloquence /]# mount /dev/testvg/backuplv /backup [root@Eloquence /]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 974M 0 974M 0% /dev tmpfs 991M 0 991M 0% /dev/shm tmpfs 991M 11M 981M 2% /run tmpfs 991M 0 991M 0% /sys/fs/cgroup /dev/mapper/centos-root 17G 4.3G 13G 25% / /dev/sda1 1014M 171M 843M 17% /boot tmpfs 199M 12K 199M 1% /run/user/42 tmpfs 199M 0 199M 0% /run/user/0 /dev/mapper/testvg-datalv 70G 53M 67G 1% /data // 마운트 완료 /dev/mapper/testvg-backuplv 30G 45M 28G 1% /backup // 마운트 완료 |
3. 자동 마운트 (fstab)
[root@Eloquence /]# vi /etc/fstab # # /etc/fstab # Created by anaconda on Sun Mar 7 05:57:29 2021 # # 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 # /dev/mapper/centos-root / xfs defaults 0 0 UUID=67b178ee-9154-43e1-989f-bdca58311160 /boot xfs defaults 0 0 /dev/mapper/centos-swap swap swap defaults 0 0 /dev/testvg/datalv /data ext4 defaults 0 0 // 마운트 등록 /dev/testvg/backuplv /backup ext4 defaults 0 0 // 마운트 등록 |
반응형
'IT > linux' 카테고리의 다른 글
[리눅스] LVM 구성 ③편 - LVM 명령어 총정리 (0) | 2021.05.21 |
---|---|
[리눅스] LVM 구성 ②편 - PV,VG,LV,FS 확장/용량 추가 (0) | 2021.05.14 |
[리눅스] 기본 부팅 커널 변경 (default boot kernel) (0) | 2021.05.04 |
[리눅스] fuser 명령어 사용법 (0) | 2021.04.26 |
[리눅스] CentOS 구버전 iso 다운로드 방법 (0) | 2021.03.16 |