본문 바로가기
OS/Linux

[ubuntu] LVM 구성 - 추가 LVM 구성

by KEI NETWORK 2019. 7. 18.
728x90

LVM 구성 환경


디스크를 추가하여 LVM을 신규로 구성하는 방법은 "[Linux] LVM 구성 - 신규 LVM 구성" 포스팅을 참조 부탁드립니다.

 

기존 운영중인 LVM에 신규 디스크를 추가하여 LVM에 디스크 용량을 증가할 수 있습니다.

 

 

 

디스크 추가 및 PV 설정


LVM에 추가할 Disk를 마운트 합니다.

$> sudo fdisk -l

 

Disk /dev/sdd: 10.7 GB, 10737418240 bytes

64 heads, 32 sectors/track, 10240 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk identifier: 0x00000000

 

 

fdisk를 통해 신규로 추가된 Disk를 파티션 합니다.

•sudo fdisk /dev/sdd(장치명)

$> sudo fdisk /dev/sdd  # 파티션 할 장치명을 입력합니다.

 

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x1b6fa8a1.

Changes will remain in memory only, until you decide to write them.

After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

The device presents a logical sector size that is smaller than

the physical sector size. Aligning to a physical sector (or optimal

I/O) size boundary is recommended, or performance may be impacted.

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'를 입력하여 현재의 파티션 정보를 확인할 수 있습니다.

생성된 파티션이 없는 것을 다시 한번 확인 후 파티션 생성을 진행합니다.

Command (m for help)p    

  

Disk /dev/sdd: 10.7 GB, 10737418240 bytes

64 heads, 32 sectors/track, 10240 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk identifier: 0x1b6fa8a1

   Device Boot      Start         End      Blocks   Id  System

 

 

 

n'을 입력하면 파티션을 생성할 수 있습니다.

 

'p'는 파티션의 속성입니다. 주 파티션 또는 확장 파티션 중에 선택할 수 있습니다.

 

파티션 번호에는 첫번째 파티션을 생성함에 따라 1번을 선택했습니다.

 

파티션의 크기는 용량으로 나오지 않고 Cylinder의 시작점과 끝점을 선택하게 됩니다.

•Cylinder의 시작점을 1, 끝점을 5000으로 지정할 경우 약 5GB를 파티션 합니다.

•Cylinder의 시작점을 1, 끝점을 10240으로 지정할 경우 10GB를 파티션 합니다.

Command (m for help): n                    # 파티션을 생성합니다.

Command action                             # 파티션의 속성을 선택합니다.

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1                  # 파티션의 번호를 선택합니다.

First cylinder (1-10240, default 1): 1     # Cylinder의 시작점을 선택합니다.

Last cylinder, +cylinders or +size{K,M,G} (1-10240, default 10240): 10240  # Cylinder의 끝점을 선택합니다.

 

 

'p'를 입력하여 파티션이 정상적으로 생성되었는지 확인합니다.

Command (m for help): p

 

Disk /dev/sdd: 10.7 GB, 10737418240 bytes

64 heads, 32 sectors/track, 10240 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk identifier: 0x1b6fa8a1

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1       10240    10485744   83  Linux

 

 

파티션이 정상적으로 생성되었다면 't'를 입력하여 파티션 System ID를 변경합니다.

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partition's system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

 

Command (m for help): t

 

 

'list'를 입력하여 파티션 System ID 리스트를 확인합니다.

Linux LVM을 추가 구성 할 예정이기 때문에 '8e'를 입력합니다.

Hex code (type L to list codes): list

 

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        

 1  FAT12           39  Plan 9          82  Linux swap / So c1  DRDOS/sec (FAT-

 2  XENIX root      3c  PartitionMagic  83  Linux           c4  DRDOS/sec (FAT-

 3  XENIX usr       40  Venix 80286     84  OS/2 hidden C:  c6  DRDOS/sec (FAT-

 4  FAT16 <32M      41  PPC PReP Boot   85  Linux extended  c7  Syrinx         

 5  Extended        42  SFS             86  NTFS volume set da  Non-FS data    

 6  FAT16           4d  QNX4.x          87  NTFS volume set db  CP// CTOS / .

 7  HPFS/NTFS       4e  QNX4.x 2nd part 88  Linux plaintext de  Dell Utility   

 8  AIX             4f  QNX4.x 3rd part 8e  Linux LVM       df  BootIt         

 9  AIX bootable    50  OnTrack DM      93  Amoeba          e1  DOS access     

 a  OS/2 Boot Manag 51  OnTrack DM6 Aux 94  Amoeba BBT      e3  DOS R/O        

 b  W95 FAT32       52  CP/M            9f  BSD/OS          e4  SpeedStor      

 c  W95 FAT32 (LBA) 53  OnTrack DM6 Aux a0  IBM Thinkpad hi eb  BeOS fs        

 e  W95 FAT16 (LBA) 54  OnTrackDM6      a5  FreeBSD         ee  GPT            

 f  W95 Ext'd (LBA) 55  EZ-Drive        a6  OpenBSD         ef  EFI (FAT-12/16/

10  OPUS            56  Golden Bow      a7  NeXTSTEP        f0  Linux/PA-RISC b

11  Hidden FAT12    5c  Priam Edisk     a8  Darwin UFS      f1  SpeedStor      

12  Compaq diagnost 61  SpeedStor       a9  NetBSD          f4  SpeedStor      

14  Hidden FAT16 <3 63  GNU HURD or Sys ab  Darwin boot     f2  DOS secondary  

16  Hidden FAT16    64  Novell Netware  af  HFS / HFS+      fb  VMware VMFS    

17  Hidden HPFS/NTF 65  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE 

18  AST SmartSleep  70  DiskSecure Mult b8  BSDI swap       fd  Linux raid auto

1b  Hidden W95 FAT3 75  PC/IX           bb  Boot Wizard hid fe  LANstep        

1c  Hidden W95 FAT3 80  Old Minix       be  Solaris boot    ff  BBT            

1e  Hidden W95 FAT1

 

Hex code (type L to list codes): 8e  

 

 

 

파티션 System ID가 Linux LVM으로 정상적으로 변경되었으면 'w'를 입력하여 저장합니다.

Changed system type of partition 1 to 8e (Linux LVM)

 

Command action

   a   toggle a bootable flag

   b   edit bsd disklabel

   c   toggle the dos compatibility flag

   d   delete a partition

   l   list known partition types

   m   print this menu

   n   add a new partition

   o   create a new empty DOS partition table

   p   print the partition table

   q   quit without saving changes

   s   create a new empty Sun disklabel

   t   change a partitions system id

   u   change display/entry units

   v   verify the partition table

   w   write table to disk and exit

   x   extra functionality (experts only)

Command (m for help): w

 

'/dev/sdd'에 대한 파티션 정보가 정상적으로 생성되었는지 확인합니다.

$> sudo fdisk -l

 

Disk /dev/sdd: 10.7 GB, 10737418240 bytes

64 heads, 32 sectors/track, 10240 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 4096 bytes

I/O size (minimum/optimal): 4096 bytes / 4096 bytes

Disk identifier: 0x1b6fa8a1

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1       10240    10485744   8e  Linux LVM

 

 

LVM으로 추가 구성할 신규 Disk의 파티션 설정이 완료 되었다면 Physical Volumes을 생성합니다.
•pvcreate /dev/장치명

$> sudo pvcreate /dev/sdd1

  Physical volume "/dev/sdd1" successfully created

 

 

$> sudo pvdisplay

  --- Physical volume ---

  PV Name               /dev/sdb1

  VG Name               vg001

  PV Size               10.00 GiB / not usable 3.98 MiB

  Allocatable           yes (but full)

  PE Size               4.00 MiB

  Total PE              2559

  Free PE               0

  Allocated PE          2559

  PV UUID               tIgIGn-Uxzs-mpFl-jk3e-cGhc-c7pC-NZef9X

   

  --- Physical volume ---

  PV Name               /dev/sdc1

  VG Name               vg001

  PV Size               10.00 GiB / not usable 3.98 MiB

  Allocatable           yes 

  PE Size               4.00 MiB

  Total PE              2559

  Free PE               254

  Allocated PE          2305

  PV UUID               5g3syX-Nudm-96ib-oSco-Ghdh-Ajfk-mf8iBT

   

  "/dev/sdd1" is a new physical volume of "10.00 GiB"

  --- NEW Physical volume ---

  PV Name               /dev/sdd1

  VG Name               

  PV Size               10.00 GiB

  Allocatable           NO

  PE Size               0   

  Total PE              0

  Free PE               0

  Allocated PE          0

  PV UUID               nU30XI-DTmq-NYPc-HEMZ-gPhB-cr7M-EdMLUF

 

 

신규 Phycical volume을 추가할 Volume Groups을 확인합니다.

$> sudo vgdisplay

 

  --- Volume group ---

  VG Name               vg001

  System ID             

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  2

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               1

  Max PV                0

  Cur PV                2

  Act PV                2

  VG Size               19.99 GiB

  PE Size               4.00 MiB

  Total PE              5118

  Alloc PE / Size       4864 / 19.00 GiB

  Free  PE / Size       254 / 1016.00 MiB

  VG UUID               fWzKCY-bQGC-Wd6z-n4eD-tpsy-A5wA-1Rglhm

 

 

Volume Groups에 신규 Phycical Volume을 추가합니다.

•vgextend [ VG 이름 ] [ 장치명 ]

$> sudo vgextend vg001 /dev/sdd1

  Volume group "vg001" successfully extended

 

 

Phycical Volume 추가를 완료하였다면 VG정보를 확인합니다.

Free PE Size가 증가 된 것을 확인할 수 있습니다.

$> sudo vgdisplay

  --- Volume group ---

  VG Name               vg001

  System ID             

  Format                lvm2

  Metadata Areas        3

  Metadata Sequence No  3

  VG Access             read/write

  VG Status             resizable

  MAX LV                0

  Cur LV                1

  Open LV               1

  Max PV                0

  Cur PV                3

  Act PV                3

  VG Size               29.99 GiB

  PE Size               4.00 MiB

  Total PE              7677

  Alloc PE / Size       4864 / 19.00 GiB

  Free  PE / Size       2813 / 10.99 GiB

  VG UUID               fWzKCY-bQGC-Wd6z-n4eD-tpsy-A5wA-1Rglhm

 

 

Logical Volume에 증설된 용량을 추가합니다.

•sudo lvextend [ LV 장치명] -l +[ Free PE Size]

$> sudo lvextend /dev/vg001/lv001 -+2813

  Size of logical volume vg001/lv001 changed from 19.00 GiB (4864 extents) to 29.99 GiB (7677 extents).

  Logical volume lv001 successfully resized.

 

 

 

Logical Volume 확인 시 LV Size가 증가한 것을 확인할 수 있습니다.

$> sudo lvdisplay

  --- Logical volume ---

  LV Path                /dev/vg001/lv001

  LV Name                lv001

  VG Name                vg001

  LV UUID                xC5Vgy-LMFJ-4ddL-FE31-zYoz-w7Oh-fXHf6R

  LV Write Access        read/write

  LV Creation host, time test, 2017-11-14 03:46:42 +0000

  LV Status              available

  # open                 1

  LV Size                29.99 GiB

  Current LE             7677

  Segments               3

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     256

  Block device           253:0

 

 

 

하지만 df-h로 디스크 사이즈 확인 시 아직 증가되지 않은 부분을 확인할 수 있습니다.

$> df -h

 

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda1              30G  1.4G   27G   5/

tmpfs                 1.8G     0  1.8G   0/dev/shm

/dev/mapper/vg001-lv001

                       19G   44M   18G   1/data

 

 

변경된 LV 용량을 파일시스템에 반영합니다.

•resize2fs [ LV 장치명 ]

$> sudo resize2fs /dev/vg001/lv001

 

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/vg001/lv001 is mounted on /data; on-line resizing required

old desc_blocks = 2, new_desc_blocks = 2

Performing an on-line resize of /dev/vg001/lv001 to 7861248 (4k) blocks.

The filesystem on /dev/vg001/lv001 is now 7861248 blocks long.

 

$> df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/sda1              30G  1.4G   27G   5/

tmpfs                 1.8G     0  1.8G   0/dev/shm

/dev/mapper/vg001-lv001

                       30G   44M   28G   1/data

 

 

추가된  LV 용량이 정상적으로 표기될 경우 LVM에 디스크 추가를 통한 용량증설이 완료된 것입니다.

728x90

댓글