728x90
반응형

문 서 명 : VM 환경의 Linux OS 디스크 사이즈 늘리기

문 서 버 전 : Ver_1.0

문 서 구 분 :  Manual  □ Summary

작 성 일 : 2016 10 25

작 성 자 : 우리들의 삶

테 스 트 환 경 : ESXi 5.5, RHEL 6.7, LVM 2.0

출 처 : 본인

본 문서는 VM 환경의 Linux system에 대해 디스크 사이즈를 확장하는 방법을 명시한다.
만약 LVM에 대한 개념정리가 필요하신 분은 다음 글을 사전에 읽어보기를 권장한다.




VM 환경의 Linux System에 대해 디스크 사이즈를 늘리고자 한다면 다음과 같은 수순을 거치게 된다.


1. VM설정에서 디스크 사이즈 확장
2. OS에서 fdisk 명령을 통해 disk label 정의
3. 재부팅
4. 새로만든 공간을 PV로 정의(pvcreate)
5. VG에 PV를 넣어줌(vgextend)
6. LV에 용량을 늘려줌(lvexted)
7. 최종으로 할당된 LV공간을 볼륨이 재인식하는 과정(resize2fs )


1. VM 설정에서 디스크 사이즈 확장


2. OS에서 fdisk 명령을 통해 disk label 정의

[root@testsvrdwa01 ~]# fdisk -l

Disk /dev/sda: 193.3 GB, 193273528320 bytes  <늘어난 용량 체크
255 heads, 63 sectors/track, 23497 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b22b4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3264    25701376   8e  Linux LVM
/dev/sda3            3264       10051    54520257+  8e  Linux LVM

[root@testsvrdwa01 ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 193.3 GB, 193273528320 bytes
255 heads, 63 sectors/track, 23497 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b22b4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3264    25701376   8e  Linux LVM
/dev/sda3            3264       10051    54520257+  8e  Linux LVM


Command (m for help): n  
Command action
   e   extended
   p   primary partition (1-4)
p  <- 만약 차후 더 확장할 계획이 있다면 e 키를 눌러 extended 로 하여야 한다.
Selected partition 4 <- 현재 시스템은 1~3번까지 쓰고 있으므로 4번
First cylinder (10052-23497, default 10052): 10052
Last cylinder, +cylinders or +size{K,M,G} (10052-23497, default 23497):
Using default value 23497

Command (m for help): p

Disk /dev/sda: 193.3 GB, 193273528320 bytes
255 heads, 63 sectors/track, 23497 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b22b4

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          64      512000   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2              64        3264    25701376   8e  Linux LVM
/dev/sda3            3264       10051    54520257+  8e  Linux LVM
/dev/sda4           10052       23497   108004995   83  Linux  <- 4번 볼륨이 추가됨

Command (m for help): t  <- change a partition's system id
Partition number (1-4): 4 <- 4번 볼륨 선택
Hex code (type L to list codes): 8e <- Linux LVM용으로 만들기 위해 partition system id를 8e 로 정의한다.
Changed system type of partition 4 to 8e (Linux LVM)

Command (m for help): w  <- 설정한 내용을 저장
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 장치나 자원이 동작 중.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.




3. 재부팅

[root@testsvrdwa01 ~]# init 6




4. 새로만든 공간을 PV로 정의(pvcreate)

[root@testsvrdwa01 ~]# pvcreate /dev/sda4  <- 방금 정의한 볼륨을 PV로 만들어 준다.
  Physical volume "/dev/sda4" successfully created

[root@testsvrdwa01 ~]# pvs  <- 확인
  PV         VG     Fmt  Attr PSize   PFree 
  /dev/sda2  vg_test lvm2 a--   24.51g      0
  /dev/sda3  vg_test lvm2 a--   51.99g      0
  /dev/sda4         lvm2 ---  103.00g 103.00g  <- PV로 만들어졌고, 아무런 VG에 속하지 않는것이 보인다.




5. VG에 PV를 넣어줌(vgextend)
[root@testsvrdwa01 ~]# vgs  <- 설정 전 확인
  VG     #PV #LV #SN Attr   VSize  VFree
  vg_test   2   3   0 wz--n- 76.50g    0

[root@testsvrdwa01 ~]# vgextend vg_test /dev/sda4   <- vgextend vg_name pv_path
  Volume group "vg_test" successfully extended

[root@testsvrdwa01 ~]# vgs  <- 늘어난 공간 확인
  VG     #PV #LV #SN Attr   VSize   VFree 
  vg_test   3   3   0 wz--n- 179.50g 103.00g



6. LV에 용량을 늘려줌(lvexted)

[root@testsvrdwa01 ~]# lvextend /dev/vg_test/lv_home -l +100%FREE   <- lv_home을 vg 남은 공간 전체로 확장한다.
  Size of logical volume vg_test/lv_home changed from 40.00 GiB (10240 extents) to 143.00 GiB (36608 extents).
  Logical volume lv_home successfully resized

[root@testsvrdwa01 ~]# lvs
  LV      VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  lv_home vg_test -wi-ao---- 143.00g                                                   
  lv_root vg_test -wi-ao----  20.51g                                                   
  lv_swap vg_test -wi-ao----  15.99g                                       




7. 최종으로 할당된 LV공간을 볼륨이 재인식하는 과정(resize2fs )

[root@testsvrdwa01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_root
                       21G  4.5G   15G  24% /
tmpfs                 5.9G     0  5.9G   0% /dev/shm
/dev/mapper/vg_test-lv_home
                       40G   30G  7.7G  80% /home
/dev/sda1             477M   42M  410M  10% /boot
           
[root@testsvrdwa01 ~]# resize2fs /dev/vg_test/lv_home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_test/lv_home is mounted on /home; on-line resizing required
old desc_blocks = 3, new_desc_blocks = 9
Performing an on-line resize of /dev/vg_test/lv_home to 37486592 (4k) blocks.
The filesystem on /dev/vg_test/lv_home is now 37486592 blocks long.

[root@testsvrdwa01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_test-lv_root
                       21G  4.5G   15G  24% /
tmpfs                 5.9G     0  5.9G   0% /dev/shm
/dev/mapper/vg_test-lv_home
                      141G   30G  104G  23% /home
/dev/sda1             477M   42M  410M  10% /boot
[root@testsvrdwa01 ~]#



리눅스 디스크 사이즈 확장, 리눅스 용량 확장, 리눅스 용량 증설, Redhat Disk expended, resize2fs, vgextend, lvextend

728x90
반응형

+ Recent posts