본문 바로가기

OS/LINUX

[ LINUX ] CentOS LVM 파티션 축소 및 확장

[ LINUX ] CentOS LVM 파티션 축소 및 확장

Reducing and expanding CentOS LVM partitions


회사 리눅스 서버의 파티션을 조정해달라는 요청을 받게되어 작성하게 되었습니다.

기본적으로 파티션을 축소 혹은 확장하기 위한 TIP 이라고 보시면 될거 같습니다.

 Centos 초기 설치시(특정설정없이 Next Next 설치시 ) , (/) lv_root 크기는 50GB 으로 Fix 가 되어있고, 나머지는 /home 으로 할당이 되어있다고 한다.     요청자는 / 에 작업을 하여야 하는데 용량이 부족하다고하니, 놀고있는 파티션 용량을 가져와서 늘려줘야되지 않겠습니까.


I was asked to reconfigure my company's Linux server partition. It is basically a TIP for shrinking or expanding partitions.  Centos (at the time of the Next install without specific setting), (/) lv_root size is fixed to 50GB, and the rest is assigned to / home. The requestor will have to work on /, but the capacity is insufficient.


1) 디스크 정보 확인

- 디스크 정보를 확인합니다. 2가지 명령어로 볼 수 있습니다. 

# fdisk -l    ( 디스크 파티션 관리 명령 ) 

# df -h      ( 디스크 마운트 상태 및 용량 확인 명령 )

어떤 방법으로 보시든 저희가 필요한 부분은 home 과 root 의 경로가 필요한 것이기 떄문에 아무거나 사용해주셔도 될 것 같습니다.


1) Check disk information - Check the disc information. Two commands are available. # fdisk -l (Disk partition management command) # df -h (disk mount status and capacity check command) No matter what you look at, we will need the path to home and root, so we can use it anyway.


 위 같은 경우는 fdisk 명령어를 사용하였고, 우리가 원하는 root 와 home 의 경로를 구할 수 있습니다.

* 빨간부분은 저희 회사명이 들어가기때문에 모자이크처리를했습니다 ^^;;



In this case, we use the fdisk command, and we can get the root and home paths we want. * The red part is mosaic processing because our company name is entered



2) 파티션 축소

- 축소할 대상의 축소용량과 경로를 Command

# lvreduce -r -L [원하는용량] [경로]


unmout 여부를 묻습니다. 잠깐 뗏다 붙일 것이니 걱정마시고 Y 하여 작업을 진행하도록 합니다. 

진행 중단에 중단하지마시고, 끝까지 처리되도록 기다려주세요 .


만약 , Device is Busy 라고 뜬다면 ?

# fuser -ck [디렉토리 경로] 로 강제로 죽이고 , 위의 방법을 다시하면 됩니다. 



2) Partition shrink - Command to reduce the capacity and path of the target to be reduced. # lvreduce -r -L [desired capacity] [path] asks if you want to unmout. Do not worry, I will put a raft for a while and let Y work on it.

Please do not interrupt the process, please wait for it to finish.




3) 파티션 축소 확인

3) Confirm partitionreduction

축소가 잘되었군요.

The reduction is good.



4) 파티션 확장

- 확장할 대상의 축소용량과 경로를 Command. 

# lvresize -r -l+[확장용량] [경로]

# lvresize -r -l +100%FREE [경로] 남아있는 모든 용량을 확장하겠다는 의미입니다.


4) Extending the partition

- Command to reduce the capacity and path of the target to expand. This means expanding all remaining capacity.

# lvresize -r -l + [extended capacity] [path]



5) LVM 상태 확인

# lvdisplay 


5) Checking LVM status


잘 바뀌었네요 

good !