린아저씨의 잡학사전

[CentOS7] LVM /home 크기 대신 /(root) 크기 늘리기


서버 구성시 /home 영역이 필요 없는데 기본 값으로 설정했을 경우 /home 대신 /(root) 크기를 늘려줘야 하는 경우가 있다.

이럴 경우 /home LVM을 삭제하고 /(root) LVM을 늘린 후 적용하는 방법이다.



1. 우선 현재 mount 되어 있는 영역을 확인한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
# df -Th
 
Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs        50G  9.4G   45G  18/
devtmpfs                devtmpfs   17G     0   17G   0/dev
tmpfs                   tmpfs      17G     0   17G   0/dev/shm
tmpfs                   tmpfs      17G   18M   17G   1/run
tmpfs                   tmpfs      17G     0   17G   0/sys/fs/cgroup
/dev/sda1               xfs       1.1G  136M  928M  13/boot
/dev/mapper/centos-home xfs        57G   34M   62G   1/home
cm_processes            tmpfs      17G   14M   17G   1/run/cloudera-scm-agent/process
tmpfs                   tmpfs     3.4G     0  3.4G   0/run/user/0 
cs


/(root) 영역이 50G /home 영역이 57G 잡혀있는 것을 확인할 수 있다.




2. /home을 우선 umount 해주고 /etc/fstab 에서도 삭제해준다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# umount /home
 
# vi /etc/fstab
 
#
# /etc/fstab
# Created by anaconda on Mon Sep 10 11:02:54 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=d50a11eb-5415-496e-9099-4d7fa5173408 /boot                   xfs     defaults        0 0
#/dev/mapper/centos-home /home                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
cs




3. lv 정보를 확인한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# lvdisplay                         
 
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                3uTBf4-lG69-dVOC-hpQw-QQiD-TSNk-Ft6wR8
  LV Write Access        read/write
  LV Creation host, time cloudera00.bigdata.com, 2018-09-10 11:02:34 +0900
  LV Status              available
  # open                 2
  LV Size                12.00 GiB
  Current LE             3072
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
 
  --- Logical volume ---
  LV Path                /dev/centos/home
  LV Name                home
  VG Name                centos
  LV UUID                GmbVNR-Vy5E-oLhn-WVr9-Piwr-X2k4-nVv0cR
  LV Write Access        read/write
  LV Creation host, time cloudera00.bigdata.com, 2018-09-10 11:02:34 +0900
  LV Status              available
  # open                 0
  LV Size                <57.00 GiB
  Current LE             14591
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:2
 
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                UqiU4M-hZfa-yNb1-n6X5-2FpC-GzUH-rorXVE
  LV Write Access        read/write
  LV Creation host, time cloudera00.bigdata.com, 2018-09-10 11:02:44 +0900
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0 
cs




4. /dev/centos/home 을 삭제해준다.

1
2
3
# lvremove /dev/centos/home

Do you really want to remove active logical volume centos/home? [y/n]: y
Logical volume "home" successfully removed
cs




5. lv 삭제를 확인한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# lvdisplay

  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                3uTBf4-lG69-dVOC-hpQw-QQiD-TSNk-Ft6wR8
  LV Write Access        read/write
  LV Creation host, time cloudera00.bigdata.com, 2018-09-10 11:02:34 +0900
  LV Status              available
  # open                 2
  LV Size                12.00 GiB
  Current LE             3072
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
 
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                UqiU4M-hZfa-yNb1-n6X5-2FpC-GzUH-rorXVE
  LV Write Access        read/write
  LV Creation host, time cloudera00.bigdata.com, 2018-09-10 11:02:44 +0900
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0
cs




6. /home을 삭제하여 늘어난 사이즈만큼 /(root)를 늘려준다.

1
2
3
4
# lvextend -L +54G /dev/centos/root

Size of logical volume centos/root changed from 50.00 GiB (12800 extents) 
to 104.00 GiB (26624 extents).
Logical volume centos/root successfully resized.
cs




7. /(root) 영역이 늘어난 것을 확인한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# lvdisplay

  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                3uTBf4-lG69-dVOC-hpQw-QQiD-TSNk-Ft6wR8
  LV Write Access        read/write
  LV Creation host, time cloudera00.bigdata.com, 2018-09-10 11:02:34 +0900
  LV Status              available
  # open                 2
  LV Size                12.00 GiB
  Current LE             3072
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:1
 
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                UqiU4M-hZfa-yNb1-n6X5-2FpC-GzUH-rorXVE
  LV Write Access        read/write
  LV Creation host, time cloudera00.bigdata.com, 2018-09-10 11:02:44 +0900
  LV Status              available
  # open                 1
  LV Size                104.00 GiB
  Current LE             26624
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0 
cs




8. 변경된 파일 시스템을 적용해준다. ( 이 작업을 해주어야 실제로 반영됨.)

1
2
3
4
5
6
7
8
9
10
11
12
# xfs_growfs /dev/centos/root

meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 27262976 
cs




9. 잘 적용되었는지 확인해 준다.

1
2
3
4
5
6
7
8
9
10
11
# df -Th

Filesystem              Type      Size  Used Avail Use% Mounted on
/dev/mapper/centos-root xfs       104G  8.8G   96G   9/
devtmpfs                devtmpfs   16G     0   16G   0/dev
tmpfs                   tmpfs      16G     0   16G   0/dev/shm
tmpfs                   tmpfs      16G   17M   16G   1/run
tmpfs                   tmpfs      16G     0   16G   0/sys/fs/cgroup
/dev/sda1               xfs      1014M  130M  885M  13/boot
cm_processes            tmpfs      16G   25M   16G   1/run/cloudera-scm-agent/process
tmpfs                   tmpfs     3.2G     0  3.2G   0/run/user/0 
cs




☞ 이 글이 도움이 되셨다면 광고 클릭을 부탁드립니다 :)

공유하기

facebook twitter kakaoTalk kakaostory naver band