defragfs 명령어 (AIX 5.3·6.1)
https://archive.horanglab.com/posts/aix-cmd-defragfs
핵심 정리
- 흩어진 할당을 연속되게 재배치해 파일 시스템의 연속된 빈 공간을 늘립니다(조각 모음).
- 파일 시스템이 읽기·쓰기로 마운트되어 있어야 합니다. 서비스 중에도 돌릴 수 있지만 I/O가 많아지므로 한가한 시간에 합니다.
-q(현재 상태),-r(현재 상태와 실행 후 예상),-s(조각화 정도)는 보고서만 만들고 바꾸지 않습니다.- JFS2를 줄이려는데(
chfs -a size=-) 조각화 때문에 실패하면 먼저defragfs를 돌려 봅니다. - 스냅숏이 있는 JFS2는 스냅숏으로 데이터를 복사하느라 느리므로, 스냅숏을 지우고 돌린 뒤 다시 만드는 편이 낫습니다.
| 항목 | 내용 |
|---|---|
| 버전 | AIX 5.3, AIX 6.1 (내용이 같고, 6.1 문서에 RBAC 안내가 더해짐) |
| 원문 | IBM Commands Reference — 5.3 Volume 2, 6.1 Volume 2 |
| 파일 | /usr/sbin/defragfs, /etc/filesystems |
| 관련 명령어 | chfs, crfs, lsfs, snapshot, reorgvg |
목적
파일 시스템의 연속된 빈 공간을 늘립니다.
영어 원문
Increases a file system's contiguous free space.
구문
defragfs [ -q | -r | -s ] { Device | FileSystem }
설명
defragfs 명령은 디스크에 흩어진 할당을 연속되게 재배치해 파일 시스템의 연속된 빈 공간을 늘립니다. 조각 모음할 파일 시스템은 논리 볼륨 경로인 Device(예: /dev/hd4)나 /etc/filesystems의 마운트 지점인 FileSystem으로 지정합니다.
조각(fragment)을 쓰는 파일 시스템과 압축 파일 시스템을 위한 명령이지만, 조각을 쓰지 않는 파일 시스템의 연속된 빈 공간을 늘리는 데도 쓸 수 있습니다.
파일 시스템을 읽기·쓰기로 마운트해야 실행됩니다. -q, -r, -s는 조각화 보고서를 만들며 파일 시스템을 바꾸지 않습니다.
스냅숏이 있는 JFS2에서는 스냅숏 저장 객체로 복사할 데이터가 많아 느리며, 스냅숏이 있으면 경고를 보여 줍니다. snapshot 명령으로 스냅숏을 지우고, defragfs가 끝난 뒤 다시 만들 수 있습니다.
영어 원문
The defragfs command increases a file system's contiguous free space by reorganizing allocations to be contiguous rather than scattered across the disk. The file system to be defragmented can be specified with the Device variable, which is the path name of the logical volume (for example, /dev/hd4). It can also be specified with the FileSystem variable, which is the mount point in the /etc/filesystems file.
The defragfs command is intended for fragmented and compressed file systems. However, you can use the defragfs command to increase contiguous free space in nonfragmented file systems.
You must mount the file system read-write for this command to run successfully. Using the -q flag, the -r flag or the -s flag generates a fragmentation report. These flags do not alter the file system.
The defragfs command is slow against a JFS2 file system with a snapshot due to the amount of data that must be copied into snapshot storage object. The defragfs command issues a warning message if there are snapshots. The snapshot command can be used to delete the snapshots and then used again to create a new snapshot after the defragfs command completes.
플래그
| 플래그 | 설명 |
|---|---|
-q |
파일 시스템의 현재 상태를 보고합니다. |
-r |
현재 상태와, -q, -r, -s 없이 실행했을 때의 결과 상태를 보고합니다. |
-s |
파일 시스템의 조각화를 보고합니다. 메타데이터를 훑으므로 성능이 떨어질 수 있습니다. |
영어 원문
-q— Reports the current state of the file system.-r— Reports the current state of the file system and the state that would result if the defragfs command is run without either the-q,-ror-sflag.-s— Reports the fragmentation in the file system. This option causes defragfs to pass through meta data in the file system which may result in degraded performance.
Output
JFS 보고 항목
| 항목 | 뜻 |
|---|---|
| Number of free fragments | 빈 조각 수 |
| Number of allocated fragments | 할당한 조각 수 |
| Number of free spaces shorter than a block | 블록보다 짧은 빈 공간 수. 빈 공간은 할당되지 않은 연속 조각 묶음입니다. |
| Number of free fragments in short free spaces | 짧은 빈 공간(블록보다 짧은 것)에 있는 조각 수의 합 |
| Number of fragments moved | 옮긴 조각 수 |
| Number of logical blocks moved | 옮긴 논리 블록 수 |
| Number of allocation attempts | 빈 조각을 다시 할당한 횟수 |
| Number of exact matches | 옮길 조각이 어떤 빈 공간에 꼭 맞은 횟수 |
| Total number of fragments | 전체 조각 수 |
| Number of fragments that may be migrated | 조각 모음 중 옮길 수 있는 조각 수 |
| FileSystem filesystem is n percent fragmented | 조각화 정도(%) |
JFS2 보고 항목
| 항목 | 뜻 |
|---|---|
| Total allocation groups | 할당 그룹 수. 할당 그룹은 공간을 덩어리로 나눠 JFS2 할당 정책이 좋은 I/O 성능을 내게 합니다. |
| Allocation groups defragmented | 조각 모음한 할당 그룹 수 |
| Allocation groups skipped - entirely free | 전부 비어 있어 건너뛴 그룹 수 |
| Allocation groups skipped - too few free blocks | 재배치할 빈 블록이 너무 적어 건너뛴 그룹 수 |
| Allocation groups skipped - contains a large contiguous free space | 큰 연속 빈 공간이 있어 조각 모음할 가치가 없어 건너뛴 그룹 수 |
| Allocation groups are candidates for defragmenting | 조각 모음 대상 그룹 수 |
| Average number of free runs in candidate allocation groups | 대상 그룹의 평균 free run 수. free run은 할당되지 않은 연속 블록 묶음입니다. |
| Total number of blocks | 전체 블록 수 |
| Number of blocks that may be migrated | 조각 모음 중 옮길 수 있는 블록 수 |
| FileSystem filesystem is n percent fragmented | 조각화 정도(%) |
영어 원문
On a JFS filesystem, the definitions for the messages reported by the defragfs command are as follows:
Number of free fragments The number of free fragments in the file system.
Number of allocated fragments The number of allocated fragments in the file system.
Number of free spaces shorter than a block The number of free spaces within the file system that are shorter than a block. A free space is a set of contiguous fragments that are not allocated.
Number of free fragments in short free spaces The total number of fragments in all the short free spaces. A short free space is one that is shorter than a block.
Number of fragments moved The total number of fragments moved.
Number of logical blocks moved The total number of logical blocks moved.
Number of allocation attempts The number of times free fragments were reallocated.
Number of exact matches The number of times the fragments that are moved would fit exactly in some free space.
Total number of fragments The total number of fragments in the file system.
Number of fragments that may be migrated The number of fragments that may be moved during defragmentation.
FileSystem filesystem is n percent fragmented Shows to what extent the file system is fragmented in percentage.
On a JFS2 filesystem the definitions for the messages reported by the defragfs command are as follows: Total allocation groups The number of allocation groups in the file system. Allocation groups divide the space on a file system into chunks. Allocation groups allow JFS2 resource allocation policies to use well known methods for achieving good I/O performance.
Allocation groups defragmented The number of allocation groups that were defragmented.
Allocation groups skipped - entirely free The number of allocation groups that were skipped because they were entirely free.
Allocation groups skipped - too few free blocks The number of allocation groups that were skipped because there were too few free blocks in them for reallocation.
Allocation groups skipped - contains a large contiguous free space The number of allocation groups that were skipped because they contained a large contiguous free space which is not worth defragmenting.
Allocation groups are candidates for defragmenting The number of allocation groups that are fit for defragmenting.
Average number of free runs in candidate allocation groups The average number of free runs per allocation group, for allocation groups that are found fit for defragmentation. A free run is a contiguous set of blocks which are not allocated.
Total number of blocks The total number of blocks in the file system.
Number of blocks that may be migrated The number of blocks that may be moved during defragmentation.
FileSystem filesystem is n percent fragmented Shows to what extent the file system is fragmented in percentage.
보안
(6.1) RBAC와 Trusted AIX 사용자: 이 명령은 특권 작업을 할 수 있으며 특권 사용자만 할 수 있습니다. 권한과 특권은 lssecattr 명령이나 getcmdattr 하위 명령으로 봅니다.
영어 원문
Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations associated with this command, see the lssecattr command or the getcmdattr subcommand.
예제
| 명령 | 하는 일 |
|---|---|
defragfs /data1 |
/dev/lv00 논리 볼륨에 있는 /data1을 조각 모음 |
defragfs /data1 |
마운트 지점으로 지정해 조각 모음 |
defragfs -r /data1 |
현재 상태와 조각 모음 후 상태를 보고 |
defragfs -s /data1 |
조각화 정도를 보고 |
자주 쓰는 형태:
defragfs -s /data # 얼마나 조각났는지
defragfs /data # 조각 모음
chfs -a size=-2G /data # 그다음 줄이기
영어 원문
- To defragment the /data1 file system located on the /dev/lv00 logical volume, enter:
defragfs /data1
- To defragment the /data1 file system by specifying its mount point, enter:
defragfs /data1
- To generate a report on the /data1 file system that indicates its current status as well as its status after being defragmented, enter:
defragfs -r /data1
- To generate a report on the fragmentation in the /data1 file system, enter:
defragfs -s /data1
파일
| 파일 | 설명 |
|---|---|
/etc/filesystems |
알려진 파일 시스템과 그 특성 |
영어 원문
- /etc/filesystems — Lists the known file systems and defines their characteristics.
Related information:
- crfs command
- lsfs command
- JFS data compression
- Variable number of i-nodes
리눅스(GNU)와 다른 점
리눅스에서는 파일 시스템 정보가 /etc/fstab에 있고(AIX는 스탠자 형식의 /etc/filesystems), LVM과 파일 시스템 명령이 나뉘어 있습니다. 만들기는 lvcreate 뒤 mkfs.xfs·mkfs.ext4, 늘리기는 lvextend -r(또는 lvextend 뒤 xfs_growfs·resize2fs), 지우기는 umount 뒤 /etc/fstab 항목과 lvremove로 따로 합니다. AIX의 crfs·chfs·rmfs는 이것을 한 명령으로 합니다. 리눅스에서 조각 모음은 xfs_fsr(XFS), e4defrag(ext4)로 하고, 조각화 정도는 xfs_db -r -c frag나 e4defrag -c로 봅니다.