[LINUX]ext3, ext4 크기 확장 - Resize an ext3, ext4
만약 LVM 을 통해 기존에 있던 Logical volume 을 lvresize 나 lvextend 혹은 lvreduce 를 통해 크기를 변경했을 때
lvdisplay 로 확인했을 때는 크기가 확장되거나 줄었는데 실제 mount (df) 를 통해 보면 이전하고 크기가 바뀌지 않았을 경우가 있다.
이는 LVM logical volume 의 크기를 조정했으나 이 볼륨을 실제 ext3 나 ext4 등 파일시스템으로 초기 포맷 했을 때 크기가 고정되어 버렸기 때문이다. 용어는 정확히 모르겠으나 free block 테이블이 이미 고정되었기 때문일 것이다.(추측이다.)
그럴때 resize2fs 라는 유틸을 통해 파일시스템을 다시 조정하면 된다.(용어가 맞나 모르겠다.)
아래 내용은 http://en.positon.org/post/Resize-an-ext3-ext4-partition 에서 가져왔다.
빨간 글씨 부분이 중요하다.
Before doing anything: backup your sensible data!
To extend a partition and it's filesystem , you have to:
- Extend the partition
- Extend the filesystem
To shrink a partition and it's filesystem , you have to:
- Shrink the filesystem
- Shrink the partition
For an ext3 partition, simply use parted :
parted /dev/sdx print resize N
Parted doesn't support ext4 (yet?). For an ext4 partition or if parted refuses to resize your ext3partition ( Error: File system has an incompatible feature enabled.
), use resize2fs :
To extend:
cfdisk /dev/sdx # delete the partition and create it again with the desired size resize2fs /dev/sdxY
Without giving any size, resize2fs extends the filesystem to the partition's size.
To shrink, it's almost as simple:
# example if you want a 10G partition # resize filesystem with a size smaller than the desired size resize2fs /dev/sdxY 9G cfdisk /dev/sdx # delete the partition and create it again with the desired size # (a little bigger than the filesystem!!) # then launch resize2fs again resize2fs /dev/sdxY
Doing so we get the good partition size without loosing any space.
Notes: