LVM

-Disk 파티션 효율적으로 관리하고 사용할 수 있는 방식

-LVM2 (Device Mapper)를 이용

 

1. 초기화 설정

-VMware 스냅샷을 이용하여 초기화

-1GB disk * 3EA 추가

-reboot

2. Fdisk 을 이용하여 추가 확인

#fdisk -l

3.파티션 생성

#fdisk /dev/sdb~sdd

'n'         add a new partition

'p'         primary partition

'1'         partition number

'enter'    Frist cylinder

'enter'    last cylinder

't'              Change a partition's system id

'8e'            Linux LVM(리눅스 문제 필수로나옴)

'w'

 

4. PV생성

#pvcreate [장치명]

 

#pvcreate /dev/sdb1 ~ sdd1

5. VG(Volume Group) 생성

#vgcreate [볼륨그룹명] [PV장치명]...[PV장치명]

 

#vgcreate PracticeVG /dev/sdb1 /dev/sdc1 /dev/sdd1

 

6. VG 구성 확인

#vgdisplay [볼륨그룹명]

#vgdisplay PracticeVG

  --- Volume group ---
  VG Name               PracticeVG
  Cur PV                3            //현재 PV 개수
  Act PV                3            //활성 pv 개수
  VG Size               2.98 GiB    //VG 용량
  PE Size               4.00 MiB    // PE 크기 (4MB)
  Total PE              762
  Alloc PE / Size       0 / 0        //할당된 PE 개수   /용량
  Free  PE / Size       762 / 2.98 GiB    //남은 PE 개수 /용량
 

7. VG의 파티션 LV 생성

#lvcreate --szie [크기] --name [LV이름] [VG이름]

 

#lvcreate --size 500M --name PracticeLV1 PracticeVG

#lvcreate --size 1.5GB --name PracticeLV2 PracticeVG

#lvcreate --extents 100%FREE --name PracticeLV3 PracticeVG

나머지 (FREE) 용량을 전부 PracticeLV3에 할당

 

8. LV 정보 확인

#lvdisplay

  LV Path                /dev/PracticeVG/PracticeLV1
  LV Name                PracticeLV1
  VG Name                PracticeVG
  LV Size                500.00 MiB
  Current LE             125        //LV에 할당된 LE 개수
9. 파일 시스템 생성 및 마운트

#mkfs -t ext4 /dev/PracticeVG/PracticeLV1 

#mkfs -t ext4 /dev/PracticeVG/PracticeLV2

#mkfs -t ext4 /dev/PracticeVG/PracticeLV3

 

#mkdir /LV-{1,2,3}

#mount /dev/PracticeVG/PracticeLV1 /LV-1

#mount /dev/PracticeVG/PracticeLV2 /LV-2

#mount /dev/PracticeVG/PracticeLV3 /LV-3

 

# df -h           //확인

 

LV -1 500M

LV -2 1.5GB

LV -3 나머지전부(1GB)

 

LV 삭제 및 용량 추가

#umount /LV-3        //언마운트

#lvchange -an /dev/PracticeVG/PracticeLV3    //LV 비활성화

//LV 상태를 변화 (-a actice -n no)

-> 해당 LV를 비활성화

 

#lvremove /dev/PracticeVG/PracticeLV3        //LV 제거

 

#lvdisplay     // LV3 삭제 확인

#vgdisplay    //VG 정보 확인

 Cur LV                2
 Open LV               2
 Cur PV                3
 Act PV                3
 VG Size               2.98 GiB
 PE Size               4.00 MiB
 Total PE              762
 Alloc PE / Size       509 / 1.99 GiB
 Free  PE / Size       253 / 1012.00 MiB    여유 PE 253 /1012MB

 

용량 추가

#lvextend --size +512M /dev/PracticeVG/PracticeLV1

//LV-1에 512M 추가

 Size of logical volume PracticeVG/PracticeLV1 changed from 500.00 MiB (125 extents) to 1012.00 MiB (253 extents).
  Logical volume PracticeLV1 successfully resized.
이렇게 뜨면 성공

이번엔 블록 개수로 추가 하는 것

#lvextend --extents +125 /dev/PracticeVG/PracticeLV2

 

 Size of logical volume PracticeVG/PracticeLV2 changed from 1.50 GiB (384 extents) to 1.99 GiB (509 extents).
  Logical volume PracticeLV2 successfully resized

이렇게 뜨면 성공

#vgdisplay 남은 용량 확인

  Free  PE / Size       0 / 0    없다!

 

#df -h

/dev/mapper/PraticeVG-PracticeLV1    477M 2.3M 449M 1%/LV-1

/dev/mapper/PracticeVG-PracticeLV2
                      1.5G  2.3M  1.4G   1% /LV-2

 

#resize2fs /dev/PracticeVG/PracticeLV1 //파일 시스템 크기 재설정

#resize2fs /dev/PracticeVG/PracticeLV2//파일 시스템 크기 재설정

 

#df -h

/dev/mapper/PracticeVG-PracticeLV1
                      973M  2.8M  920M   1% /LV-1
/dev/mapper/PracticeVG-PracticeLV2
                      2.0G  2.3M  1.9G   1% /LV-2

'리눅스 ' 카테고리의 다른 글

find,xargs  (0) 2017.04.16
find 옵션  (0) 2017.04.16
LVM명령어  (0) 2017.04.15
쿼터명령어  (0) 2017.04.15
쿼터  (0) 2017.04.15

+ Recent posts