Linux

linux root home 파티션 합치기

Naan 2022. 11. 7. 00:42
320x100

linux 설치할때 파티션을 자동으로 설정을 하면

root 는 용량이 50G 로 할당되고 home 이 나머지로 할당 된다.

home 과 root 경로를 같이 쓰고 싶은데 파티션이 나눠져 있어서 불편하다 이걸 파티션 합치기로 하자.

우선 합치기전에 home 에는 파일이 없어야 한다 있으면 삭제 되니 백업을 꼭 하자.

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                Tp93ZE-oSpq-QJW3-310I-JgFj-eFrf-5wQXpz
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-12-10 01:49:03 +0900
  LV Status              available
  # open                 2
  LV Size                7.81 GiB
  Current LE             2000
  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                c1q2BN-zz9U-QzQf-E9Tl-kh4l-PPxD-UyLpbi
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-12-10 01:49:03 +0900
  LV Status              available
  # open                 1
  LV Size                163.08 GiB
  Current LE             41749
  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                1yZqZE-Mwj2-xPzs-ygqN-tPpg-F8L2-pL02Zp
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-12-10 01:49:12 +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

파티션 상태를 확인 해보면 위와 같이 설정이 되어 있다.

home 파티션을 삭제를 하자

# lvremove /dev/mapper/centos-home
Do you really want to remove active logical volume centos/home? [y/n]: y
  Logical volume "home" successfully removed

하면 파티션이 삭제 된다.

  Logical volume centos/home contains a filesystem in use.

만약에 위와 같이 뜬다면 umount 를 안해줘서 그렇다 umount 를 먼저 하자.

# umount -l /home

 

파티션 삭제 된것을 확인하면

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                Tp93ZE-oSpq-QJW3-310I-JgFj-eFrf-5wQXpz
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-12-10 01:49:03 +0900
  LV Status              available
  # open                 2
  LV Size                7.81 GiB
  Current LE             2000
  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                1yZqZE-Mwj2-xPzs-ygqN-tPpg-F8L2-pL02Zp
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-12-10 01:49:12 +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

home 이 삭제 된것을 확인 할 수 있다.

root 로 파티션을 추가하자

# lvextend -L +163.08G /dev/centos/root
  Rounding size to boundary between physical extents: 163.08 GiB.
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 213.08 GiB (54549 extents).
  Logical volume centos/root successfully resized.

163.08G 는 home 에 할당되어 있는 용량이다.

root 용량이 늘어 난지 확인 해보자.

# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                Tp93ZE-oSpq-QJW3-310I-JgFj-eFrf-5wQXpz
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-12-10 01:49:03 +0900
  LV Status              available
  # open                 2
  LV Size                7.81 GiB
  Current LE             2000
  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                1yZqZE-Mwj2-xPzs-ygqN-tPpg-F8L2-pL02Zp
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-12-10 01:49:12 +0900
  LV Status              available
  # open                 1
  LV Size                213.08 GiB
  Current LE             54549
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           253:0

50GB 에서 213.08GB 로 늘어난것을 확인 할 수 있다.

하지만 시스템에는 적용이 안되어 있다. 적용시켜주자.

# 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 55858176

적용이 된것을 확인 할 수 있다.

 

 

 

320x100