카테고리 없음

리눅스 파일시스템 크기 조정(확장)

수다스런농부 2013. 5. 24. 11:33


아래 방법을 통해서 파일시스템 확장함.
파일 시스템은 ext4
root파일 시스템인경우 라이브CD를 이용해서 하는것이
제일 안전하다고 할 수 있다.
파티션 테이블의 연속적인뒷부분의 공간이 있어야 가능하다.
없다면 대상이 되는 뒷부분의 파티션은 삭제되고
데이타역시 보존 할 수 없다. (백업만이 살길)

만약 크기를 줄이고 싶다면 먼저 resize2fs 를이용해서
파일 시스템의 크기를 먼주 줄이고 파티션을 조정 해야한다.
(이건 해보지 않았다. 이론상 그렇다는거.)

대상 언마운트
umount /target

파일 시스템 체크
e2fsck -f /dev/sdb1

저널링 비활성화
tune4fs -O ^has_journal /dev/sdb1

파티션 사이즈 변경
parted /dev/sdb


(parted) print

Model: ATA Patriot Torqx 2 (scsi)
Disk /dev/sdb: 32.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags
1 1049kB 12.9GB 12.9GB primary type=83
2 12.9GB 13.0GB 107MB primary ext4 type=83

(parted) rm 2

(parted) mkpart

Partition type? primary/extended? primary
File system type? [ext2]?
Start? 12.9GB
End? 13.4GB

(parted) quit

resize2fs /dev/sdb2

resize2fs 1.42.6 (21-Sep-2012)
Filesystem at /dev/sdb2 is mounted on /boot; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2

The filesystem on /dev/sdb2 is now 498688 blocks long.


파일시스템 체크
e2fsck -f /dev/sdb1

저널링 활성화
tune4fs -O has_journal /dev/sdb1

파일시스템 마운트
mount /target

종료.