파티션 및 파일 시스템 크기 확장
가상 이미지를 복제하여 이미지에 있는 하나 이상의 디스크의 크기를 늘리는 경우, 추가 디스크 공간을 사용하기 위해 일련의 운영 체제 명령을 실행하여 파티션 및 파일 시스템의 크기를 확장해야 합니다.
이 태스크에 대한 정보
이 태스크는 복제한 이미지에 지정한 추가 디스크 공간을 사용하기 위해
파티션 및 파일 시스템 크기를 확장하는 프로시저에 대해 설명합니다. 이 프로시저는
다음과 같은 가정 하에 디자인되었습니다.
- 조작하는 파티션이 해당 디스크의 유일한 파티션입니다.
- 파티션이 루트 파티션이 아닙니다.
이전에 이미지의 사본을 복제하여 디스크 크기를 원본 이미지보다 크게 구성한 경우에 이 프로시저를 사용하십시오.
참고: 복제된 이미지를 배치할 때마다 이 프로시저를 수행해야 합니다. 그러나 매번 이러한 명령을 실행하지 않도록 하려면
복제된 이미지를 확장하고 이 프로시저를 실행한 후 이미지를 캡처하십시오. 그런 다음, 이러한 명령을 매번 실행할 필요 없이
캡처된 이미지를 반복적으로 사용할 수 있습니다.
예를 들어, 다음 프로시저는 WebSphere Application Server Hypervisor Edition 가상 이미지에서 /opt/IBM/AppServer/profiles 의 크기를 확장하는 단계를 설명합니다.
프로시저
- 배치된 가상 머신에 로그온하여 WebSphere Application Server Hypervisor Edition의
실행 중인 인스턴스를 중지하십시오.
-bash-4.1# cd /opt/IBM/WebSphere/AppServer/bin -bash-4.1# ./stopServer.sh server1 ADMU0116I: Tool information is being logged in file /opt/IBM/WebSphere/Profiles/DefaultAppSrv01/logs/server1/stopServer.log ADMU0128I: Starting tool with the DefaultAppSrv01 profile ADMU3100I: Reading configuration for server: server1 ADMU3301I: Server stop request issued. Waiting for stop status. ADMU4000I: Server server1 stop completed.
- df -h 명령을 사용하여 파일 시스템을 나열하고
/opt/IBM/WebSphere/Profiles
과 연관된 파일 시스템을 식별하십시오.-bash-4.1# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 9.9G 4.2G 5.3G 45% / tmpfs 937M 176K 937M 1% /dev/shm /dev/sdb1 7.9G 3.9G 3.7G 52% /opt/IBM/WebSphere/AppServer /dev/sdc1 2.0G 610M 1.3G 32% /opt/IBM/WebSphere/Profiles /dev/sdd1 2.0G 507M 1.4G 27% /opt/IBM/HTTPServer
이 목록에서
/opt/IBM/WebSphere/Profiles
디렉토리가/dev/sdc1
파일 시스템과 연관되어 있습니다. - fdisk -1 명령을 사용하여 디스크 및 파티션을 나열하고 선택한 파일 시스템과 연관된 파티션을 식별하십시오.
-bash-4.1# fdisk -1 Disk /dev/sda: 12.9 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00005a0f Device Boot Start End Blocks Id System /dev/sda1 * 1 1306 10484736 83 Linux /dev/sda2 1306 1567 2097152 82 Linux swap / Solaris Disk /dev/sdb: 8589 MB, 8589934592 bytes 255 heads, 63 sectors/track, 1044 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xe5886cba Device Boot Start End Blocks Id System /dev/sdb1 1 1044 8385898+ 83 Linux Disk /dev/sdc: 12.9 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x47c0b2bc Device Boot Start End Blocks Id System /dev/sdc1 1 261 2096451 83 Linux Disk /dev/sdd: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0xdc97d4d3 Device Boot Start End Blocks Id System /dev/sdd1 1 261 2096451 83 Linux
이 출력에서 다음 파티션 정보에 주의하십시오.Device Boot Start End Blocks Id System /dev/sdc1 1 261 2096451 83 Linux
- umount 명령을 사용하여 파티션을 마운트 해제하십시오.
-bash-4.1# umount /dev/sdc1
- fdisk 명령을 사용하여 파티션을 확장하십시오.
- fdisk -u 명령을 실행하여 섹터 모드에서 디스크의 파티션 테이블을 여십시오.
-bash-4.1# fdisk -u /dev/sdc
- 프롬프트에 p 를 입력하여 디스크에 파티션을 나열하십시오.
Command (m for help): p Disk /dev/sdc: 12.9 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders, total 25165824 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x47c0b2bc Device Boot Start End Blocks Id System /dev/sdc1 63 4192964 2096451 83 Linux
시작 섹터의 값(63)에 주의하십시오. 나중에 파티션을 다시 작성할 때 이 값이 필요합니다.
- 이 파티션을 삭제하려면
d
을 입력하십시오.Command (m for help): d Selected partition 1
- 파티션을 다시 작성하려면
n
를 입력하십시오.Command (m for help): n
-
primary partition
유형을 선택하려면p
를 입력하십시오.Command action e extended p primary partition (1-4) p
- 파티션 번호 1을 선택하려면
1
을 입력하십시오.Partition number (1-4): 1
- 앞에서 주의를 기울였던 시작 섹터의 값(63)을 사용하여 첫 번째
섹터를 지정하십시오.참고: 이전과 같은 시작점에 동일한 값을 지정해야 합니다. 그러지 않으면 파일 시스템을 더 이상 마운트하거나 사용할 수 없습니다.
First sector (63-25165823, default 63): 63
- 파티션 종료점에 마지막 섹터를 지정하여 파티션을 디스크에서 사용 가능한 전체 공간으로 확장하십시오.
Last sector, +sectors or _size{K,M,G} (63-25165823, default 25165823): 25165823
- 업데이트된 파티션을 나열하고 변경사항을 확인하려면
p
를 입력하십시오.Command (m for help): p Disk /dev/sdc: 12.9 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders, total 25165824 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x47c0b2bc Device Boot Start End Blocks Id System /dev/sdc1 63 25165823 12582880+ 83 Linux
이 출력에서는
End
값이 4192964에서 25165823으로 변경되었고 블록 수가 2096451에서 12582880+로 늘었음을 보여줍니다. - 변경사항을 저장하려면
w
를 입력하십시오.Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks. -bash-4.1#
- fdisk -u 명령을 실행하여 섹터 모드에서 디스크의 파티션 테이블을 여십시오.
- e2fsck 명령을 사용하여 파티션을 점검하고 오류가 없는지 확인하십시오.
-bash-4.1# e2fsck -f /dev/sdc1 e2fsck 1.41.12 (17-May-2010) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/sdc1: 2997/131072 files (0.5% non-contiguos), 164355/524112 blocks
- resize2fs 명령을 사용하여 파일 시스템을 확장하여 파티션의 추가 공간을 모두 사용하십시오.
-bash-4.1# resize2fs /dev/sdc1 resize2fs 1.41.12 (17-May-2010) Resizing the file system on /dev/sdc1 to 3145720 (4k) blocks. The file system on /dev/sdc1 is now 3145720 blocks long.
- mount 명령을 사용하여 파티션을 마운트하십시오.
-bash-4.1# mount /dev/sdc1 /opt/IBM/WebSphere/Profiles
- df -h 명령을 사용하여 파일 시스템을 다시 나열하십시오.
-bash-4.1# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 9.9G 4.2G 5.3G 45% / tmpfs 937M 176K 937M 1% /dev/shm /dev/sdb1 7.9G 3.9G 3.7G 52% /opt/IBM/WebSphere/AppServer /dev/sdd1 2.0G 507M 1.4G 27% /opt/IBM/HTTPServer /dev/sdc1 12G 612M 11G 6% /opt/IBM/WebSphere/Profiles
이 목록에서
/dev/sdc1
의 크기가 2.0G 에서 12G로 증가했으며 사용 가능한 공간이 1.3G 에서 11G로 증가했습니다. - 서버를 시작하십시오.
-bash-4.1# ./startServer.sh server1 ADMU0116I: Tool information is being logged in file /opt/IBM/WebSphere/Profiles/DefaultAppSrv01/logs/server1/startServer.log ADMU0128I: Starting tool with the DefaultAppSrv01 profile ADMU3100I: Reading configuration for server: server1 ADMU3201I: Server launched. Waiting for initialization status. ADMU3000I: Server server1 open for e-business; process id is 7743
결과
배치된 이미지가 더 큰 디스크 공간을 이용할 수 있습니다.
다음에 수행할 작업
복제 이미지를 확장한 후 이 프로시저를 수행한 경우, 이러한 변경사항을 포함하는 이미지를 캡처하면 이러한 단계를 다시 완료할 필요 없이 해당 이미지를 반복적으로 사용할 수 있습니다.