IT/LINUX

linux xfs 파일 시스템 용량 확장

ssung85 2024. 7. 12. 18:19
728x90

/ 용량 부족 해서 200GB 추가 예정

[root@localhost ~]# df -h
Filesystem                                        Size  Used Avail Use% Mounted on
...
/dev/mapper/rl-root                                44G   44G   20K 100% /
...

 

1. 디스크 추가 

Disk /dev/xvdb: 200 GiB 추가  확인

[root@localhost ~]# fdisk -l
Disk /dev/xvda: 50 GiB, 53687091200 bytes, 104857600 sectors
...
Device     Boot   Start       End   Sectors Size Id Type
/dev/xvda1 *       2048   2099199   2097152   1G 83 Linux
/dev/xvda2      2099200 104857599 102758400  49G 8e Linux LVM

Disk /dev/mapper/rl-root: 44 GiB, 47240445952 bytes, 92266496 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 /dev/mapper/rl-swap: 5 GiB, 5368709120 bytes, 10485760 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 /dev/xvdb: 200 GiB, 214748364800 bytes, 419430400 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
Disklabel type: dos
Disk identifier: 0xf3d32962

 

2. lvm 파티션 생성

[root@localhost ~]# fdisk /dev/xvdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-419430399, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-419430399, default 419430399):

Created a new partition 1 of type 'Linux' and of size 200 GiB.

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
Changed type of partition 'Linux' to 'Linux LVM'.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

 

728x90

3. pv 생성

[root@localhost ~]# pvcreate /dev/xvdb1
  Physical volume "/dev/xvdb1" successfully created.
[root@localhost ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/xvda2
  VG Name               rl
  PV Size               <49.00 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              12543
  Free PE               0
  Allocated PE          12543
  PV UUID               BjiuTe-ZtYS-eU5z-dC9s-Y8Nw-or1j-HVP95j

  "/dev/xvdb1" is a new physical volume of "<200.00 GiB"
  --- NEW Physical volume ---
  PV Name               /dev/xvdb1
  VG Name
  PV Size               <200.00 GiB
  Allocatable           NO
  PE Size               0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               pDQW9R-umbN-6bQ7-Iw55-c4s2-D2vU-zDypeV
  
  [root@localhost ~]# pvscan
  PV /dev/xvda2   VG rl              lvm2 [<49.00 GiB / 0    free]
  PV /dev/xvdb1                      lvm2 [<200.00 GiB]
  Total: 2 [<249.00 GiB] / in use: 1 [<49.00 GiB] / in no VG: 1 [<200.00 GiB]

 

4. vg 그룹에 pv 추가

 > Couldn't create temporary archive name 에러 발생 시 vg 용량 정리 필요

[root@localhost ~]# vgextend rl /dev/xvdb1
  Couldn't create temporary archive name.  ->> 디스크 용량 부족하면 발생 , 디스크 정리 후 다시 실행

[root@localhost ~]# vgextend rl /dev/xvdb1
  Volume group "rl" successfully extended

 

5. 파티션 그룹에 붙이기

[root@localhost ~]# lvextend -l +100%FREE -n /dev/rl/root
  Size of logical volume rl/root changed from <44.00 GiB (11263 extents) to 243.99 GiB (62462 extents).
  Logical volume rl/root successfully resized.

 

6. pv / lv 확인

[root@localhost ~]# pvscan
  PV /dev/xvda2   VG rl              lvm2 [<49.00 GiB / 0    free]
  PV /dev/xvdb1   VG rl              lvm2 [<200.00 GiB / 0    free]
  Total: 2 [248.99 GiB] / in use: 2 [248.99 GiB] / in no VG: 0 [0   ]
  
[root@localhost ~]# lvscan
  ACTIVE            '/dev/rl/swap' [5.00 GiB] inherit
  ACTIVE            '/dev/rl/root' [243.99 GiB] inherit

 

7. 용량 확장 적용

xfs인 경우 -> xfs_growfs
ext4 인 경우 -> resize2fs

[root@localhost ~]# xfs_growfs /dev/rl/root
meta-data=/dev/mapper/rl-root    isize=512    agcount=4, agsize=2883328 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=1    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=11533312, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=5631, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 11533312 to 63961088

[root@localhost ~]# df -h
Filesystem                                        Size  Used Avail Use% Mounted on
...
/dev/mapper/rl-root                               244G   45G  200G  19% /
728x90

'IT > LINUX' 카테고리의 다른 글

[ ANSIBLE ] awx install  (0) 2024.06.05
rocky8 ntp 서버 만들기  (0) 2024.05.16
Rocky 에서 3TB 이상 디스크 추가 하기  (0) 2024.04.16
rocky8 윈도우 공유 폴더 만들기(samba, cifs)  (0) 2024.04.02
linux magaraid gui 설치 방법  (0) 2023.11.09