본문으로 바로가기

[Linux] RHCSA LVM 사이즈 확장

category Linux 2020. 11. 23. 12:05
728x90

현재 pv 확인

[root@JeongYD01 test]# pvs
  PV         VG       Fmt  Attr PSize   PFree
  /dev/sda2  cl       lvm2 a--  <24.00g    0
  /dev/sdb1  datavg01 lvm2 a--  496.00m    0

 

pv로 사용할 디스크 생성 /dev/sdc1, /dev/sdc1, /dev/sdc1

# fdisk /dev/sdc

Device     Boot Start   End Cylinders  Size Id Type
/dev/sdc1           1    40        39  305M 8e Linux LVM
/dev/sdc2          40    79        40  306M 8e Linux LVM
/dev/sdc3          79   118        40  306M 8e Linux LVM

 

pv /dev/sdc1, /dev/sdc2, /dev/sdc3 생성

[root@JeongYD01 test]# pvcreate /dev/sdc1
  Physical volume "/dev/sdc1" successfully created.
[root@JeongYD01 test]# pvcreate /dev/sdc2
  Physical volume "/dev/sdc2" successfully created.
[root@JeongYD01 test]# pvcreate /dev/sdc3
  Physical volume "/dev/sdc3" successfully created.

 

생성된 pv /dev/sdc1, /dev/sdc2, /dev/sdc3 확인

[root@JeongYD01 test]# pvs
  PV         VG       Fmt  Attr PSize   PFree
  /dev/sda2  cl       lvm2 a--  <24.00g      0
  /dev/sdb1  datavg01 lvm2 a--  496.00m      0
  /dev/sdc1           lvm2 ---  305.00m 305.00m
  /dev/sdc2           lvm2 ---  306.00m 306.00m
  /dev/sdc3           lvm2 ---  306.00m 306.00m

 

현재 vg 확인

[root@JeongYD01 test]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  cl         1   2   0 wz--n- <24.00g    0
  datavg01   1   1   0 wz--n- 496.00m    0

 

생성한 pv2개 /dev/sdc1 /dev/sdc2 이용하여 datavg02 생성 PE 사이즈 16M 으로

[root@JeongYD01 test]# vgcreate datavg02 /dev/sdc1 /dev/sdc2 -s 16M
  Volume group "datavg02" successfully created

 

생성된 datavg02 확인

[root@JeongYD01 test]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  cl         1   2   0 wz--n- <24.00g      0
  datavg01   1   1   0 wz--n- 496.00m      0
  datavg02   2   0   0 wz--n- 608.00m 608.00m

[root@JeongYD01 test]# vgdisplay
  --- Volume group ---
  VG Name               datavg02
  System ID
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               608.00 MiB
  PE Size               16.00 MiB
  Total PE              38
  Alloc PE / Size       0 / 0
  Free  PE / Size       38 / 608.00 MiB
  VG UUID               UMqxVo-w4fZ-F3AY-OJPq-5aco-u3ml-Uf7FUy

 

datavg02로 datalv02 lv 생성

[root@JeongYD01 test]# lvcreate -n datalv02 -L +600M datavg02
  Rounding up size to full physical extent 608.00 MiB
  Logical volume "datalv02" created.

 

datalv02 생성 확인

[root@JeongYD01 test]# lvs
  LV       VG       Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  root     cl       -wi-ao---- <21.96g                                          
  swap     cl       -wi-ao----  <2.04g                                          
  datalv01 datavg01 -wi-ao---- 496.00m                                          
  datalv02 datavg02 -wi-a----- 608.00m                                          

[root@JeongYD01 test]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/datavg02/datalv02
  LV Name                datalv02
  VG Name                datavg02
  LV UUID                woBgK2-8nxs-9uWq-yyU2-D5yG-xEAu-Ljz04t
  LV Write Access        read/write
  LV Creation host, time JeongYD01, 2020-11-21 08:18:54 -0500
  LV Status              available
  # open                 0
  LV Size                608.00 MiB
  Current LE             38
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:3

 

파일시스템 /dev/mapper/datavg02-datalv02 생성

[root@JeongYD01 test]# mkfs /dev/mapper/datavg02-datalv02
mke2fs 1.45.4 (23-Sep-2019)
Creating filesystem with 155648 4k blocks and 38960 inodes
Filesystem UUID: cfa2c5da-b91f-49e5-9faf-998e1e428592
Superblock backups stored on blocks:
        32768, 98304

Allocating group tables: done
Writing inode tables: done
Writing superblocks and filesystem accounting information: done

 

마운트 포인트 생성 후 마운트

[root@JeongYD01 ~]# mkdir /mnt/data02
[root@JeongYD01 ~]# mount /dev/mapper/datavg02-datalv02 /mnt/data02
[root@JeongYD01 ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
devtmpfs                       872M     0  872M   0% /dev
tmpfs                          901M     0  901M   0% /dev/shm
tmpfs                          901M  9.4M  891M   2% /run
tmpfs                          901M     0  901M   0% /sys/fs/cgroup
/dev/mapper/cl-root             22G  4.4G   18G  20% /
/dev/mapper/datavg01-datalv01  473M  2.3M  446M   1% /mnt/data01
/dev/sda1                      976M  193M  717M  22% /boot
tmpfs                          181M  1.2M  179M   1% /run/user/42
tmpfs                          181M  4.0K  181M   1% /run/user/0
/dev/mapper/datavg02-datalv02  599M  468K  568M   1% /mnt/data02

 

umount 후 파일시스템 확장 +300M

[root@JeongYD01 ~]# umount /mnt/data02
[root@JeongYD01 ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
devtmpfs                       872M     0  872M   0% /dev
tmpfs                          901M     0  901M   0% /dev/shm
tmpfs                          901M  9.4M  891M   2% /run
tmpfs                          901M     0  901M   0% /sys/fs/cgroup
/dev/mapper/cl-root             22G  4.4G   18G  20% /
/dev/mapper/datavg01-datalv01  473M  2.3M  446M   1% /mnt/data01
/dev/sda1                      976M  193M  717M  22% /boot
tmpfs                          181M  1.2M  179M   1% /run/user/42
tmpfs                          181M  4.0K  181M   1% /run/user/0

 

미사용중인 /dev/sdc3 사용하여 확장

[root@JeongYD01 ~]# pvs
  PV         VG       Fmt  Attr PSize   PFree
  /dev/sda2  cl       lvm2 a--  <24.00g      0
  /dev/sdb1  datavg01 lvm2 a--  496.00m      0
  /dev/sdc1  datavg02 lvm2 a--  304.00m      0
  /dev/sdc2  datavg02 lvm2 a--  304.00m      0
  /dev/sdc3               lvm2 ---  306.00m 306.00m

[root@JeongYD01 ~]# vgextend datavg02 /dev/sdc3
  Volume group "datavg02" successfully extended

 

/dev/sdc3이 datavg02로 할당된것 확인, datavg02. free 사이즈 300M 확인

[root@JeongYD01 ~]# pvs
  PV         VG       Fmt  Attr PSize   PFree
  /dev/sda2  cl       lvm2 a--  <24.00g      0
  /dev/sdb1  datavg01 lvm2 a--  496.00m      0
  /dev/sdc1  datavg02 lvm2 a--  304.00m      0
  /dev/sdc2  datavg02 lvm2 a--  304.00m      0
  /dev/sdc3  datavg02 lvm2 a--  304.00m 304.00m

[root@JeongYD01 ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  cl         1   2   0 wz--n- <24.00g      0
  datavg01   1   1   0 wz--n- 496.00m      0
  datavg02   3   1   0 wz--n- 912.00m 304.00m

 

lv 사이즈 확장

[root@JeongYD01 ~]# lvextend /dev/datavg02/datalv02 -L 900M
  Rounding size to boundary between physical extents: 912.00 MiB.
  Size of logical volume datavg02/datalv02 changed from 608.00 MiB (38 extents) to 912.00 MiB (57 extents).
  Logical volume datavg02/datalv02 successfully resized.

[root@JeongYD01 ~]# vgs
  VG       #PV #LV #SN Attr   VSize   VFree
  cl         1   2   0 wz--n- <24.00g    0
  datavg01   1   1   0 wz--n- 496.00m    0
  datavg02   3   1   0 wz--n- 912.00m    0

 

마운트 후 사이즈 확인해보면 아직 사이즈가 여전히 599M 이다

[root@JeongYD01 ~]# mount /dev/mapper/datavg02-datalv02 /mnt/data02

[root@JeongYD01 ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
devtmpfs                       872M     0  872M   0% /dev
tmpfs                          901M     0  901M   0% /dev/shm
tmpfs                          901M  9.4M  891M   2% /run
tmpfs                          901M     0  901M   0% /sys/fs/cgroup
/dev/mapper/cl-root             22G  4.4G   18G  20% /
/dev/mapper/datavg01-datalv01  473M  2.3M  446M   1% /mnt/data01
/dev/sda1                      976M  193M  717M  22% /boot
tmpfs                          181M  1.2M  179M   1% /run/user/42
tmpfs                          181M  4.0K  181M   1% /run/user/0
/dev/mapper/datavg02-datalv02  599M  468K  568M   1% /mnt/data02

 

resize2fs 하면 된다 

[root@JeongYD01 ~]# resize2fs /dev/mapper/datavg02-datalv02
resize2fs 1.45.4 (23-Sep-2019)

[root@JeongYD01 ~]# resize2fs /dev/mapper/datavg02-datalv02
resize2fs 1.45.4 (23-Sep-2019)
Filesystem at /dev/mapper/datavg02-datalv02 is mounted on /mnt/data02; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/datavg02-datalv02 is now 233472 (4k) blocks long.

[root@JeongYD01 ~]# df -h
Filesystem                     Size  Used Avail Use% Mounted on
devtmpfs                       872M     0  872M   0% /dev
tmpfs                          901M     0  901M   0% /dev/shm
tmpfs                          901M  9.4M  891M   2% /run
tmpfs                          901M     0  901M   0% /sys/fs/cgroup
/dev/mapper/cl-root             22G  4.4G   18G  20% /
/dev/mapper/datavg01-datalv01  473M  2.3M  446M   1% /mnt/data01
/dev/sda1                      976M  193M  717M  22% /boot
tmpfs                          181M  1.2M  179M   1% /run/user/42
tmpfs                          181M  4.0K  181M   1% /run/user/0
/dev/mapper/datavg02-datalv02  897M  764K  855M   1% /mnt/data02

'Linux' 카테고리의 다른 글

[Linux] RHCSA ssh-keygen  (0) 2020.11.25
[Linux] RHCSA swap 늘리기  (0) 2020.11.24
[Linux] RHCSA filesystem 생성  (0) 2020.11.22
[Linux] RHCSA SELinux 전환  (0) 2020.11.21
[Linux] RHCSA yum repository 등록  (0) 2020.11.20